Creating a Telegram Bot

   

Follow these steps to connect your bot to Telegram:

  1. In Flow XO, click Bots in the top menu bar, then choose +New.
  2. Now choose Telegram as the messaging platform.
  3. Type in a descriptive name for the bot.
  4. Next, you should follow this link to start a conversation with the @BotFather and create a bot using the "/newbot" command. You'll find more detailed instructions on the Telegram site.
  5. After you've created the bot, you'll be given a token. Copy this as you'll need to paste it into Flow XO.
  6. To support all the available message types, you'll also need to "/setinline" to enabled (for mention or direct mention) and "/setprivacy" to disabled (for overhear) in BotFather. We'll explain how next.
  7. To enable inline support, message @BotFather with "/setinline". When he asks, choose the bot you just created. Now you'll be asked to give a placeholder message. Type something here, we suggest a generic "Ask something". You should then see a message saying your inline settings have been updated.
  8. By default, Telegram bots can only hear messages directed at them. To enable overhear commands (if you need them), you should disable privacy. It's good practice to leave privacy enabled unless you actually need to overhear. Message @BotFather with "/setprivacy". You'll then be asked to choose a bot. Now type "disable" to change the privacy mode, and finally you should see a success message.
  9. Back in Flow XO, type in your new bot's username and paste in the token you were given earlier by @BotFather.
  10. Finally, save the bot. The bot is now up and running!
  11. The last step will give you details about how to distribute your bot to other users.

Distributing Your Bot

To distribute you bot to other users, you can use a link in this format:

https://telegram.me/{username}

Where {username} is your bot's username. This will allow any Telegram user to start talking to your bot. Of course, the person clicking the link must to be signed up and ready to use Telegram on their device.

If you'd like to give people a link to allow them to add your bot to their group, you can use this link format:

https://telegram.me/{username}?startgroup=1

Again, replace {username} with your bot's username.

Configuration

In addition to the standard bot settings, you can set some defaults to determine how the standard messaging tasks within Flow XO will format your Telegram messages.

Default Keyboard

Telegram supports two types of keyboards (eg buttons), "Inline" and "Custom". When set to "inline", buttons are sent attached to the bottom of every message. This is the only keyboard method that works with channels, and it is usually the preferred way of interacting with your users. You can alternatively set your bot to use "Custom" keyboards. Custom keyboards replace the normal QWERTY keyboard with the buttons that you define. This option is rarely used as a default, but you might want to use it on a case by case basis, in which case you can use our Telegram Actions integration and send your own keyboard definitions as needed.

Keyboard buttons per row

Telegram is very flexible in the ways it lets you specify the button layout for both Inline and Custom keyboards. You can customize your button layout on a case by case basis using our Telegram Actions integration and send your own keyboard definitions, but when you are using the standard messaging actions inside Flow XO (Send Message, Ask a Question, etc), this setting will determine how many buttons to place per row.

Default parse mode

Telegram can display messages written with a specialized HTML markup or Markdown. Again, you can customize this using Telegram Actions, but you can also specify globally what format you want to use for the standard Flow XO messaging actions. In addition to HTML and Markdown, you can choose 'None'. You might want to use this mode if you are running into issues with Telegram not being able to display your messages because of 'reserved' characters. You'll see errors in the interaction logs about 'Unable to parse entity'. If you don't need Markdown or HTML to format your text, setting the default to None will allow the most flexibility in what types of text you can send without generating an error. If you DO use HTML or Markdown, be aware there are some limitations you may run into in exchange for the ability to have more control over your message formatting.

Customizing Your Bot

There are a lot of optional settings that you can update with @BotFather that will improve how your bot appears and give your users more idea about what it does.

You can read about all the bot settings over at Telegram.

Start Button

When the user connects to the bot for the first time (they click the 'START' button in Telegram), the message '/start' will be sent to the bot. You can look for the presence of this to know that the user clicked 'START' and welcome the user for the first time. The start message may also have optional arguments in the case of a deep linking (a way to drive traffic to specific flows using URLS). Please see how to work with commands here and how to set them up in Telegram with auto-complete for your users here

Telegram Specific Features

Telegram has a lot of powerful features that are unique. Because Flow XO supports many channels, not just Telegram, our standard flow building tools cannot take advantage of many of these features. However, if you are building Telegram specific flows you can take advantage of these from within Flow XO by using our Telegram Actions integration, which provides easy access to most Telegram bot functionality.

Let us know how we can improve Flow XO on our feedback site.

Still need help? Contact Us Contact Us