Skip to content

Commit 32804d6

Browse files
authored
Add responses for Telegram bot actions (#41692)
1 parent f0c38e1 commit 32804d6

File tree

1 file changed

+73
-0
lines changed

1 file changed

+73
-0
lines changed

source/_integrations/telegram_bot.markdown

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,8 @@ Send a notification.
209209
| `reply_to_message_id` | yes | Mark the message as a reply to a previous message. In `telegram_callback` handling, for example, you can use {% raw %}`{{ trigger.event.data.message.message_id }}`{% endraw %} |
210210
| `message_thread_id` | yes | Send the message to a specific topic or thread.|
211211

212+
This action returns a [send message response](#send-message-response).
213+
212214
### Action `telegram_bot.send_photo`
213215

214216
Send a photo.
@@ -235,6 +237,8 @@ Send a photo.
235237
| `reply_to_message_id` | yes | Mark the message as a reply to a previous message. In `telegram_callback` handling, for example, you can use {% raw %}`{{ trigger.event.data.message.message_id }}`{% endraw %} |
236238
| `message_thread_id` | yes | Send the message to a specific topic or thread.|
237239

240+
This action returns a [send message response](#send-message-response).
241+
238242
### Action `telegram_bot.send_video`
239243

240244
Send a video.
@@ -260,6 +264,8 @@ Send a video.
260264
| `reply_to_message_id` | yes | Mark the message as a reply to a previous message. In `telegram_callback` handling, for example, you can use {% raw %}`{{ trigger.event.data.message.message_id }}`{% endraw %} |
261265
| `message_thread_id` | yes | Send the message to a specific topic or thread.|
262266

267+
This action returns a [send message response](#send-message-response).
268+
263269
### Action `telegram_bot.send_animation`
264270

265271
Send an animation.
@@ -286,6 +292,8 @@ Send an animation.
286292
| `reply_to_message_id` | yes | Mark the message as a reply to a previous message. In `telegram_callback` handling, for example, you can use {% raw %}`{{ trigger.event.data.message.message_id }}`{% endraw %} |
287293
| `message_thread_id` | yes | Send the message to a specific topic or thread.|
288294

295+
This action returns a [send message response](#send-message-response).
296+
289297
### Action `telegram_bot.send_voice`
290298

291299
Send a voice message.
@@ -311,6 +319,8 @@ Send a voice message.
311319
| `reply_to_message_id` | yes | Mark the message as a reply to a previous message. In `telegram_callback` handling, for example, you can use {% raw %}`{{ trigger.event.data.message.message_id }}`{% endraw %} |
312320
| `message_thread_id` | yes | Send the message to a specific topic or thread.|
313321

322+
This action returns a [send message response](#send-message-response).
323+
314324
### Action `telegram_bot.send_sticker`
315325

316326
Send a sticker.
@@ -336,6 +346,8 @@ Send a sticker.
336346
| `reply_to_message_id` | yes | Mark the message as a reply to a previous message. In `telegram_callback` handling, for example, you can use {% raw %}`{{ trigger.event.data.message.message_id }}`{% endraw %} |
337347
| `message_thread_id` | yes | Send the message to a specific topic or thread.|
338348

349+
This action returns a [send message response](#send-message-response).
350+
339351
### Action `telegram_bot.send_document`
340352

341353
Send a document.
@@ -362,6 +374,8 @@ Send a document.
362374
| `reply_to_message_id` | yes | Mark the message as a reply to a previous message. In `telegram_callback` handling, for example, you can use {% raw %}`{{ trigger.event.data.message.message_id }}`{% endraw %} |
363375
| `message_thread_id` | yes | Send the message to a specific topic or thread.|
364376

377+
This action returns a [send message response](#send-message-response).
378+
365379
### Action `telegram_bot.send_location`
366380

367381
Send a location.
@@ -381,6 +395,8 @@ Send a location.
381395
| `reply_to_message_id` | yes | Mark the message as a reply to a previous message. In `telegram_callback` handling, for example, you can use {% raw %}`{{ trigger.event.data.message.message_id }}`{% endraw %} |
382396
| `message_thread_id` | yes | Send the message to a specific topic or thread.|
383397

398+
This action returns a [send message response](#send-message-response).
399+
384400
### Action `telegram_bot.send_poll`
385401

386402
Send a poll.
@@ -399,6 +415,8 @@ Send a poll.
399415
| `reply_to_message_id` | yes | Mark the message as a reply to a previous message. In `telegram_callback` handling, for example, you can use {% raw %}`{{ trigger.event.data.message.message_id }}`{% endraw %} |
400416
| `message_thread_id` | yes | Send the message to a specific topic or thread.|
401417

418+
This action returns a [send message response](#send-message-response).
419+
402420
### Action `telegram_bot.send_chat_action`
403421

404422
Send a chat action. Use it to notify the user with the relevant "typing" action when a bot response may be delayed, so they know a message is coming soon. Telegram clears this status after 5 seconds or when the reply arrives.
@@ -512,6 +530,40 @@ Sets the bot's reaction for a given message.
512530
| `reaction` | no | Emoji to react to the message with. |
513531
| `is_big` | yes | Whether to use a large variant of the reaction animation. |
514532

533+
## Response schemas for actions
534+
535+
{% tip %}
536+
537+
Responses can be accessed using the `response_variable` of actions.
538+
You can refer to the [send a message then edit it after a delay](#example-send_message-then-edit-it-after-a-delay) automation for an example of usage of the response.
539+
540+
{% endtip %}
541+
542+
### Send message response
543+
544+
Response schema:
545+
546+
| Data attribute | Optional | Type | Description |
547+
| -------------- | -------- | -------------------- | ------------------------------------------------------------------------- |
548+
| `chats` | no | list | A list of chat objects. Each object represents a successful message sent. |
549+
550+
Chat object schema:
551+
552+
| Data attribute | Optional | Type | Description |
553+
| ---------------| -------- | ------- | --------------------------------------- |
554+
| `chat_id` | no | integer | The target chat_id of the sent message. |
555+
| `message_id` | no | integer | The id of the message. |
556+
557+
Example response:
558+
559+
```yaml
560+
chats:
561+
- chat_id: 1234567890
562+
message_id: 100
563+
- chat_id: -1234567890
564+
message_id: 200
565+
```
566+
515567
## Telegram notification platform
516568

517569
{% warning %}
@@ -1011,6 +1063,27 @@ actions:
10111063
disable_web_page_preview: true
10121064
```
10131065
1066+
## Example: send_message then edit it after a delay
1067+
1068+
{% raw %}
1069+
1070+
```yaml
1071+
actions:
1072+
- action: telegram_bot.send_message
1073+
data:
1074+
message: testing
1075+
response_variable: response
1076+
- delay:
1077+
seconds: 5
1078+
- action: telegram_bot.edit_message
1079+
data:
1080+
message: done testing
1081+
chat_id: "{{ response.chats[0].chat_id }}"
1082+
message_id: "{{ response.chats[0].message_id }}"
1083+
```
1084+
1085+
{% endraw %}
1086+
10141087
## Example: send_message to a topic within a group
10151088
10161089
```yaml

0 commit comments

Comments
 (0)