One of the great advantages of chatbots is that, unlike applications, they don't need to be downloaded, it is not necessary to update them and they do not take up space in the phone's memory.
Another is that we can have several bots integrated in the same chat. This way we avoid jumping from one app to another according to what we need at each moment.
The main consequences? More pleasant user experiences and faster and simpler customer service interactions.
How to create a bot for Telegram
First things first. You need to sign up for Telegram (obviously). I recommend using the Telegram web client to test the basics.
Open the Telegram application, search for @BotFather and start the chat. Send the /newbot command and follow the instructions. After completing the initial steps, you will get:
- Your own token
- Telegram api URL - api.telegram.org/<your token>
- link to documentation
At the moment the bot is 100% passive.
Integration with Chatcompose
To continue you will need a ChatCompose account. You can register here.
Once registered, go to the Install> Integrations section. There you will see the option to integrate with Telegram.
You will see the following:
Enter the token you generated with BotFather and save.
The token should look something like 000000:AAAAAAAAAAAAA, where the zeros are numbers and the As are letters.
Once saved, we will register our bot route with telegram. Copy the route from our platform and paste it in this url along with your token.
api.telegram.org/bot<your_token>/setWebHook?url=<your_route>
The url should look something like this:
api.telegram.org/bot000000:AAAAAAAAAAAAA/setWebHook?url=https://panel.chatcompose.com/telegram/yourbot
Navigate to that route. The answer should return the following:
{"ok":true,"result":true,"description":"Webhook was set"}
To test if the configuration was successful you can navigate to:
api.telegram.org/bot<your_token>/getWebhookInfo
The call should return the chatcompose url we just configured.
If you have not yet entered the token generated with BotFather in ChatCompose, do it now.
Next steps
Your bot should be installed and running on Telegram. Do not forget to configure your automatic responses within ChatCompose in the Database section.
Click on the address of your bot generated by BotFather (t.me/nameofyour) and start interacting with it.