Integrating with Telegram Bot
To send messages in your Telegram bot using Reteno, , do the following:
- Create a bot in the @BotFather service, copy the access key, and upload it to Reteno.
- Configure a service on your side that will accept contact tokens from your bot and pass them to Reteno. You can do this in any way that is convenient for you (see the implementation example at the link ).
Access Settings
-
Open @BotFather in Telegram.
-
Send commands
/start
/newbot
-
Follow the instructions to set up the bot.
-
After creating the bot, you will receive an access token. Copy it.
![Copy token](https://files.readme.io/96c8b01-bot_1.webp)
- Go to your Reteno account settings → My bots tab and click Connect Telegram bot.
![Connect Telegram bot](https://files.readme.io/ee66288-bot-en-01.webp)
- Enter the token in the corresponding field and click Save.
![Enter the token](https://files.readme.io/614b973-bot_3.webp)
To integrate the already existing bot:
-
Go to My bots tab and click Connect Telegram bot.
-
Click Connect existing bot.
![Connect existing bot](https://files.readme.io/af2d57e-bot_4.webp)
- Enter the
/mybots
command in the @BotFather chat, select an existing bot from the list, copy its token, add it to the corresponding field, and click Save.
![Existing token](https://files.readme.io/e7aede1-bot_5.webp)
After connecting the bot, you will receive an application ID (app_uuid
) - it must be used in the URL to send a request for adding and updating tokens of your contacts in Reteno: https://reteno.com/api/v1/apps/{app_uuid}/tokens
.
![App ID](https://files.readme.io/2de3cce-bot-en-02.webp)
Note
The number of subscribers of the Telegram bot is shown to the right of the bot's name.
Creating and Updating Contacts
To add or update contact tokens, use the Add application tokens API method (POST type).
JSON request format:
{
"tokens": [Token]
}
Contact data format in the request:
{
"token": string, // required
```
// identifiers to search for contact (at least one is required)
"contactId": Long,
"externalCustomerId": string,
"phone": string,
"email": string
```}
URL to send the request: /v1/apps/{app_uuid}/tokens
A contact is created with all identifiers if there is no contact with such identifiers in the system.
- If the identifiers already exist, they are not created or updated.
- Priority of identifiers for searching contacts in the system: contactId → externalCustomerId → phone → email.
- If the highest priority identifier does not match an existing contact, a contact is created with a new identifier and token.
- If the identifier with the highest priority already exists in eSputnik, the token will be recorded in the contact card, the remaining identifiers will be ignored. Please note that requests using the
Add application tokens
method do not update existing tokens, but only create new ones. For example, if two requests with the same email address contain two different tokens, both will be written to the contact card.
To update other contact information, use the Add/update a contact or Add/update contacts methods.
Message Statuses
SENT, FAILED, and CLICKED statuses are tracked.
A token will be removed from the contact card upon receiving the FAILED (Forbidden) status, which is sent when the user blocks the bot.
Updated 24 days ago