Quickstart: Create a new Telegram chatbot with API.chat REST API

Get up and running with API.chat chatbot APIs and start developing your chatbots.

Creating a chatbot with API.chat can begin as soon as you create a API.chat account, and requires next steps:

  1. Obtain an API key

  2. Create a chatbot with a default demo scenario

  3. Create a Telegram chatbot using @BotFather

  4. Connect created a channel to the chatbot

1️⃣Obtain a API key

To use API.chat chatbot APIs you must include a valid subscription key in HTTP requests when you make calls to those APIs.

To get a subscription key for accessing APIs, a subscription is required. A subscription is a named container for a pair of subscription keys. We already created a Personal subscription for you on registration, it's availibe in your Profile. Save one of the keys for future usage.


2️⃣Create a chatbot

After you have the subscription key you can create your first chatbot. To do so you should perform POST operation on /bots endpoint with json body with name, language (EN == 1) and fancy name (for future usage). You can omit scenario field or set it to null - demo-scenario will be used by default.

curl -v -X POST "https://bot.api.chat/bots/"
-H "Content-Type: application/json"
-H "Cache-Control: no-cache"
--data-raw '{
"name": "botName",
"language": 1,
"fancy_name": "Bot Fancy Name",
"scenario": null

3️⃣Create a Telegram chatbot (Telegram channel)

There are Telegram bots and there are API.chat bots. Telegram bot is third-party applications that run inside Telegram, and API.chat bot is a scenario that moves it. For simplicity, we will name Telegram bots (and any other messengers bots) as Channels everywhere outside this section. Please don't mistake this with the actual Telegram channel.

We support a lot of channels, but for a quick start let's start with the most advanced and easiest to use - Telegram.

To create a Telegram bot use @BotFather bot. It will help you create new bots and change settings for existing ones.

Use the /newbot command to create a new bot. The BotFather will ask you for a name and username, then generate an authorization token for your new bot.

The name of your bot is displayed in contact details and elsewhere.

The Username is a short name, to be used in mentions and t.me links. Usernames are 5-32 characters long and are case insensitive, but may only include Latin characters, numbers, and underscores. Your bot's username must end in 'bot', e.g. 'tetris_bot' or 'TetrisBot'.

The token is a string like 110201543:AAHdqTcvCH1vGWJxfSeofSAs0K5PALDsaw which is required to send requests to the Bot API. You will use this token later to connect the created channel to API.chat chatbot.


4️⃣Connect the channel to the chatbot

Use channels APIs to connect Telegram channel to API.chat chatbot. 

HTTP Request

curl -v -X POST "https://bot.api.chat/channels/telegram/botName" 
-H "Content-Type: application/json"
-H "Cache-Control: no-cache"
--data-raw '{
"Token": "110201543:AAHdqTcvCH1vGWJxfSeofSAs0K5PALDsaw"

HTTP Response

HTTP/1.1 201 Created 
cache-control: no-cache
content-length: 124
content-type: application/json; charset=utf-8
"Token": "110201543:AAHdqTcvCH1vGWJxfSeofSAs0K5PALDsaw",
"BotName": "name_of_telegram_bot"

What's Next


Learn the Basics

Explore this guide on how to build a simple chatbot 


Check Full Demo

Feel free to explore just created demo scenario and try to change it for yourself.


Explore Integrations

Explore how to connect your chatbot to Zapier or Airtable with built-in integrations (soon)