Some employees of our company work outside the office: visits to customers, work at home. To communicate with such employees, we use a GSM gateway connected to our PBX Askozia. Any call from the client can be forwarded to the employee “in the field”.
In such conditions, an uncomfortable situation arises: an employee, on an incoming call, sees the SIM card number, not the client number. There is no possibility to promptly call back on a missed call.
We decided to use Telegram to notify about calls. The result was an interesting bundle of Askozia + Telegram + 1C: Enterprise software products.
')
How things work
The employee accesses the service via Telegram. By writing a bot, you can subscribe to notifications.
The greeting format is “
I <Phone number> ”:
The bot saves the phone number, and from that moment knows to which chat to send alerts.
If someone tries to call or forward the call to the employee’s number, messages come to the chat:
Please note information about the caller's name and his phone number is displayed. Submission (name) of the caller can be taken from 1C: CRM, if necessary. In this example, callerid (name) was installed after receiving information from 1C: CRM, an example of the implementation was described by
jorikfon in his article (see the section "useful materials").
Additionally, the “
(call back) ” hyperlink is displayed. The hyperlink initiates a callback to the employee’s mobile number. As soon as the call on the mobile is accepted, the set will start dialing the subscriber whose call was previously received.
An interesting and unexpected feature - the call alert comes faster than a mobile call. Dialing through a GSM line is delayed 4-5 seconds. Notification in Telegram comes much faster.
Service installation on IP PBX Askozia
Telegram API, AMI Asterisk, SOAP web services 1C: Enterprise are used. All services implemented in PHP 5.
Connect to PBX via SSH:
Connect to PBX via SFTP
Download distribution by
reference . Copy scripts from distribution to directory: “
/ storage / usbdisk1 / askoziapbx / astlogs / asterisk / telegram / ”
We continue to work through SSH
Define the settings in the settings.json file
Example settings.json { "ami_host": "127.0.0.1", "ami_port": 5038, "ami_username": "1cami", "ami_secret": "PASSWORD1cami", "telegram_API_key": "171119210:AAHo-000000000000000000000", "subscription_file": "subscription.db", "dst_context": "SIP-PHONE-0000000000feaad021c", "res_callback": "http://HOST:56080/telegram/miko_callback.php", "local_context": "localchannels" }
- “ Ami_host, ami_port, ami_username, ami_secret ” - AMI connection parameters
- “ Telegram_API_key ” - API key telegram bot
- “ Subscription_file ” - the name of the file where alert subscriptions will be stored
- “ Dst_context ” is the context through which destination numbers can be dialed.
- “ Local_context ” - context through which the set of extension numbers is possible
- “ Res_callback ” is the URL where the callback script is published, “HOST” is the address of askozia
How to get AMI connection parameters- ami_host - if the script is run locally, then the address is 127.0.0.1
- ami_port - default value 5038
- ami_username is the default admin
- ami_secret - default askozia
How to get Telegram API keyHe should be asked from “
BotFather ”:
Create a new dialogue with the contact “BotFather” in the telegram
- Send the command "/ newbot"
- In the second step, enter the name of the new bot.
- In the third step, enter the "username" of the bot, it should contain the string "bot"
In response, the bot will send a message with the key
Use this token to access the HTTP API:
171119299:AAHo-y2Ps4-ZTblLRHbjBHG5pG-0cpN
Configuring Contexts- local_context is the context where internal numbers are defined, and our employees' mobiles, by default “localchannels”
- dst_context - to get this context, you need to open one of the accounts of the “Phone” type and in the address bar of the browser copy the type identifier " SIP-PROVIDER-196627525951ab38268552a ", this will be the context
Running scripts in cron
It is necessary to open the “integrator console” by clicking “ESC” in the web interface:
- Click on the " Configuration Files " tab
- Select the " crontabs " file
- Add a line to run the script as in the image above.
*/5 * * * * /bin/sh /storage/usbdisk1/askoziapbx/astlogs/asterisk/telegram/starter.sh
Results of implementation
Employees received a useful service for incoming call alerts:
- Alert arrives before the call
- The employee sees who is calling him.
- When using the "call back" function, the call goes through the PBX, which means the conversation is recorded
Useful materials