serfreeman1337 / asterlink

Asterisk integration with Bitrix24 and SuiteCRM
MIT License
29 stars 18 forks source link

Filtering incoming calls from FreePBX | Outgoing calls not being triggered #15

Closed EfimSirotkin closed 1 year ago

EfimSirotkin commented 1 year ago

Hi! I'm kind of confused on how to filter specific numbers for incoming calls. I get notifications on every incoming call that is being registered in my incoming context, but I want to be able to limit the numbers that are actually processed by Asterlink. Is there a way to make it work? I've seen the regexp example and tried it a little, but with no success. Thanks in advance!

Also I'm facing another issue right now and also I don't even know how to debug it, because I don't get log entries while performing click to call from Bitrix24 UI. The point is that when I manually perform outgoing call by typing a number I get the record a call uploaded but I'm not able to call from the Bitrix card straight. Can you please give me some hints on resolving that issues? Thanks!

serfreeman1337 commented 1 year ago

Hello. I think you're looking for DID filtering: https://github.com/serfreeman1337/asterlink/blob/23b855a80b41fab22accb722ec48999ac02ed6be/conf.example.yml#L17-L21

I don't get log entries while performing click to call from Bitrix24 UI

Click 2 Call needs webhook setup in bitrix24. See: https://github.com/serfreeman1337/asterlink/blob/master/README_bitrix24.md#call-originations-from-bitrix24

Applications -> Developer resources -> Other -> Outbound webhook To access bitrix24 telephony page simple add /telephony/ to your bitrix24 address (no idea how to get there other way in new version)

Make sure you have set "Default number for outgoing calls " for outbound webhook.

my_endpoint_address:5678 - it's where asterlink is running. If you open it in your browser, it should show "404 page not found".

EfimSirotkin commented 1 year ago

Oh! I'm really happy that you replied to my question, but unfortunately did list doesn't seem to work properly. image I listed 2 numbers. The first one - is the number of a "client" that is performing incoming call. And the second one - is the number of a employee that the call is intended to come to. But even when I call from the third number not mentioned in this list - it actually displays the popup of incoming call anyway.

I've set up everything connected with webhooks, it seems to me that everything is correct. When I try to call Asterlink API manually it logs my try, but when I try to trigger call from Bitrix24 it doesn't log anything.

Maybe the issue is connected with misconfigured dialplan for bitrix24 call originations...

serfreeman1337 commented 1 year ago

image If you really want to filter CallerIDs you can do this:

pbx:
  cid_format:
  - {expr: "^\\+375291234567$", repl: "$0"}
  dial_format:
  - {expr: "^\\+375291234567$", repl: "$0"}

This way only calls from or to +375291234567 will be registred by asterlink.

The second number doesn't look like internal extension number. Does asterisk perform outgoing call to connect employee? Like: Incoming call -> Asterisk -> Outgoing call to other phone and then that call got logged by asterlink so you want to filter it out ?

but when I try to trigger call from Bitrix24 it doesn't log anything

Make sure that handler URL from outbound hook are accessible on the internet (for example, by using curl)

EfimSirotkin commented 1 year ago

Ah, man... The problem with DID was due to incorrect identation.. Fixed it. Now it's working!!! Thanks!

But still. Handler URL is accessible from bitrix server. So these are 3 separate VMs that are located in one local subnet. So they're accessible to each other. Don't know what to do. I've tested using curl and when I do it manually it does work, but Bitrix doesn't perform it.

Maybe the issue it because of incorrect dialplan configuration. Kind of a dummy here. image

serfreeman1337 commented 1 year ago

Handler URL is accessible from bitrix server.

So you have "On-premise" Bitrix24 edition, which runs on the local VM, and from which you successfuly accessed asterlink endpoint.

Note "Events" ![image](https://github.com/serfreeman1337/asterlink/assets/2133936/7e0acc5e-1988-4167-be02-cb8c05d64f05)
Does the dialer show "Application: Outbound webhook" ? ![image](https://github.com/serfreeman1337/asterlink/assets/2133936/7903bc28-0a44-4434-abf8-22acee1c7fbf)

You can also try to use IP instead of hostname.

Maybe the issue it because of incorrect dialplan configuration.

This dialplan is only for routing incoming calls directly to "Responsible person" extension from Bitrix24 Contact.

EfimSirotkin commented 1 year ago

Yeah, everything is quite right, dialer shows "Application: Outbound webhook".. How can I manully trigger an outgoing call with curl from Bitrix. Maybe there is a template for it so I can build my own request and test it to exclude the problem with firewalls between VMs.

EfimSirotkin commented 1 year ago

It seems kind of confusing to me, because I have Yealink telephones connected and registered at FreePBX and I can't imagine how the outgoing call will be triggered that way. Should I have softphone software configured instead?? Also there is a functionality to configure internal telephony in Bitrix24 and connect telephones there via ip.bitrix-xxxx.telephony.com. Should we configure it to make things work?

serfreeman1337 commented 1 year ago

How can I manully trigger an outgoing call with curl from Bitrix.

curl -v --location 'http://newbitfreepbx.rrb.by:56789/originate/' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'auth%5Bapplication_token%5D=APPLICATION_TOKEN' \
--data-urlencode 'data%5BUSER_ID%5D=1' \
--data-urlencode 'data%5BPHONE_NUMBER_INTERNATIONAL%5D=+375291234567' \
--data-urlencode 'data%5BCALL_ID%5D=SOME_RANDOM_VALUE'

Because I have Yealink telephones connected and registered at FreePBX and I can't imagine how the outgoing call will be triggered that way

It was just my guess about your setup, because you said that your employee have a number that looks like a public one.

I listed 2 numbers. The first one - is the number of a "client" that is performing incoming call. And the second one - is the number of a employee that the call is intended to come to.

Oh wait, I get it now. Employee number is the DID and you wanted asterlink to only registers calls for this DID.

Bitrix24 docs say that active license is needed to use outbound hooks.

Other solution suggests to override oauth server (in russian).

EfimSirotkin commented 1 year ago

Yeah, we have progress with manual curl, but it seems that Asterlink can't find extension.. I have no idea what extension should be used and where it should be configured.

image

So the user with ID=1 has internal extension = 4444 and the work_phone +37517xxxxxxx, I'm trying to call to +37529yyyyyy, but it shows me these errors.

P.S. Russian is not a problem :)

EfimSirotkin commented 1 year ago

So the curl format is as follows: image

serfreeman1337 commented 1 year ago

P.S. Russian is not a problem :) Extension does not exists.

Это ответ на Originate от Asterisk. Либо нету внутреннего экстеншена 4444, либо нету исходящего маршрута для номера +375X.. Оба номера набираются в контексте from-internal. Сам номер набирается без проблем с экстеншена 4444, нету ли условия на CallerID в исходящем маршруте ?

EfimSirotkin commented 1 year ago

А outgoing_context тоже тогда должен быть from-internal?

вт, 27 июн. 2023 г., 19:08 serfreeman1337 @.***>:

P.S. Russian is not a problem :) Extension does not exists.

Это ответ на Originate от Asterisk. Либо нету внутреннего экстеншена 4444, либо нету исходящего маршрута для номера +375X.. Оба номера набираются в контексте from-internal https://github.com/serfreeman1337/asterlink/blob/23b855a80b41fab22accb722ec48999ac02ed6be/conf.example.yml#L16 .

— Reply to this email directly, view it on GitHub https://github.com/serfreeman1337/asterlink/issues/15#issuecomment-1609827513, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKWCM6EBOPJ4GGDKUHS3CSTXNMARXANCNFSM6AAAAAAZTJWT2A . You are receiving this because you authored the thread.Message ID: @.***>

serfreeman1337 commented 1 year ago

В outgoing_context регистрируются исходящие вызовы, т.е. там должен быть контекст, через который набирается только транк. from-internal - общий контекст, где набираются еще и внутр. экстеншены.

EfimSirotkin commented 1 year ago

Добрый день! Спасибо за все ответы. А может ли быть такое, что он не находит маршрут для этого extension из-за неверного outgoing_context?

вт, 27 июн. 2023 г., 21:55 serfreeman1337 @.***>:

В outgoing_context регистрируются исходящие вызовы, т.е. там должен быть контекст, через который набирается только транк. from-internal - общий контекст, где набираются еще и внутр. экстеншены.

— Reply to this email directly, view it on GitHub https://github.com/serfreeman1337/asterlink/issues/15#issuecomment-1610054019, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKWCM6AALL6I77TKY7AZBBDXNMUDRANCNFSM6AAAAAAZTJWT2A . You are receiving this because you authored the thread.Message ID: @.***>

EfimSirotkin commented 1 year ago

Исходящий маршрут для этого экстеншена существует и при наборе номера +37529ххх вручную все отлично, однако при попытке сделать это через curl пишет, что extension does not exist. image

serfreeman1337 commented 1 year ago

Можно попробовать убрать 4444 в маршруте для теста. asterisk -rx "dialplan show ext-local" | grep 4444 - тут 4444 же есть ?

EfimSirotkin commented 1 year ago

Да, вывод есть. image

serfreeman1337 commented 1 year ago

dial_context в conf.yml же from-internal ?

Может быть asterisk не пропускает из-за ограничения по 4444 CallerID (4 поле) в исходящем маршруте. Если возможно, можно попробовать временно убрать это ограничение и проверить еще раз. Но у меня на freepbx14 работало и так.

А через консоль asterisk -rvvvvv тоже можно вызвать 4444, например в эхо-тест? channel originate Local/4444@from-internal application Echo

EfimSirotkin commented 1 year ago

Изменил dial_context на from-internal - стал инициировать звонок (по логу видно), но выдает Bad Request по истечении примерно 10 секунд после New Originate request. image Отправляю вот такой запрос, при этом у 4444 id = 1. вроде все ок. image вот что curl отдает в консоль: image

Эхо-тест, кстати, отрабатывает. Звонок приходит

serfreeman1337 commented 1 year ago

Этот 400 Bad Request от битрикса, может быть он ожидает существующий oID. Главное что номер теперь набирается через curl и что проблема была в conf.yml:

Изменил dial_context на from-internal - стал инициировать звонок

Если починить исходящие вебхуки, то набор номера из битрикса должен заработать. Как я понял, в коробочной версии исходящие вебхуки работают через официальный сервер, в ссылке из этого коммента есть информация про это: https://github.com/serfreeman1337/asterlink/issues/15#issuecomment-1609609383

У меня нету коробочной версии и проверить этот момент не могу.

EfimSirotkin commented 1 year ago

Добрый день! Спасибо большое за ответы! Прокинул сервак вовне и заработало через внешку.