Telegram

With over 200 million active monthly users, Telegram is a free messaging app with a focus on speed and security. Thanks to its distributed infrastructure and encryption, Telegram is fast and secure. It can be used on multiple devices at the same time — messages are synced seamlessly across any number of phones, tablets or computers. Telegram allows businesses to send messages, photos, files of any type, as well as use other rich capabilities like quick replies, postbacks, compound messages and carousels.

Capabilities

Telegram supports a wide variety of capabilities as seen in the channel capabilities grid. Below is a detailed view of each capabilities.

Content Types

  • Text

    Full SupportAPI
  • Image

    Full SupportAPI
  • File

    Partial SupportAPI
  • Emoji

    Full SupportAPI
  • GIF

    Full SupportAPI
  • Location

    Full SupportAPI

Action Types

  • Link

    Full SupportAPI
  • Extension

    Partial SupportAPI
  • Buy

    Full SupportAPI
  • Postback

    Full SupportAPI
  • Reply

    Full SupportAPI
  • Location Request

    Full SupportAPI

Structured Messages

  • Compound Message

    Full SupportAPI
  • Carousel

    Full SupportAPI

Indicators

  • Typing

    Full SupportAPI
  • Read

    Full SupportAPI
  • Conversation Start

    Full SupportAPI

Delivery Events

Delivery events allow you to track deliveries of Sunshine Conversations messages to Telegram by subscribing to the conversation:message:delivery:channel webhook. Failures to deliver a message to Telegram can be detected by subscribing to the conversation:message:delivery:failure webhook.

The Telegram message IDs associated with each Sunshine Conversations message are available in delivery event payloads in the externalMessages property.

Downloading Telegram and Creating an Account

Telegram Messenger is available for smartphones, tablets, desktop computers, and as a web-based application. Your messages automatically sync between your devices.

To download Telegram, go to https://telegram.org and select your platform, or go to your smartphone’s app store.

Open Telegram, and then follow the instructions to create your account.

Note: You need an existing account to log in to Telegram Web. You cannot create an account from within Telegram Web.

Creating a Bot

Telegram bots are third-party AI applications that perform functions such as interacting with users, relaying weather information, and listing news articles. These bots run within Telegram.

This example uses BotFather to create a bot and the access tokens, and then uses that bot to send messages from Telegram to Sunshine Conversations.

For more information on Telegram bots, see Bots: An introduction for developers.

To create a bot

  1. Open your Telegram application or go to the web-browser version at https://web.telegram.org/z/
  2. Search for @BotFather and start a chat with the bot.

  3. In your chat window, type /newbot and follow the instructions on the screen.

    When you have successfully created a bot, BotFather displays a “Done! Congratulations on your new bot.” message.

  4. Copy the secure token from that message.

    Sunshine Conversation uses that secure token to integrate with Telegram.

Integrating with Sunshine Conversations

Once you have created the bot, all you have to do is enter the bot’s access token on the integration page. Sunshine Conversations now relays any message it receives to your business systems.

Note: Make sure to log in to Telegram before continuing the steps below.

To integrate Telegram with Sunshine Conversations

  1. In the Sunshine Conversations dashboard, click the app where you want to integrate Telegram or create a new one.

  2. Click Connect Integrations.

  3. Expand the Customer Channels section and click Telegram.

  4. Click Connect.

    Telegram Integration Page Settings

  5. If you have not already created a Telegram bot, click Create a Bot and follow the instructions above.

  6. Enter a unique name for this integration.

  7. Paste the secure token you received when creating a bot into Bot Token.

  8. Click Authenticate your Telegram Bot.

To test your integration

  1. In the Telegram app, start a chat with the bot you created.

    If you don’t remember your bot’s name, open the chat history with BotFather.

  2. Enter a test message such as This is a test.

  3. In the Sunshine Conversations dashboard, open the app where you integrated Telegram and click Logs.

    If you see something similar to this, your integration is successful.

Telegram Log

Once your server is listening for requests, create a webhook to receive the message.

  1. In the Sunshine Conversations dashboard, open the app where you integrated Telegram and click Connect integrations.

  2. From the categories list on the left side, click API & Webhooks and then click Webhooks.

  3. Click Connect and then click Create a webhook.

  4. Enter your webhook URL.

  5. Check the Conversation message trigger and then click Create webhook.

To test your webhook

  1. In the Telegram app, start a chat with the bot you created.

  2. Enter a test message such as This is another test.

  3. In the Sunshine Conversations dashboard, open the app where you integrated Telegram and click Logs.

    If you see something similar to this, your webhook is receiving your messages.

Telegram Webhook Log

Conversations Through the Bot

To send a user to your bot, you can direct them to https://telegram.me/<your_bot_username>. Telegram users can also search for your bot by its username, which is obtained while creating a bot with BotFather. Once they have added your bot to their contacts, your bot will act as any other Telegram user. Any user will be able to send normal text messages to your bot or any of the supported file formats (documents, images, sound). If the user sends a file, the message will contain a link to the file that was sent.

When you reply from any of the configured backend channels, Telegram users will receive the message as though it was coming from the bot.

Action Buttons

When used with Telegram, message actions work as expected. A button with type link will bring the user to a web page, while postback buttons will trigger any Sunshine Conversations webhook listening to the postback trigger.

Payment requests with the Stripe integration will turn into link buttons which bring the user to a checkout page where payment information can be entered.