Sending messages

The Channels API supports many of the features of Telegram; however, due to the omni-channel nature of the API, there may be some differences between the Channels API message and the native Telegram API.To send a Telegram message, you must have an active Telegram channel and perform an HTTP request to the following endpoint with a valid access key.

When sending outbound messages as well as setting the receiver information you must set message body field in all cases

Body

{
 "receiver": {
   "contacts": [
     {
       "identifierValue": "1033247360"
     }
   ]
 },
 "body": {...}
}

You can send messages to users who have interacted with your Telegram bot by either starting a conversation or responding to your messages. Telegram bots can also send messages in one-on-one chats, group chats, and channels where the bot has been added. However, users must initiate the interaction by messaging your bot, as bots cannot send unsolicited messages to users who have not engaged with them first.

The Channels API supports many of the features of the Telegram API. However, due to the omni-channel nature of the API, there may be some differences between the Channels API message formats and the native Telegram API. Here is an overview of Telegram message types and how they align with Channels API message types:

Telegram API type
Channels API

text

photo

audio / video

document

voice

location

sticker

-

contact

-

poll

-

dice

-

game

-

animation

video note

Outbound messages

Markdown support

By default, all text and media messages sent through our platform are treated as plain text. However, we offer support for MarkdownV1 and MarkdownV2 formatting, which can be applied by specifying the parseMode option within message metadata.

  • MarkdownV1 enables basic formatting, such as bold, italic, and hyperlinks.

  • MarkdownV2 allows more complex formatting, with additional support for features like nested styles and stricter rules for escaping special characters (e.g., !, ?, *).

Message example using MarkdownV1 formatting

{
    "type": "text",
    "text": {
        "text": "*Bold Text* _Italic Text_ [Link](http://example.com)",
        "metadata": {
            "telegram": {
                "parseMode": "Markdown"
            }
        }
    }
}

Message example using MarkdownV2 formatting

{
    "type": "text",
    "text": {
        "text": "*Bold Text* _Italic Text_ [Link](http://example.com) `code` ~strikethrough~",
        "metadata": {
            "telegram": {
                "parseMode": "MarkdownV2"
            }
        }
    }
}

Text

Text message

{
  "type": "text",
  "text": {
    "text": "Single text message"
  }
}

Text message with reply buttons

{
  "type": "text",
  "text": {
    "text": "Single text message with reply actions",
    "actions": [
      {
        "type": "reply",
        "reply": {
          "text": "Reply action 1"
        }
      },
      {
        "type": "reply",
        "reply": {
          "text": "Reply action 2"
        }
      }
    ]
  }
}

Text message with postback actions

{
  "type": "text",
  "text": {
    "text": "Single text message with postback actions",
    "actions": [
      {
        "type": "postback",
        "postback": {
          "text": "Postback action 1",
          "payload": "postback-payload-1"
        }
      },
      {
        "type": "postback",
        "postback": {
          "text": "Postback action 2",
          "payload": "postback-payload-2"
        }
      }
    ]
  }
}

Text message with location request

{
  "type": "text",
  "text": {
    "text": "Single text message with location request",
    "actions": [
      {
        "type": "locationRequest",
        "locationRequest": {
          "text": "Please share location"
        }
      }
    ]
  }
}

Image

Single image message

{
  "type": "image",
  "image": {
    "images": [
      {
        "altText": "Label of first image",
        "mediaUrl": "https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FdnJZeZvhOMhDQA8SpjQM%2Fuploads%2FrEM9zztd8SEiJS6RQuR3%2Fimage.png?alt=media"
      }
    ]
  }
}

Single image message with text

{
  "type": "image",
  "image": {
    "images": [
      {
        "altText": "Label of first image",
        "mediaUrl": "https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FdnJZeZvhOMhDQA8SpjQM%2Fuploads%2FrEM9zztd8SEiJS6RQuR3%2Fimage.png?alt=media"
      }
    ],
    "text": "Single image message"
  }
}

Multiple image message

{
  "type": "image",
  "image": {
    "images": [
      {
        "altText": "Label of first image",
        "mediaUrl": "https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FdnJZeZvhOMhDQA8SpjQM%2Fuploads%2FrEM9zztd8SEiJS6RQuR3%2Fimage.png?alt=media"
      },
      {
        "altText": "Label of second image",
        "mediaUrl": "https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FdnJZeZvhOMhDQA8SpjQM%2Fuploads%2FrEM9zztd8SEiJS6RQuR3%2Fimage.png?alt=media"
      }
    ],
    "text": "Multiple images message"
  }
}

Single image message with postback actions

{
  "type": "image",
  "image": {
    "images": [
      {
        "altText": "Image label",
        "mediaUrl": "https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FdnJZeZvhOMhDQA8SpjQM%2Fuploads%2FrEM9zztd8SEiJS6RQuR3%2Fimage.png?alt=media"
      }
    ],
    "text": "Single image message with postback actions",
    "actions": [
      {
        "type": "postback",
        "postback": {
          "payload": "postback-payload-1",
          "text": "Postback option 1"
        }
      },
      {
        "postback": {
          "payload": "postback-payload-2",
          "text": "Postback option 2"
        },
        "type": "postback"
      }
    ]
  }
}

Single image message with label and reply actions

{
    "type": "image",
    "image": {
        "images": [
            {
                "altText": "Image label",
                "mediaUrl": "https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FdnJZeZvhOMhDQA8SpjQM%2Fuploads%2FrEM9zztd8SEiJS6RQuR3%2Fimage.png?alt=media"
            }
        ],
        "text": "Single image message with reply actions",
        "actions": [
            {
                "type": "reply",
                "reply": {
                    "text": "Reply action 1"
                }
            },
            {
                "type": "reply",
                "reply": {
                    "text": "Reply action 2"
                }
            }
        ]
    }
}

Single image message with location request

{
    "type": "image",
    "image": {
        "images": [
            {
                "altText": "Label of first image",
                "mediaUrl": "https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FdnJZeZvhOMhDQA8SpjQM%2Fuploads%2FrEM9zztd8SEiJS6RQuR3%2Fimage.png?alt=media"
            }
        ],
        "actions": [
            {
                "type": "locationRequest",
                "locationRequest": {
                    "text": "Please share location"
                }
            }
        ]
    }
}

GIF

Gif message

{
    "type": "gif",
    "gif": {
        "mediaUrl": "https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FdnJZeZvhOMhDQA8SpjQM%2Fuploads%2FIEoLtO9E5bNsXkbC2D8A%2Fbird.gif?alt=media"
    }
}

File

Single file message

{
    "type": "file",
    "file": {
        "text": "Single file message",
        "files": [
            {
                "contentType": "video/mp4",
                "mediaUrl": "https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FdnJZeZvhOMhDQA8SpjQM%2Fuploads%2FtXMQ4lIinia9ehf4EpC4%2Fvideo.mp4?alt=media"
            }
        ]
    }
}

Multiple files message

{
  "type": "file",
  "file": {
    "text": "Multiple files message",
    "files": [
      {
        "contentType": "video/mp4",
        "mediaUrl": "https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FdnJZeZvhOMhDQA8SpjQM%2Fuploads%2FtXMQ4lIinia9ehf4EpC4%2Fvideo.mp4?alt=media"
      },
      {
        "contentType": "application/pdf",
        "mediaUrl": "https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FdnJZeZvhOMhDQA8SpjQM%2Fuploads%2FbgnxOoaF4aHSHUzMFCna%2Faudio.mp3?alt=media"
      }
    ]
  }
}

Location

{
    "type": "location",
    "location": {
        "coordinates": {
            "latitude": 52.37164323041201,
            "longitude": 4.884335169232767
        },
        "location": {
            "address": "Keizersgracht 268, 1016 EV, Amsterdam",
            "label": "MessageBird Amsterdam office"
        }
    }
}

Last updated