Missed call notification

Status
Not open for further replies.

goose2600

Member
Dec 18, 2018
51
1
8
I would like to send a notification when there is a missed call (ORIGINATOR_CANCEL).

I adapted this lua script: https://freeswitch.org/confluence/plugins/servlet/mobile?contentId=3965148#content/view/7144600
It works from fs_cli, but not from dialpan.

In order to make the scipt to work, I put "hangup_after_bridge=false" and "continue_on_fail=true" in the inbound route, but seems the dialplan does not continue after bridging/transfering the call.

This is the dialplan:
<extension name="123456789" continue="true" uuid="edc20021-9f49-4597-a0c3-dee23fd68ee7">
<condition field="destination_number" expression="^(123456789)$">
<action application="export" data="call_direction=inbound" inline="true"/>
<action application="set" data="domain_uuid=69b7c8b9-9131-44e3-9fbb-590925725125" inline="true"/>
<action application="set" data="domain_name=pbx.local" inline="true"/>
<action application="set" data="hangup_after_bridge=false" inline="true"/>
<action application="set" data="continue_on_fail=true" inline="true"/>
<action application="bridge" data="sofia/internal/20%${sip_profile}"/>
<action application="lua" data="missedcall_notification.lua ${originate_disposition} '${caller_id_number}' '${destination_number}'"/>
</condition>
</extension>

Can someone help me?
 

Adrian Fretwell

Well-Known Member
Aug 13, 2017
1,498
413
83
Not sure exactly what you are trying to achieve but missed call notifications are available from the extension record:

Screenshot from 2021-04-03 10-14-02.png

The same is also available from ring groups.
 

goose2600

Member
Dec 18, 2018
51
1
8
Adrian thanks, I know the email notifications for missed calls exists, but I need to send a webhook to the my home automation system.
The problem is how and were to put in the dialplan the action to execute the lua script.
 
Last edited:

Adrian Fretwell

Well-Known Member
Aug 13, 2017
1,498
413
83
I'm sure you can do this in the dialplan maybe with a combination of lua and hangup callback functions.

It maybe worth your while exploring FreeSWITCH events and event hook scripts. Look at:
https://freeswitch.org/confluence/display/FREESWITCH/Event+List
https://freeswitch.org/confluence/display/FREESWITCH/Event+headers
These events and be hooked with an lua script. you setup your hook script line in /etc/freeswitch/autoload_configs/lua.conf.xml:

Code:
<!-- Example For my Web Hook CHANNEL_HANGUP or CHANNEL_HANGUP_COMPLETE-->
<hook event="CHANNEL_HANGUP_COMPLETE" script="my-web-hook.lua"/>

You can then access the event headers in your lua script using:

Code:
 mycallstate = event:getHeader("Channel-Call-State");

You could always look at doing this on the client side, for example, Yealink phones have a facility called "Action URL" that allows you to fire web hooks based on the phones status, screen shot below:

Screenshot from 2021-04-03 11-25-36.png
 
Last edited:

goose2600

Member
Dec 18, 2018
51
1
8
Helpfus as usual, thank you!
I will try to get the "hangup_cause".

Anyway I would like to understand why the dialplan does not continue after bridging, even setting "hangup_after_bridge=false".
Do I mess something?
 
Last edited:

Adrian Fretwell

Well-Known Member
Aug 13, 2017
1,498
413
83
Anyway I would like to understand why the dialplan does not continue after bridging, even setting "hangup_after_bridge=false".
Do I mess something?
I think the reason is because, in a missed call, it is the A-leg that terminates. If hangup_after_bridge is false (which is the default), then the dialplan will continue after the B-leg terminates.
 

abelitouci

Member
Jul 3, 2019
31
6
8
Houston, Texas
Adrian thanks, I know the email notifications for missed calls exists, but I need to send a webhook to the my home automation system.
The problem is how and were to put in the dialplan the action to execute the lua script.
I have the same problem, different scenario but I'm trying to add a lua or batch script on the dialplan for all my incoming calls to send a push to my restAPI server and don't know how to do it.
I've seen some posts where you can call "action ->system-> /script path" but unfortanetly neither system or bgsystem are available on my dialplan apps and they will not stick.

can anyone please help me with some directions?
Thanks
 

Scubadave112

Member
Jan 24, 2020
122
20
18
37
I wish they would make an Action URL for MWI... I feel like that would be very useful for custom notification
 
Status
Not open for further replies.