# Telegram API Call Task

This task can interact with Telegram API.

# Example: Send Telegram Message

flow "telegram_send_message" {

  variable "telegram_token" {}
  variable "chat_id" {}

  task "telegram_api_call" "this" {
    client = {
      token = var.telegram_token
    api_method = "send_message"

    chat_id = var.chat_id
    text = "Hello World! - Send From Runflow"
    timeout = 10


The telegram bot will send you a new message:

preview of the telegram message

Click me to view the run output


$ runflow run examples/telegram_send_message.hcl --var telegram_token=$TELEGRAM_TOKEN --var chat_id=$CHAT_ID
[2021-07-08 23:14:41,337] "task.telegram_api_call.this" is started.
[2021-07-08 23:14:42,602] "task.telegram_api_call.this" is successful.

# Argument Reference

  • api_method - (Required, str) The API method, for example send_message. See the full methods (opens new window) page.
  • The rest of the arguments are the method parameters of the corresponding api_method listed on the page (opens new window). For example, when the api_method is send_message (opens new window), you should set:
    • chat_id - (Required, int or str) Unique identifier for the target chat or username of the target channel (in the format @channelusername).
    • text - (Required, str) Text of the message to be sent.
    • parse_mode - (Optional, str) Send Markdown or HTML.
    • ...
  • client - (Required, map) The client settings.
    • token - (Required, str) The token for telegram bot.
    • base_url - (Optional, str) Telegram Bot API service URL.
    • base_file_url - (Optional, str) Telegram Bot API file URL.

# Attributes Reference

  • result - The returning value of Telegram bot method call.