This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/main by this push:
     new fa6752e98227 Add support for the SendChatAction method in the Telegram 
API (#20704)
fa6752e98227 is described below

commit fa6752e98227592e0ec3b19cd4e3dee3eb502c07
Author: Kirill Byvshev <[email protected]>
AuthorDate: Wed Jan 7 18:39:50 2026 +0400

    Add support for the SendChatAction method in the Telegram API (#20704)
---
 .../src/main/docs/telegram-component.adoc          |   1 +
 .../telegram/model/SendChatActionMessage.java      | 127 +++++++++++++++++++++
 .../service/TelegramServiceRestBotAPIAdapter.java  |   2 +
 .../telegram/model/SendChatActionMessageTest.java  |  56 +++++++++
 4 files changed, 186 insertions(+)

diff --git a/components/camel-telegram/src/main/docs/telegram-component.adoc 
b/components/camel-telegram/src/main/docs/telegram-component.adoc
index 0629c6ac0ab4..ad380157785c 100644
--- a/components/camel-telegram/src/main/docs/telegram-component.adoc
+++ b/components/camel-telegram/src/main/docs/telegram-component.adoc
@@ -114,6 +114,7 @@ The following message bodies are allowed for a producer 
endpoint (messages of ty
 | `CreateInvoiceLinkMessage` | To create a link for an invoice 
(createInvoiceLink)
 | `AnswerShippingQueryMessage` | To reply to shipping queries 
(answerShippingQuery)
 | `AnswerPreCheckoutQueryMessage` | To respond to a pre-checkout query from a 
payment (answerPreCheckoutQuery)
+| `SendChatActionMessage` | To send a chat action status like typing, 
uploading, etc. (sendChatAction)
 | `byte[]` | To send any media type supported. It requires the 
`CamelTelegramMediaType` header to be set to the appropriate media type
 | `String` | To send a text message to a chat. It gets converted automatically 
into a `OutgoingTextMessage`
 
diff --git 
a/components/camel-telegram/src/main/java/org/apache/camel/component/telegram/model/SendChatActionMessage.java
 
b/components/camel-telegram/src/main/java/org/apache/camel/component/telegram/model/SendChatActionMessage.java
new file mode 100644
index 000000000000..b7d4db0bbfbc
--- /dev/null
+++ 
b/components/camel-telegram/src/main/java/org/apache/camel/component/telegram/model/SendChatActionMessage.java
@@ -0,0 +1,127 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.telegram.model;
+
+import java.io.Serial;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonValue;
+
+/**
+ * Use this method when you need to tell the user that something is happening 
on the bot's side. The status is set for 5
+ * seconds or less (when a message arrives from your bot, Telegram clients 
clear its typing status).
+ *
+ * @see <a href=
+ *      
"https://core.telegram.org/bots/api#sendchataction";>https://core.telegram.org/bots/api#sendchataction</a>
+ */
+@JsonInclude(JsonInclude.Include.NON_NULL)
+public class SendChatActionMessage extends OutgoingMessage {
+
+    @Serial
+    private static final long serialVersionUID = 7645218383562920862L;
+
+    /**
+     * Unique identifier of the business connection on behalf of which the 
action will be sent.
+     */
+    @JsonProperty("business_connection_id")
+    private String businessConnectionId;
+
+    /**
+     * Unique identifier for the target message thread; for supergroups only.
+     */
+    @JsonProperty("message_thread_id")
+    private Integer messageThreadId;
+
+    /**
+     * Type of action to broadcast. Choose one, depending on what the user is 
about to receive: typing for text
+     * messages, upload_photo for photos, record_video or upload_video for 
videos, record_voice or upload_voice for
+     * voice notes, upload_document for general files, choose_sticker for 
stickers, find_location for location data,
+     * record_video_note or upload_video_note for video notes.
+     */
+    private Action action;
+
+    public SendChatActionMessage() {
+    }
+
+    public SendChatActionMessage(Action action) {
+        this.action = action;
+    }
+
+    public Action getAction() {
+        return action;
+    }
+
+    public void setAction(Action action) {
+        this.action = action;
+    }
+
+    public Integer getMessageThreadId() {
+        return messageThreadId;
+    }
+
+    public void setMessageThreadId(Integer messageThreadId) {
+        this.messageThreadId = messageThreadId;
+    }
+
+    public String getBusinessConnectionId() {
+        return businessConnectionId;
+    }
+
+    public void setBusinessConnectionId(String businessConnectionId) {
+        this.businessConnectionId = businessConnectionId;
+    }
+
+    @Override
+    public String toString() {
+        final StringBuilder sb = new StringBuilder("SendChatActionMessage{");
+        sb.append("chatId='").append(chatId).append('\'');
+        sb.append(", action=").append(action);
+        sb.append(", messageThreadId=").append(messageThreadId);
+        sb.append(", 
businessConnectionId='").append(businessConnectionId).append('\'');
+        sb.append('}');
+        return sb.toString();
+    }
+
+    /**
+     * Type of action to broadcast.
+     */
+    public enum Action {
+        TYPING("typing"),
+        UPLOAD_PHOTO("upload_photo"),
+        RECORD_VIDEO("record_video"),
+        UPLOAD_VIDEO("upload_video"),
+        RECORD_VOICE("record_voice"),
+        UPLOAD_VOICE("upload_voice"),
+        UPLOAD_DOCUMENT("upload_document"),
+        CHOOSE_STICKER("choose_sticker"),
+        FIND_LOCATION("find_location"),
+        RECORD_VIDEO_NOTE("record_video_note"),
+        UPLOAD_VIDEO_NOTE("upload_video_note");
+
+        private final String value;
+
+        Action(String value) {
+            this.value = value;
+        }
+
+        @JsonValue
+        public String getValue() {
+            return value;
+        }
+    }
+}
diff --git 
a/components/camel-telegram/src/main/java/org/apache/camel/component/telegram/service/TelegramServiceRestBotAPIAdapter.java
 
b/components/camel-telegram/src/main/java/org/apache/camel/component/telegram/service/TelegramServiceRestBotAPIAdapter.java
index d834e2cebab4..f960890130e1 100644
--- 
a/components/camel-telegram/src/main/java/org/apache/camel/component/telegram/service/TelegramServiceRestBotAPIAdapter.java
+++ 
b/components/camel-telegram/src/main/java/org/apache/camel/component/telegram/service/TelegramServiceRestBotAPIAdapter.java
@@ -53,6 +53,7 @@ import 
org.apache.camel.component.telegram.model.OutgoingSetGameScoreMessage;
 import org.apache.camel.component.telegram.model.OutgoingStickerMessage;
 import org.apache.camel.component.telegram.model.OutgoingTextMessage;
 import org.apache.camel.component.telegram.model.OutgoingVideoMessage;
+import org.apache.camel.component.telegram.model.SendChatActionMessage;
 import org.apache.camel.component.telegram.model.SendLocationMessage;
 import org.apache.camel.component.telegram.model.SendVenueMessage;
 import 
org.apache.camel.component.telegram.model.StopMessageLiveLocationMessage;
@@ -113,6 +114,7 @@ public class TelegramServiceRestBotAPIAdapter implements 
TelegramService {
                 .register(CreateInvoiceLinkMessage.class, "createInvoiceLink", 
MessageResultString.class)
                 .register(AnswerPreCheckoutQueryMessage.class, 
"answerPreCheckoutQuery")
                 .register(AnswerShippingQueryMessage.class, 
"answerShippingQuery")
+                .register(SendChatActionMessage.class, "sendChatAction")
                 .build();
     }
 
diff --git 
a/components/camel-telegram/src/test/java/org/apache/camel/component/telegram/model/SendChatActionMessageTest.java
 
b/components/camel-telegram/src/test/java/org/apache/camel/component/telegram/model/SendChatActionMessageTest.java
new file mode 100644
index 000000000000..4e4b50906ab5
--- /dev/null
+++ 
b/components/camel-telegram/src/test/java/org/apache/camel/component/telegram/model/SendChatActionMessageTest.java
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.telegram.model;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+/**
+ * Tests for {@link SendChatActionMessage} JSON serialization.
+ */
+class SendChatActionMessageTest {
+
+    private final ObjectMapper objectMapper = new ObjectMapper();
+
+    @Test
+    void testActionSerializesToJson() throws JsonProcessingException {
+        SendChatActionMessage message = new 
SendChatActionMessage(SendChatActionMessage.Action.TYPING);
+        message.setChatId("123456");
+        message.setMessageThreadId(42);
+        message.setBusinessConnectionId("bc_123");
+
+        String json = objectMapper.writeValueAsString(message);
+
+        assertThat(json)
+                .contains("\"action\":\"typing\"")
+                .contains("\"chat_id\":\"123456\"")
+                .contains("\"message_thread_id\":42")
+                .contains("\"business_connection_id\":\"bc_123\"");
+    }
+
+    @Test
+    void testAllActionEnumValuesAreSnakeCase() {
+        for (SendChatActionMessage.Action action : 
SendChatActionMessage.Action.values()) {
+            assertThat(action.getValue())
+                    .isEqualTo(action.getValue().toLowerCase())
+                    .doesNotContain(" ");
+        }
+    }
+}

Reply via email to