It happens that a call from an office PBX comes to mobile. And skipped on it too.
The reasons for this are different for everyone, but the consequences are the same - you look at the city office number and think, and who called it?
On Habré, this topic has already been discussed more than once. Notifications were sent both to the post office and via SMS, lately it is fashionable to do this with telegram bots, however I will use Bitrix24.
')
Why him? Welcome under the cut!
Actually, everything is quite simple - push-notifications on phones are attractively convenient and I want to use something that delivers the minimum of trouble with constant use.
Why not Telegram? It's just that it only implements a general chat, and I would like some pleasant privacy.
Why not SMS? Leaving the non-free issue behind the brackets, I’ll say that I don’t want to create service points when hiring or firing an employee. I want to disable it in AD and everything, he does not have more corporate services.
Why not mail (as it is on the previous item is quite suitable)? Because employees suddenly do not use it on their phones (well, we have a lot of them anyway).
In general, according to the results of doubts and meditations, we decided to stop at the corporate portal based on Beatrix. Much can be said about him (and not always good), but we have it and the employees use it.
In addition, it is integrated with AD and the data of all employees are recorded in it (including internal phones, this is important).
In general, to the point!
Warning: the
code below can cause you moral injury. Immediately agree that he is terrible, after all, I am not a coder .
To begin with, we will build a receiver from the side of the portal, to which notifications will arrive and which will send them to IM:
send_from_pbx.php<? require($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_before.php"); if (!(count($_POST) == 2) || !CModule::IncludeModule('iblock') || !CModule::IncludeModule('im')) { die('error'); } $dbr = CUser::GetList(($by="ID"), ($order="ACS"), ["UF_PHONE_INNER" => intval($_POST["number"])]); while ($user = $dbr->Fetch()) { CIMMessenger::Add(array( "MESSAGE_TYPE" => "P",
note: everything is pretty simple here. First, we pull the database, receiving the correspondence “internal number - user ID in the bitrix”, then send the message from the account specially created for Asterisk. In principle, you can send and on behalf of the system, a matter of taste.
Now, on the server of Asterisk we will lay out a small script:
It's still easier here. Log in using curl, and then send the same POST message and phone number.
Well and finally we rule extensions.conf in Asterisk. In a macro that translates calls to a mobile in case the main phone is unavailable, we add exactly one line calling the script that we just wrote (I will give the whole macro here just in case):
[macro-mobile] exten => s,1,Set(CDR(userfield)=LOCAL) exten => s,n,ExecIf($[${LEN(${CALLERID(num)})}=3]?Set(name=${SHELL( mysql asterisk -uasterisk -pperasperaadastra -sse 'SELECT callerid FROM peers WHERE defaultuser=${CALLERID(num)}' )$ exten => s,n,Macro(record,local) exten => s,n,Dial(SIP/${MACRO_EXTEN},20) exten => s,n,Dial(SIP/tel_out/${ARG1}) exten => s,n,System(/srv/asterisk/send2bitrix/send.sh "${name} ( ${CALLERID(num)})" ${EXTEN})
in the dial plan, this macro is used as follows:
exten => 100,1,Macro(mobile,79251122333)
It's still pretty obvious here. The macro forcibly places CallerID from the database, starts recording conversations, tries to call the main phone, then to the mobile and, having a fiasco, calls our script notifying the user about who called him and when.
That's all. Thanks for attention!
If you want to clarify something, to speak, and even more so to give good advice - write.