Creating Telegram Bot Streams

This article will walk you through creating a Telegram Bot stream step by step.

Streams API in the CommPeak SMS platform provides routes for two-way conversations in Telegram. Learn how to create a Telegram bot and complete adding a stream in TextPeak.

Step 1: Create a Telegram Bot

Before adding a Telegram Bot stream, create a Telegram bot using BotFather.

Screenshot with adding a Telegram bot in BotFather

Creating a Telegram bot using BotFather

When adding a stream, in Step 4, you will be asked to provide an authorization token generated in Telegram.

Screenshot with generated authorization token

Authorization token generated in Telegram

Step 2: Load Stream Creation Wizard

To start, select Streams API in the main menu on the left and click Create Streams API on the page that opens. Then choose Telegram Bot in the pop-up window.

Screenshot with choosing stream type with Telegram type highlighted

Stream type options: Telegram

The Create New Stream wizard will load. Fill in the necessary information to complete each step.

Step 3: Stream API Details

Start with entering stream details:​

  • Stream API name - enter a meaningful name to locate the stream quickly.

  • Stream API description - provide more information that will be visible when you open the stream.

  • Enable IP ACL - optionally, select the checkbox to limit access to the stream. Then, in the Add IP field, add one or more IP addresses from which you will make API calls. To add an IP, enter it and click Add.

  • Tags - create tags and apply them immediately to categorize your streams and quickly find the ones you need (optional). To add a tag, enter it in the field and then select from the drop-down.

    Screenshot of the Create New Stream page

    Create New Stream page

Click Save & Next to proceed to the next step.

📘

NOTE

You can save the stream as a draft on each step and then complete the rest at any time later.

Step 4: Telegram Bot Settings

Enter your token to access the HTTP API that was generated when creating a new bot. Then click Save & Next to proceed to the next step.

Screenshot with Telegram Bot Settings step

Telegram Bot settings section

Step 5: Incoming Messages Webhook (optional)

Create a Webhook right away to receive incoming messages through the API.

  • URL - select the GET or POST method and enter the URL to which you want to send data
  • HTTP Headers - optionally, provide the key name and value.

The requests' preview is available on the right. You can copy the request body while creating the webhook or creating the stream summary.

Screenshot with Incoming Messages Webhook step

Incoming Message Webhook section

You can skip this step for now. Otherwise, click Save & Next to proceed to the next step.

Step 6: Stream Summary

You can review stream details here.

Screenshot of the Stream Summary section

Stream Summary section

The incoming message webhook settings will be displayed at the bottom if a webhook was created in Step 3.​

Screenshot with Incoming Message Webhook settings

Reviewing Incoming Message Webhook section

The API requests preview is available on the right. Click the expand button to view the request.

Screenshot of API requests with the expand button highlighted

API requests preview: expand button

You can copy the endpoint or request body immediately.

Screenshot with API requests with the copy buttons highlighted

Message with media request section with the Code Copy option

After you click Create Stream, a pop-up window appears. You can copy your authorization token here.

Screenshot with a pop-up providing a stream authorization token

Stream IP was created successfully success window

Finally, click Done. The new stream will appear at the top of your Streams API table.