Notifications via Telegram allow you to send clients information about crediting a payment, opening a service, answering a request, etc. Read more in Notification types.

This article describes how to connect and configure BILLmanager client notifications via a Telegram bot.

Configuration on Telegram side

Create a Telegram bot. To do this:

  1. Follow the link or use the search in Telegram to find @BotFather.
  2. Start the bot with the /start command.
  3. Create your own bot with the /newbot command. Create the name for the bot and its user.
  4. Save the bot name and token from the last message.

Configuration on BILLmanager side

Message gateway

Enter IntegrationMail gatewaysAdd button:

  1. Select Telegram.
  2. Select the Provider to which Telegram notifications will be linked.
  3. Notification types — select the types of notifications that will be sent through this gateway. If no sending gateway is configured for the notification, it will be sent through the first gateway suitable in terms of sending method.

    Example 1. Two gateways are configured in BILLmanager to send notifications. In the settings of the first gateway, the types "Send invoice" and "Provider message" are selected for sending. Nothing is selected in the "Notification types" field in the second gateway settings. All types of notifications will pass through the second gateway except those specified in the settings of the first gateway.

    Example 2. Two gateways with id 10 and 15 are configured in BILLmanager to send notifications. The same notification types are selected for both gateways. Notifications will be sent through a gateway with a smaller id - 10. If messages have not been sent through the gateway with id 10 for some reason, the gateway with id 15 will not send those messages.

  4. Enable the Activate after creation option.
  5. Enter the Bot name in Telegram.
  6. Specify the Token you saved when creating the bot.
  7. Enter an address of the form {BILLmanagerURL}/mancgi/telegram_webhook in the Link for Webhook field to receive confirmations from Telegram. Telegram will send webhooks to this address indicating that the client and the bot are connected. You can leave the field blank. In this case, the address of the server with BILLmanager will be used.
  8. Select message Layout from the Telegram bot:
    • HTML;
    • Markdown;
    • MarkdownV2.
  9. Press Finish.

Message templates

Set up message templates for Telegram notifications:

  1. Enter SettingsMessage templatesMessages for messengers.
  2. Fill in the required templates using the markup you selected in the settings. By default, the templates are not filled in. You can use the same variables to create messages as you do to create email notifications.

Example of a payment receipt notice

<% function EscapeForMarkdown(data) { %>
    <% if (!data || data == '') { return; }%>
    <% return data.replace(/[_*[\]()~'>#+\-=|{}.!\\]/g, "\\$&") %>
<% } %>
*Your payment has been credited*
Hello, *_<%= EscapeForMarkdown(user.realname) %>_*\!
This is to inform you that payment has been credited to account No *<%= payment.number %>* in the amount of *<%= EscapeForMarkdown(payment.paymethodamount) %> <%= payment.currency.iso %>*\.
Your current account balance is *<%= EscapeForMarkdown(subaccount.balance) %> <%= currency.iso %>*\.


Log of interaction between Telegram and the billing platform is recorded in file /usr/local/mgr5/var/gwtelegram.log.

Connecting Telegram notifications on the client side

The client can choose one or more notification channels in the client area. To receive notifications via Telegram, the client needs to take the following actions:

  1. In the Client area, go to the Profile settings → Notifications settings menu.
  2. Enable the required notifications in the messenger column.
  3. In the Telegram field, enter his/her Telegram username without @.
  4. Press Save.
  5. Go to Telegram and write to the bot. After that, BILLmanager connects the bot and the user, and the client can receive all the necessary notifications in the messenger.