Wait for ANSWER/HANGUP events in Mod lua
I am using Mod lua for call processing on the FreeSwitch. I would like to wait for some events such as CHANNEL_ANSWER and CHANNEL_HANGUP in order to get the answer time and hangup time. Basically, something like Wait for event CHANNEL_ANSWER or CHANNEL_HANGUP If (event_name = "CHANNEL_ANSWER") then answer_timestamp = getHeader("Caller-Channel-Answered-Time") If (event_name = "CHANNEL_HANGUP") then hangup_timestamp = getHeader("Event-Date-Timestamp") The session:getState() described in module lua gets the call state but not the channel state. For instance, 'CS_EXECUTE' is the channel state when it is executing a dialplan not when the call is answered. Is there a way to wait for channel events such as CHANNEL_ANSWER and CHANNEL_HANGUP in order to retrieve answer and hangup timestamps for a call? Any input is very much appreciated. Thanks. Sam
Hi Sam, you should be more verbose what you currently doing. There a many ways to call an lua script in FS (in the dialplan, as startup-script, as dialplan-binding etc). Sounds like you want to fetch some kind of billing informations. 2013/8/17 Sami Montour <smontour@verizon.net>
I am using Mod lua for call processing on the FreeSwitch. I would like to wait for some events such as CHANNEL_ANSWER and CHANNEL_HANGUP in order to get the answer time and hangup time. Basically, something like****
** **
Wait for event CHANNEL_ANSWER or CHANNEL_HANGUP****
If (event_name = “CHANNEL_ANSWER”) then answer_timestamp = getHeader(“Caller-Channel-Answered-Time”) ****
If (event_name = “CHANNEL_HANGUP”) then hangup_timestamp = getHeader(“Event-Date-Timestamp”)****
** **
The session:getState() described in module lua gets the call state but not the channel state. For instance, ‘CS_EXECUTE’ is the channel state when it is executing a dialplan not when the call is answered. ****
** **
Is there a way to wait for channel events such as CHANNEL_ANSWER and CHANNEL_HANGUP in order to retrieve answer and hangup timestamps for a call? ****
** **
Any input is very much appreciated.****
** **
Thanks.****
** **
Sam****
** **
-- Mit freundlichen Grüßen *Karsten Horsmann*
Hi Karsten, Thank you for the reply. You are correct. I am trying to retrieve billing information from a basic call. I am calling lua script in the dialplan. When a call comes in, FS hands it over to lua script for processing. <include> <extension> <condition field="destination_number" expression="^(15[0-9][0-9])$"> <action application="lua" data="fs_billing.lua"/> </condition> </extension> </include> I did the same thing with ESL where I listened for CHANNEL_ANSWER and CHANNEL_HANGUP events then fetched answer and hangup times and that worked just fine. I would like to do the same thing with lua. Thanks From: freeswitch-users-bounces@lists.freeswitch.org [mailto:freeswitch-users-bounces@lists.freeswitch.org] On Behalf Of Karsten Horsmann Sent: Sunday, August 18, 2013 10:19 AM To: FreeSWITCH Users Help Subject: Re: [Freeswitch-users] Wait for ANSWER/HANGUP events in Mod lua Hi Sam, you should be more verbose what you currently doing. There a many ways to call an lua script in FS (in the dialplan, as startup-script, as dialplan-binding etc). Sounds like you want to fetch some kind of billing informations. 2013/8/17 Sami Montour <smontour@verizon.net> I am using Mod lua for call processing on the FreeSwitch. I would like to wait for some events such as CHANNEL_ANSWER and CHANNEL_HANGUP in order to get the answer time and hangup time. Basically, something like Wait for event CHANNEL_ANSWER or CHANNEL_HANGUP If (event_name = CHANNEL_ANSWER) then answer_timestamp = getHeader(Caller-Channel-Answered-Time) If (event_name = CHANNEL_HANGUP) then hangup_timestamp = getHeader(Event-Date-Timestamp) The session:getState() described in module lua gets the call state but not the channel state. For instance, CS_EXECUTE is the channel state when it is executing a dialplan not when the call is answered. Is there a way to wait for channel events such as CHANNEL_ANSWER and CHANNEL_HANGUP in order to retrieve answer and hangup timestamps for a call? Any input is very much appreciated. Thanks. Sam -- Mit freundlichen Grüßen *Karsten Horsmann*
Hi Sam, as Ken wrote. That maybe not a good idea to fetch billing informations with lua. And i am not sure, if you call the lua-script within the dialplan - if it lives anymore at hangup to do something. May some of the freeswitch-jedis knows that. Cheers. 2013/8/18 Sami Montour <smontour@verizon.net>
Hi Karsten,****
Thank you for the reply. You are correct. I am trying to retrieve billing information from a basic call. I am calling lua script in the dialplan. When a call comes in, FS hands it over to lua script for processing.****
** **
<include>****
<extension>****
<condition field="destination_number" expression="^(15[0-9][0-9])$">****
<action application="lua" data="fs_billing.lua"/>****
</condition>****
</extension>****
</include>****
** **
I did the same thing with ESL where I listened for CHANNEL_ANSWER and CHANNEL_HANGUP events then fetched answer and hangup times and that worked just fine. I would like to do the same thing with lua. ****
** **
Thanks****
** **
-- Mit freundlichen Grüßen *Karsten Horsmann*
billing in lua is asking for issues... why not do something like triggiering the billing from the xml cdr or such this avoids loss od cdrs as it uses the filesystem as a backup to incase your websvices or billing processor is down Ken Sent from my iPad On Aug 18, 2013, at 10:19, Karsten Horsmann <khorsmann@gmail.com> wrote:
Hi Sam,
you should be more verbose what you currently doing. There a many ways to call an lua script in FS (in the dialplan, as startup-script, as dialplan-binding etc).
Sounds like you want to fetch some kind of billing informations.
2013/8/17 Sami Montour <smontour@verizon.net>
I am using Mod lua for call processing on the FreeSwitch. I would like to wait for some events such as CHANNEL_ANSWER and CHANNEL_HANGUP in order to get the answer time and hangup time. Basically, something like
Wait for event CHANNEL_ANSWER or CHANNEL_HANGUP
If (event_name = “CHANNEL_ANSWER”) then answer_timestamp = getHeader(“Caller-Channel-Answered-Time”)
If (event_name = “CHANNEL_HANGUP”) then hangup_timestamp = getHeader(“Event-Date-Timestamp”)
The session:getState() described in module lua gets the call state but not the channel state. For instance, ‘CS_EXECUTE’ is the channel state when it is executing a dialplan not when the call is answered.
Is there a way to wait for channel events such as CHANNEL_ANSWER and CHANNEL_HANGUP in order to retrieve answer and hangup timestamps for a call?
Any input is very much appreciated.
Thanks.
Sam
-- Mit freundlichen Grüßen *Karsten Horsmann* _________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org http://www.freeswitchsolutions.com
FreeSWITCH-powered IP PBX: The CudaTel Communication Server http://www.cudatel.com
Official FreeSWITCH Sites http://www.freeswitch.org http://wiki.freeswitch.org http://www.cluecon.com
FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
The billing I would like to use with lua is for real-time billing where subscribers are debited real-time or at the end of the call. From: freeswitch-users-bounces@lists.freeswitch.org [mailto:freeswitch-users-bounces@lists.freeswitch.org] On Behalf Of Ken Rice Sent: Sunday, August 18, 2013 10:55 AM To: FreeSWITCH Users Help Subject: Re: [Freeswitch-users] Wait for ANSWER/HANGUP events in Mod lua billing in lua is asking for issues... why not do something like triggiering the billing from the xml cdr or such this avoids loss od cdrs as it uses the filesystem as a backup to incase your websvices or billing processor is down Ken Sent from my iPad On Aug 18, 2013, at 10:19, Karsten Horsmann <khorsmann@gmail.com> wrote: Hi Sam, you should be more verbose what you currently doing. There a many ways to call an lua script in FS (in the dialplan, as startup-script, as dialplan-binding etc). Sounds like you want to fetch some kind of billing informations. 2013/8/17 Sami Montour <smontour@verizon.net> I am using Mod lua for call processing on the FreeSwitch. I would like to wait for some events such as CHANNEL_ANSWER and CHANNEL_HANGUP in order to get the answer time and hangup time. Basically, something like Wait for event CHANNEL_ANSWER or CHANNEL_HANGUP If (event_name = “CHANNEL_ANSWER”) then answer_timestamp = getHeader(“Caller-Channel-Answered-Time”) If (event_name = “CHANNEL_HANGUP”) then hangup_timestamp = getHeader(“Event-Date-Timestamp”) The session:getState() described in module lua gets the call state but not the channel state. For instance, ‘CS_EXECUTE’ is the channel state when it is executing a dialplan not when the call is answered. Is there a way to wait for channel events such as CHANNEL_ANSWER and CHANNEL_HANGUP in order to retrieve answer and hangup timestamps for a call? Any input is very much appreciated. Thanks. Sam -- Mit freundlichen Grüßen *Karsten Horsmann* _________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org http://www.freeswitchsolutions.com FreeSWITCH-powered IP PBX: The CudaTel Communication Server http://www.cudatel.com Official FreeSWITCH Sites http://www.freeswitch.org http://wiki.freeswitch.org http://www.cluecon.com FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
Look at mod_nibblebill. It already does what you want and perfectly handles concurrent calls from the same subscriber. On Sunday 18 August 2013 11:15:04 Sami Montour wrote:
The billing I would like to use with lua is for real-time billing where subscribers are debited real-time or at the end of the call.
From: freeswitch-users-bounces@lists.freeswitch.org [mailto:freeswitch-users-bounces@lists.freeswitch.org] On Behalf Of Ken Rice Sent: Sunday, August 18, 2013 10:55 AM To: FreeSWITCH Users Help Subject: Re: [Freeswitch-users] Wait for ANSWER/HANGUP events in Mod lua
billing in lua is asking for issues... why not do something like triggiering the billing from the xml cdr or such this avoids loss od cdrs as it uses the filesystem as a backup to incase your websvices or billing processor is down
Ken
Sent from my iPad
On Aug 18, 2013, at 10:19, Karsten Horsmann <khorsmann@gmail.com> wrote:
Hi Sam,
you should be more verbose what you currently doing. There a many ways to call an lua script in FS (in the dialplan, as startup-script, as dialplan-binding etc).
Sounds like you want to fetch some kind of billing informations.
2013/8/17 Sami Montour <smontour@verizon.net>
I am using Mod lua for call processing on the FreeSwitch. I would like to wait for some events such as CHANNEL_ANSWER and CHANNEL_HANGUP in order to get the answer time and hangup time. Basically, something like
Wait for event CHANNEL_ANSWER or CHANNEL_HANGUP
If (event_name = “CHANNEL_ANSWER”) then answer_timestamp = getHeader(“Caller-Channel-Answered-Time”)
If (event_name = “CHANNEL_HANGUP”) then hangup_timestamp = getHeader(“Event-Date-Timestamp”)
The session:getState() described in module lua gets the call state but not the channel state. For instance, ‘CS_EXECUTE’ is the channel state when it is executing a dialplan not when the call is answered.
Is there a way to wait for channel events such as CHANNEL_ANSWER and CHANNEL_HANGUP in order to retrieve answer and hangup timestamps for a call?
Any input is very much appreciated.
Thanks.
Sam
realtime billing can be accomplished with nibble whichs deducts as the call is in progress... folowed up with bill validation via the cdr. if your lua script crashes no billing... Ken Sent from my iPad On Aug 18, 2013, at 11:15, "Sami Montour" <smontour@verizon.net> wrote:
The billing I would like to use with lua is for real-time billing where subscribers are debited real-time or at the end of the call.
From: freeswitch-users-bounces@lists.freeswitch.org [mailto:freeswitch-users-bounces@lists.freeswitch.org] On Behalf Of Ken Rice Sent: Sunday, August 18, 2013 10:55 AM To: FreeSWITCH Users Help Subject: Re: [Freeswitch-users] Wait for ANSWER/HANGUP events in Mod lua
billing in lua is asking for issues... why not do something like triggiering the billing from the xml cdr or such this avoids loss od cdrs as it uses the filesystem as a backup to incase your websvices or billing processor is down
Ken Sent from my iPad
On Aug 18, 2013, at 10:19, Karsten Horsmann <khorsmann@gmail.com> wrote:
Hi Sam,
you should be more verbose what you currently doing. There a many ways to call an lua script in FS (in the dialplan, as startup-script, as dialplan-binding etc).
Sounds like you want to fetch some kind of billing informations.
2013/8/17 Sami Montour <smontour@verizon.net> I am using Mod lua for call processing on the FreeSwitch. I would like to wait for some events such as CHANNEL_ANSWER and CHANNEL_HANGUP in order to get the answer time and hangup time. Basically, something like
Wait for event CHANNEL_ANSWER or CHANNEL_HANGUP If (event_name = “CHANNEL_ANSWER”) then answer_timestamp = getHeader(“Caller-Channel-Answered-Time”) If (event_name = “CHANNEL_HANGUP”) then hangup_timestamp = getHeader(“Event-Date-Timestamp”)
The session:getState() described in module lua gets the call state but not the channel state. For instance, ‘CS_EXECUTE’ is the channel state when it is executing a dialplan not when the call is answered.
Is there a way to wait for channel events such as CHANNEL_ANSWER and CHANNEL_HANGUP in order to retrieve answer and hangup timestamps for a call?
Any input is very much appreciated.
Thanks.
Sam
-- Mit freundlichen Grüßen *Karsten Horsmann* _________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org http://www.freeswitchsolutions.com
FreeSWITCH-powered IP PBX: The CudaTel Communication Server http://www.cudatel.com
Official FreeSWITCH Sites http://www.freeswitch.org http://wiki.freeswitch.org http://www.cluecon.com
FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org _________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org http://www.freeswitchsolutions.com
FreeSWITCH-powered IP PBX: The CudaTel Communication Server http://www.cudatel.com
Official FreeSWITCH Sites http://www.freeswitch.org http://wiki.freeswitch.org http://www.cluecon.com
FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
Thank you guys for your input. I will look into nibble bill module and try it. It seems the module is designed for real-time billing. From: freeswitch-users-bounces@lists.freeswitch.org [mailto:freeswitch-users-bounces@lists.freeswitch.org] On Behalf Of Ken Rice Sent: Sunday, August 18, 2013 11:29 AM To: FreeSWITCH Users Help Cc: FreeSWITCH Users Help Subject: Re: [Freeswitch-users] Wait for ANSWER/HANGUP events in Mod lua realtime billing can be accomplished with nibble whichs deducts as the call is in progress... folowed up with bill validation via the cdr. if your lua script crashes no billing... Ken Sent from my iPad On Aug 18, 2013, at 11:15, "Sami Montour" <smontour@verizon.net> wrote: The billing I would like to use with lua is for real-time billing where subscribers are debited real-time or at the end of the call. From: freeswitch-users-bounces@lists.freeswitch.org [mailto:freeswitch-users-bounces@lists.freeswitch.org] On Behalf Of Ken Rice Sent: Sunday, August 18, 2013 10:55 AM To: FreeSWITCH Users Help Subject: Re: [Freeswitch-users] Wait for ANSWER/HANGUP events in Mod lua billing in lua is asking for issues... why not do something like triggiering the billing from the xml cdr or such this avoids loss od cdrs as it uses the filesystem as a backup to incase your websvices or billing processor is down Ken Sent from my iPad On Aug 18, 2013, at 10:19, Karsten Horsmann <khorsmann@gmail.com> wrote: Hi Sam, you should be more verbose what you currently doing. There a many ways to call an lua script in FS (in the dialplan, as startup-script, as dialplan-binding etc). Sounds like you want to fetch some kind of billing informations. 2013/8/17 Sami Montour <smontour@verizon.net> I am using Mod lua for call processing on the FreeSwitch. I would like to wait for some events such as CHANNEL_ANSWER and CHANNEL_HANGUP in order to get the answer time and hangup time. Basically, something like Wait for event CHANNEL_ANSWER or CHANNEL_HANGUP If (event_name = “CHANNEL_ANSWER”) then answer_timestamp = getHeader(“Caller-Channel-Answered-Time”) If (event_name = “CHANNEL_HANGUP”) then hangup_timestamp = getHeader(“Event-Date-Timestamp”) The session:getState() described in module lua gets the call state but not the channel state. For instance, ‘CS_EXECUTE’ is the channel state when it is executing a dialplan not when the call is answered. Is there a way to wait for channel events such as CHANNEL_ANSWER and CHANNEL_HANGUP in order to retrieve answer and hangup timestamps for a call? Any input is very much appreciated. Thanks. Sam -- Mit freundlichen Grüßen *Karsten Horsmann* _________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org http://www.freeswitchsolutions.com FreeSWITCH-powered IP PBX: The CudaTel Communication Server http://www.cudatel.com Official FreeSWITCH Sites http://www.freeswitch.org http://wiki.freeswitch.org http://www.cluecon.com FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org _________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org http://www.freeswitchsolutions.com FreeSWITCH-powered IP PBX: The CudaTel Communication Server http://www.cudatel.com Official FreeSWITCH Sites http://www.freeswitch.org http://wiki.freeswitch.org http://www.cluecon.com FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
participants (4)
-
Karsten Horsmann
-
Ken Rice
-
Sami Montour
-
Sergey Okhapkin