BILLmanager 5 Documentation

Setting up notifications via Telegram

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 https://t.me/BotFather 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

  1. Enter IntegrationMail gatewaysAdd button.
  2. Select Telegram.
  3. Select the Provider to which Telegram notifications will be linked.
  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 %>*\.

Logging

Log of interaction between Telegram and the billing system 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.

    Note:
    In BILLmanager 6 interface, to find out the name of the bot, the client needs to look at the tooltip next to the Telegram field.