January 15, 2023

How to create Telegram payment bot and connect it to telegr.store

In this post you’ll learn how to create a Telegram bot, connect payments to it and host it on telegr.store.

Here is a video version of this manual

Creating a bot

Telegram created a special bot called BotFather (a reference to a famous film “God Father”) that gives birth to all other bot in the platform.

Open Telegram client in the desktop (it’s more convenient to set up bot from that desktop than from mobile) and search for BotFather in the search menu.

Beware - you’ll see a some results in the search that look like BotFather, but are in fact not:

Once you’ve started the BotFather you may click on the menu button and see the list of supported commands. You’ll need /newbot command

BotFather starts to ask you for your bot details. The first one is the name. It’s just a common name - could be a name of your business.

Then it asks for a username. This one has a special meaning - it will the part of the URL you’ll share with your customers (users of your group). This name shouldn’t have any spaces and must end with “bot”.

The result of your dialogue with the BotFather would be a long message that contains the bot token - save it for later.

Your bot is created, let’s move on to its customization

Bot customization (optional)

Here you are going to setup bot’s avatar and description, which makes your bot to stand out on Telegram.

In the BotFather chat, select the menu and hit /mybots command and click on your bot’s username.

This show a bunch of buttons - you’ll need “Edit bot” button. It’ll show what the customization options are:

They are:

  • Name - the one you’ve setup when creating the bot. Here you may change it. You cannot change username, though.
  • About - this a short description of the bot. Your subscribers will see it when you share the link to your bot in chats
  • Description - this is another description your subscribers will see when they open a dialogue with your bot
  • Description Picture - accompanies the description from above
  • Botpic - is an avatar

Go through all these options and set them up to your taste. The BotFather gives very intuitive tips, so I won’t be doing a deep dove here.

Bear in mind that all this customization is not mandatory to run your bot with telegr.store.

Connecting payments

In the BotFather chat, select the menu and hit /mybots command and click on your bot’s username. There you’ll see “Payments” button.

You’ll see the list of payment providers. The ones that are available in your country are at the top. The setup is different for each one of them. I’ll be showing the Stripe one.

Click on the provider, and you’ll see 2 more buttons: for test and live integration. Start with the test one - once you connect your bot to telegr.store and test it yourself, you may switch to “Live”.

With Stripe, for example, tests could be done with a demo credit card (4242 4242 4242 4242, any CVC and expiry date in the future, any name) - no real money would get transferred during tests.

Once you finished the setup with Stripe, you’ll see a payment token - click on it to copy to the clipboard.

To get the full experience of what telegr.store has to offer, you’ll need payments to be configured. But you may skip this step - if you don’t have the payment token, you may use your bot with telegr.store as a way to accept orders without payments. Payments would be done outside Telegram, in a manual mode, bot would be a way for your clients to place requests for your goods).

Connecting with telegr.store

At this step, you should have 2 tokens - bot token and payment token.

Once you open the telegr.store (https://app.telegr.store/auth/login) on the top, you’ll see a menu. Select Store -> Tokens

You’ll see a form to put the tokens. Payment token could be blank if you want to use your bot in manual mode.

After hitting save you’ll see the status page of the integration with Telegram API:

This page requires a bit if explanation:

  • “Tokens” status tells whether you’ve filled in the tokens in the previous step
  • “Payments” status will show whether you are operating in with Test or Live payments or a manual mode
  • “Webhooks” status tells whether Telegram servers know how to reach telegr.store
  • “Commands” status says whether your bot commands are ok (remember when using BotFather you used this blue button with a menu - your bot will have a similar one)
  • “Username” - just for your reference, this is a link to your bot.

Hit “Finish setup” button and see the statuses change.

If you have Payments in test mode, you can send /test_invoice command to your bot (open your bot in Telegram for that). You’ll see a test invoice. It’s a good smoke test that everything works.

And of course, all statuses should be green (and payments in live mode) before you present your bot to your subscribers.

Start your own Telegram store bot at telegr.store

© Alex Smirnov 2022