ByteChef LogoByteChef

Telegram

Telegram is a cloud-based messaging platform that enables users to send messages, media, and files, and supports automation and integrations through its API.

Categories: Communication

Type: telegram/v1


Connections

Version: 1

custom

Properties

NameLabelTypeDescriptionRequired
botTokenBot TokenSTRINGtrue

Connection Setup

Create a Telegram Bot and get the Bot Token

  1. In Telegram, start a chat with BotFather.
  2. Send the /newbot command and follow the prompts:
    • Choose a display name (can be changed later).
    • Choose a unique username that ends with bot (e.g., my_bytechef_bot).
  3. Copy the Bot Token provided by BotFather (format: 1234567890:AA...). Keep it secret.

Helpful links:


Actions

Send Media

Name: sendMedia

Sends a media message through a Telegram bot.

Properties

NameLabelTypeDescriptionRequired
chat_idChat IDSTRINGUnique identifier for the target chat or username of the target channel. Your bot has to be member of that chat or group.true
mediaTypenullSTRING
Options document, photo, video
Type of media to send.true
documentDocumentFILE_ENTRYDocument to send.true
photoPhotoFILE_ENTRYPhoto to send.true
videoVideoFILE_ENTRYVideo to send.true
direct_messages_topic_idDirect Messages Topic IDSTRINGIdentifier of the direct messages topic to which the message will be sent; required if the message is sent to a direct messages chat.false

Example JSON Structure

{
  "label" : "Send Media",
  "name" : "sendMedia",
  "parameters" : {
    "chat_id" : "",
    "mediaType" : "",
    "document" : {
      "extension" : "",
      "mimeType" : "",
      "name" : "",
      "url" : ""
    },
    "photo" : {
      "extension" : "",
      "mimeType" : "",
      "name" : "",
      "url" : ""
    },
    "video" : {
      "extension" : "",
      "mimeType" : "",
      "name" : "",
      "url" : ""
    },
    "direct_messages_topic_id" : ""
  },
  "type" : "telegram/v1/sendMedia"
}

Output

Type: OBJECT

Properties

NameTypeDescription
okBOOLEAN
Options true, false
resultOBJECT
Properties {INTEGER(message_id), INTEGER(message_thread_id), {INTEGER(topic_id), {INTEGER(id), BOOLEAN(is_bot), STRING(first_name), STRING(last_name), STRING(username)}(user)}(direct_messages_topic), {INTEGER(id), BOOLEAN(is_bot), STRING(first_name), STRING(last_name), STRING(username)}(from), {INTEGER(id), STRING(title), STRING(username), STRING(type), BOOLEAN(is_direct_messages)}(sender_chat), INTEGER(date), {INTEGER(id), STRING(title), STRING(username), STRING(type), BOOLEAN(is_direct_messages)}(chat), STRING(text), {INTEGER(topic_id), {INTEGER(id), BOOLEAN(is_bot), STRING(first_name), STRING(last_name), STRING(username)}(user)}(direct_messages_topic), {STRING(file_id), STRING(file_unique_id), {STRING(file_id), STRING(file_unique_id), INTEGER(width), INTEGER(height), INTEGER(file_size)}(thumbnail), STRING(file_name), STRING(mime_type), INTEGER(file_size)}(document), [{STRING(file_id), STRING(file_unique_id), INTEGER(width), INTEGER(height), INTEGER(file_size)}](photo), {STRING(file_id), STRING(file_unique_id), STRING(width), STRING(height), INTEGER(duration), STRING(file_name), STRING(mime_type), INTEGER(file_size)}(video)}

Output Example

{
  "ok" : false,
  "result" : {
    "message_id" : 1,
    "message_thread_id" : 1,
    "direct_messages_topic" : {
      "topic_id" : 1,
      "user" : {
        "id" : 1,
        "is_bot" : false,
        "first_name" : "",
        "last_name" : "",
        "username" : ""
      }
    },
    "from" : {
      "id" : 1,
      "is_bot" : false,
      "first_name" : "",
      "last_name" : "",
      "username" : ""
    },
    "sender_chat" : {
      "id" : 1,
      "title" : "",
      "username" : "",
      "type" : "",
      "is_direct_messages" : false
    },
    "date" : 1,
    "chat" : {
      "id" : 1,
      "title" : "",
      "username" : "",
      "type" : "",
      "is_direct_messages" : false
    },
    "text" : "",
    "document" : {
      "file_id" : "",
      "file_unique_id" : "",
      "thumbnail" : {
        "file_id" : "",
        "file_unique_id" : "",
        "width" : 1,
        "height" : 1,
        "file_size" : 1
      },
      "file_name" : "",
      "mime_type" : "",
      "file_size" : 1
    },
    "photo" : [ {
      "file_id" : "",
      "file_unique_id" : "",
      "width" : 1,
      "height" : 1,
      "file_size" : 1
    } ],
    "video" : {
      "file_id" : "",
      "file_unique_id" : "",
      "width" : "",
      "height" : "",
      "duration" : 1,
      "file_name" : "",
      "mime_type" : "",
      "file_size" : 1
    }
  }
}

Find Chat or Group ID

To find the Chat or Group ID, click here.

Find Direct Message Topic ID

To find the Direct Message Topic ID, click here.

Send Message

Name: sendMessage

Sends a message through a Telegram bot.

Properties

NameLabelTypeDescriptionRequired
chat_idChat IDSTRINGUnique identifier for the target chat or username of the target channel. Your bot has to be member of that chat or group.true
textTextSTRINGText of the message to be sent.true
direct_messages_topic_idDirect Messages Topic IDSTRINGIdentifier of the direct messages topic to which the message will be sent; required if the message is sent to a direct messages chat.false

Example JSON Structure

{
  "label" : "Send Message",
  "name" : "sendMessage",
  "parameters" : {
    "chat_id" : "",
    "text" : "",
    "direct_messages_topic_id" : ""
  },
  "type" : "telegram/v1/sendMessage"
}

Output

Type: OBJECT

Properties

NameTypeDescription
okBOOLEAN
Options true, false
resultOBJECT
Properties {INTEGER(message_id), INTEGER(message_thread_id), {INTEGER(topic_id), {INTEGER(id), BOOLEAN(is_bot), STRING(first_name), STRING(last_name), STRING(username)}(user)}(direct_messages_topic), {INTEGER(id), BOOLEAN(is_bot), STRING(first_name), STRING(last_name), STRING(username)}(from), {INTEGER(id), STRING(title), STRING(username), STRING(type), BOOLEAN(is_direct_messages)}(sender_chat), INTEGER(date), {INTEGER(id), STRING(title), STRING(username), STRING(type), BOOLEAN(is_direct_messages)}(chat), STRING(text), {INTEGER(topic_id), {INTEGER(id), BOOLEAN(is_bot), STRING(first_name), STRING(last_name), STRING(username)}(user)}(direct_messages_topic), {STRING(file_id), STRING(file_unique_id), {STRING(file_id), STRING(file_unique_id), INTEGER(width), INTEGER(height), INTEGER(file_size)}(thumbnail), STRING(file_name), STRING(mime_type), INTEGER(file_size)}(document), [{STRING(file_id), STRING(file_unique_id), INTEGER(width), INTEGER(height), INTEGER(file_size)}](photo), {STRING(file_id), STRING(file_unique_id), STRING(width), STRING(height), INTEGER(duration), STRING(file_name), STRING(mime_type), INTEGER(file_size)}(video)}

Output Example

{
  "ok" : false,
  "result" : {
    "message_id" : 1,
    "message_thread_id" : 1,
    "direct_messages_topic" : {
      "topic_id" : 1,
      "user" : {
        "id" : 1,
        "is_bot" : false,
        "first_name" : "",
        "last_name" : "",
        "username" : ""
      }
    },
    "from" : {
      "id" : 1,
      "is_bot" : false,
      "first_name" : "",
      "last_name" : "",
      "username" : ""
    },
    "sender_chat" : {
      "id" : 1,
      "title" : "",
      "username" : "",
      "type" : "",
      "is_direct_messages" : false
    },
    "date" : 1,
    "chat" : {
      "id" : 1,
      "title" : "",
      "username" : "",
      "type" : "",
      "is_direct_messages" : false
    },
    "text" : "",
    "document" : {
      "file_id" : "",
      "file_unique_id" : "",
      "thumbnail" : {
        "file_id" : "",
        "file_unique_id" : "",
        "width" : 1,
        "height" : 1,
        "file_size" : 1
      },
      "file_name" : "",
      "mime_type" : "",
      "file_size" : 1
    },
    "photo" : [ {
      "file_id" : "",
      "file_unique_id" : "",
      "width" : 1,
      "height" : 1,
      "file_size" : 1
    } ],
    "video" : {
      "file_id" : "",
      "file_unique_id" : "",
      "width" : "",
      "height" : "",
      "duration" : 1,
      "file_name" : "",
      "mime_type" : "",
      "file_size" : 1
    }
  }
}

Find Chat or Group ID

To find the Chat or Group ID, click here.

Find Direct Message Topic ID

To find the Direct Message Topic ID, click here.

Triggers

New Message

Name: newMessage

Trigger on new incoming message of any kind — text, photo, sticker, and so on. Incoming message has to be in a group that your bot is member of.

Type: DYNAMIC_WEBHOOK

Output

Type: OBJECT

Properties

NameTypeDescription
update_idINTEGER
messageOBJECT
Properties {INTEGER(message_id), INTEGER(message_thread_id), {INTEGER(topic_id), {INTEGER(id), BOOLEAN(is_bot), STRING(first_name), STRING(last_name), STRING(username)}(user)}(direct_messages_topic), {INTEGER(id), BOOLEAN(is_bot), STRING(first_name), STRING(last_name), STRING(username)}(from), {INTEGER(id), STRING(title), STRING(username), STRING(type), BOOLEAN(is_direct_messages)}(sender_chat), INTEGER(date), {INTEGER(id), STRING(title), STRING(username), STRING(type), BOOLEAN(is_direct_messages)}(chat), STRING(text), {INTEGER(topic_id), {INTEGER(id), BOOLEAN(is_bot), STRING(first_name), STRING(last_name), STRING(username)}(user)}(direct_messages_topic), {STRING(file_id), STRING(file_unique_id), {STRING(file_id), STRING(file_unique_id), INTEGER(width), INTEGER(height), INTEGER(file_size)}(thumbnail), STRING(file_name), STRING(mime_type), INTEGER(file_size)}(document), [{STRING(file_id), STRING(file_unique_id), INTEGER(width), INTEGER(height), INTEGER(file_size)}](photo), {STRING(file_id), STRING(file_unique_id), STRING(width), STRING(height), INTEGER(duration), STRING(file_name), STRING(mime_type), INTEGER(file_size)}(video)}

JSON Example

{
  "label" : "New Message",
  "name" : "newMessage",
  "type" : "telegram/v1/newMessage"
}

Find Chat or Group ID

To find the Chat or Group ID, click here.

What to do if your action is not listed here?

If this component doesn't have the action you need, you can use Custom Action to create your own. Custom Actions empower you to define HTTP requests tailored to your specific requirements, allowing for greater flexibility in integrating with external services or APIs.

To create a Custom Action, simply specify the desired HTTP method, path, and any necessary parameters. This way, you can extend the functionality of your component beyond the predefined actions, ensuring that you can meet all your integration needs effectively.


Additional Instructions

How to find Chat or Group ID

  • Method 1: Telegram Web URL
  1. Login to Telegram Web.
  2. Open chat or group you want to find ID of.
  3. URL will be in the format: https://web.telegram.org/k/#-5291165340
  4. Extract the number after #- to get the Chat ID or Group ID.
  • Method 2: Using ByteChef Telegram Trigger Output
  1. Create a ByteChef workflow that includes a Telegram trigger.
  2. Run the workflow and observe the output from the Telegram trigger.
  3. Look for the id in the chat object in the JSON response to get the Chat ID or Group ID.

How to find Direct Message Topic ID

  1. Create a ByteChef workflow that includes a Telegram trigger.
  2. Run the workflow and observe the output from the Telegram trigger.
  3. Look for the topic_id in the direct_messages_topic object in the JSON response to get the Chat ID or Group ID.

How is this guide?

Last updated on

On this page