Integration with Telegram¶
- Table of contents
- Integration with Telegram
Smartswitch could be intergated with Telegram for notification sending and interactive reports generation.
For this purpose, the Telegram's system of chats and bots is used.
The sequence of actions to setup the integration:
- Create a bot using Telegram means (see How to create a Telegram bot).
Record its token. - In Smartswitch's web-interface add Telegram bot and specify its token, which you got in i.1.
- Create chat using Telegram means.
Add a bot which was created in i.1. - Obtain chat's ID by sending the /start command into the group chat.
- Bot, which was added in i.1, will answer:
ChatID: -1002388910615
- in the Smartswitch UI add a new Telegram chat and set its ID to value obtained in i.5.
After this Smartswitch can:
Send notifications on behalf of this bot to chosen chat.¶
Currently Smartswitch can send the following notifications:
- loss (see Loss control).
This can be useful, if you don't use Profit control, to route only profitable calls.
Therefore, calls with losses might be routed through Smartswitch.
Loss control can limit a maximum loss for the time interval, by blocking a traffic, which exceeds loss limits.
In such moments notifications could be sent to Telegram chat, in order for administrator to be able to react to this situation.
To activate this feature, you need to specify Telegram chat for Loss controller, to which notifications will be directed,
and Telegram bot, on behalf of which to send notifications. - balance threshold exceeded (see Balance threshold control)
This can be useful for notifying clients that their balance is approaching the value beyond which they will be blocked.
Get commands from users and display report interactively.¶
Currently Smartswitch understands the following commands:
- /balance
Displays the current balance of the selected Company or User. - /profit"
When user enters this command in the Telegram chat, bot prompts to choose a peer.
After peer has been chosen, bot promts to choose time interval, for which to generate report.
After time interval has been chosen, bot displays profit and margin, grouped by E.164 code.
To activate this feature, you need to specify a list of available peers for Telegram chat. - /status
Displays the profit for the selected Company or User for the selected time interval. - /start
Notifies the bot that it is allowed to send notifications (see above) to this chat. - /stop
Notifies the bot that it is not allowed to send notifications (see above) to this chat.
Notice: As far as you are configuring both on Telegram and Smartswitch side,
you can be sure, that you're granting the access rights to appropriate users.
Nobody from foreign users or chats won't be able to get your confidential information.
Smartswitch sends notifications and responds to commands only to authorized chats.