[Freeswitch-users] how can i keep A-LEG do not hangup (Luis Daniel Lucio Quiroz)

ax lyb ax.lyb.lei at gmail.com
Fri Jan 16 05:19:06 MSK 2015


hi, brian,Andrew

     i known a little in lua,i do my customer callcenter in the following style:

   1.  create a inbound connect to see what channel hangup
        (BaseFreeswitchClient is a socket-connection wrap)

        int connectFS()
    {
        //"auth ClueCon\n\n";
        const char* AUTH_ME="ClueCon";
        m_pFsClient = new BaseFreeswitchClient(reinterpret_cast<IChannelDataCallback*>(this));
        if(m_pFsClient->ConnectFS(AUTH_ME) < 0 )
        {
            delete m_pFsClient;
            m_pFsClient = NULL;
            return -1;
        }
        
        //		const char* strFilter = "event plain CHANNEL_CREATE \
        //								 CHANNEL_ANSWER \
        //								 CHANNEL_BRIDGE \
        //								 CHANNEL_HANGUP \
        //								 CHANNEL_HANGUP_COMPLETE\n\n";
        const char* strFilter = "event plain CHANNEL_HANGUP_COMPLETE\n\n";
        
        if( m_pFsClient->filterEvent(strFilter) < 0 )
        {
            delete m_pFsClient ;
            m_pFsClient = NULL;
            return -1;
        }
        return 0;
    }

   2. create a server for outbound connect, the outbound connect for every call-session to FILTER 
      CHANNEL_ANSWER,CHANNEL_HANGUP_COMPLETE,CHANNEL_EXECUTE_COMPLETE

      case ESL_EVENT_CHANNEL_DATA:
        {
            const char* strEvtName = evt.getHeader("Event-Name");
           
            char szFilter[1024];
            const char* strFilter = "event plain CHANNEL_ANSWER CHANNEL_BRIDGE CHANNEL_EXECUTE_COMPLETE DTMF\n\n";
            snprintf(szFilter, sizeof(szFilter),"%sfilter Unique-ID %s\n\n",strFilter,
                     evt.getHeader("Caller-Unique-ID"));
            int nWriteSize = strnlen(szFilter,sizeof(szFilter));
            LOG(LS_ERROR)<<strEvtName << "," <<evt.getHeader( "Caller-Unique-ID")
                <<",nWriteSize="<<nWriteSize <<","<<szFilter;
            p->onWrite(szFilter,  nWriteSize);
        }

      3. set "session.SetAutoHangup(false);”, which channel_variable should i set?


   thanks 


> 在 2015年1月16日,08:18,freeswitch-users-request at lists.freeswitch.org 写道:
> 
> Send FreeSWITCH-users mailing list submissions to
> 	freeswitch-users at lists.freeswitch.org
> 
> To subscribe or unsubscribe via the World Wide Web, visit
> 	http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
> or, via email, send a message with subject or body 'help' to
> 	freeswitch-users-request at lists.freeswitch.org
> 
> You can reach the person managing the list at
> 	freeswitch-users-owner at lists.freeswitch.org
> 
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of FreeSWITCH-users digest..."
> Today's Topics:
> 
>   1. Re: Help Needed Debugging Lua Script (Luis Daniel Lucio Quiroz)
>   2. Re: how can i keep A-LEG do not hangup (Luis Daniel Lucio Quiroz)
> 
> 发件人: Luis Daniel Lucio Quiroz <luis.daniel.lucio at gmail.com>
> 收件人: FreeSWITCH Users Help <freeswitch-users at lists.freeswitch.org>
> 日期: 2015年1月16日 GMT+808:13:15
> 回复-收件人: FreeSWITCH Users Help <freeswitch-users at lists.freeswitch.org>
> 主题: 回复: [Freeswitch-users] Help Needed Debugging Lua Script
> 
> 
> Don't loose your time, contact me offline
> 
> On Jan 15, 2015 5:49 PM, "Sina Owolabi" <notify.sina at gmail.com <mailto:notify.sina at gmail.com>> wrote:
> Hi List,
> 
> I think I have finally come up with something that works, the script captures the details correctly, but I wonder if there is a better way to write it? I am trying to get it to call the dialer back and play a message, which it does correctly.
> Please what can I do to make it to retry the dialler's number in case the call doesn't go through the first (say) two times, just in case the dialler cut it off mistakenly, or the telco plays a repeated message after freeswitch hung up, preventing the callback from coming through? (I've seen this happen a few times with a local telco). Thanks!
> 
> number_to_call = argv[1];
> caller_id = argv[2];
> api = freeswitch.API();
> dialString = "{origination_caller_id_name="..caller_id..",origination_caller_id_number="..caller_id.."}sofia/gateway/sipgw/"..number_to_call.."";
> session1 = freeswitch.Session(dialString);
> session1:sleep(5000);
> 
> if (session1:ready()) then
>         session1:sleep(35000);
>         api:execute("bgapi originate", "session1");
>         session1:sleep(3000);
>         session1:streamFile('/tmp/stop_calling_me_stalker.wav');
>         session1:hangup("NORMAL_CLEARING");
> end
> 
> 
> On Wed Jan 07 2015 at 2:45:04 PM Avi Marcus <avi at avimarcus.net <mailto:avi at avimarcus.net>> wrote:
> Two things:
> 1) You aren't grabbing the arg, but the channel variable.. try this in your script:
> caller_id_number = argv[1]
> number_to_call = argv[2]
> 
> 2) I don't think you're managing your hangup/callback originate properly.
> I don't think you want to use bgapi... or maybe you just need a destination. It's "originate <http://wiki.freeswitch.org/wiki/Mod_commands#originate> sofia/A endpoint" -- you need to specify where it goes to, the lua script can't "receive" the call. You can have it received by e.g: &lua(pickup.lua)
> 
> api = freeswitch.API()
> api:execute("originate", DialString.." &lua(pickup.lua)");
> 
> Also:
> Maybe you want to use it as a hangup hook. Instead of:
> <action application="lua" data="callback.lua ${effective_caller_id_number} ${destination_number}"/>
> Do:
> <action application="set" data="api_hangup_hook=lua callback.lua ${effective_caller_id_number} ${destination_number}"/>
> <action application="hangup" data="486"/>
> 
> -Avi 
> 
> On Wed, Jan 7, 2015 at 1:52 AM, Sina Owolabi <notify.sina at gmail.com <mailto:notify.sina at gmail.com>> wrote:
> Hi List,
> 
> FreeSWITCH newbie here again.
> I am trying to cobble togther a lua callback script, my first attempt
> was successful, but I am trying to make it slightly more elegant.
> I don't see any errors when I try to run this but the callback isnt happening.
> This is my very second attempt trying to write in lua, so I would be
> very grateful for any help.
> 
> The user is expected to dial in, have the call hangup and FreeSWITCH call back.
> 
> I'm passing a modified $effective_caller_id_number and
> $destination_number to the lua script:
> 
> <extension name="callyouback">
>     <condition field="${caller_id_number}"
> expression="^1(\d{10})$"require-nested="false">
>        <action application="set" data="effective_caller_id_number=+234${1}"/>
>        <action application="set" data="effective_caller_id_name=+234${1}"/>
>     </condition>
>     <condition field="destination_number" expression="^012345(6)(7)$">
>       <action application="set" data="destination_number=+12312345${1}${2}" />
>       <action application="lua" data="callback.lua
> ${effective_caller_id_number} ${destination_number}"/>
>       <action application="gentones" data="%(3000,0,430,450,550)"/>
>       <action application="hangup" data="NORMAL_CLEARING"/>
>      </condition>
> 
> 
> The script itself:
> 
> api = freeswitch.API();
> call_string = "bagpi originate
> {origination_caller_id_name="..caller_id_name..",origination_caller_id_number="..caller_id_number.."}sofia/gateway/mysipgate/"..number_to_call..""
> 
> freeswitch.msleep(5000);
> if (session:ready()) then
>         caller_id_number = session:getVariable("destination_number");
>         caller_id_name = session:getVariable("destination_number");
>         number_to_call = session:getVariable("effective_caller_id_number");
> 
>         api:executeString(call_string);
>         freeswitch.msleep(2000);
>         session:streamFile("/tmp/get_off_my_lawn.wav");
>         session:hangup("NORMAL_CLEARING");
> end
> 
> _________________________________________________________________________
> Professional FreeSWITCH Consulting Services:
> consulting at freeswitch.org <mailto:consulting at freeswitch.org>
> http://www.freeswitchsolutions.com <http://www.freeswitchsolutions.com/>
> 
> Official FreeSWITCH Sites
> http://www.freeswitch.org <http://www.freeswitch.org/>
> http://confluence.freeswitch.org <http://confluence.freeswitch.org/>
> http://www.cluecon.com <http://www.cluecon.com/>
> 
> FreeSWITCH-users mailing list
> FreeSWITCH-users at lists.freeswitch.org <mailto:FreeSWITCH-users at lists.freeswitch.org>
> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users <http://lists.freeswitch.org/mailman/listinfo/freeswitch-users>
> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users <http://lists.freeswitch.org/mailman/options/freeswitch-users>
> http://www.freeswitch.org <http://www.freeswitch.org/>
> 
> _________________________________________________________________________
> Professional FreeSWITCH Consulting Services:
> consulting at freeswitch.org <mailto:consulting at freeswitch.org>
> http://www.freeswitchsolutions.com <http://www.freeswitchsolutions.com/>
> 
> Official FreeSWITCH Sites
> http://www.freeswitch.org <http://www.freeswitch.org/>
> http://confluence.freeswitch.org <http://confluence.freeswitch.org/>
> http://www.cluecon.com <http://www.cluecon.com/>
> 
> FreeSWITCH-users mailing list
> FreeSWITCH-users at lists.freeswitch.org <mailto:FreeSWITCH-users at lists.freeswitch.org>
> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users <http://lists.freeswitch.org/mailman/listinfo/freeswitch-users>
> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users <http://lists.freeswitch.org/mailman/options/freeswitch-users>
> http://www.freeswitch.org <http://www.freeswitch.org/>
> _________________________________________________________________________
> Professional FreeSWITCH Consulting Services:
> consulting at freeswitch.org <mailto:consulting at freeswitch.org>
> http://www.freeswitchsolutions.com <http://www.freeswitchsolutions.com/>
> 
> Official FreeSWITCH Sites
> http://www.freeswitch.org <http://www.freeswitch.org/>
> http://confluence.freeswitch.org <http://confluence.freeswitch.org/>
> http://www.cluecon.com <http://www.cluecon.com/>
> 
> FreeSWITCH-users mailing list
> FreeSWITCH-users at lists.freeswitch.org <mailto:FreeSWITCH-users at lists.freeswitch.org>
> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users <http://lists.freeswitch.org/mailman/listinfo/freeswitch-users>
> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users <http://lists.freeswitch.org/mailman/options/freeswitch-users>
> http://www.freeswitch.org <http://www.freeswitch.org/>
> 
> 
> 
> 发件人: Luis Daniel Lucio Quiroz <luis.daniel.lucio at gmail.com>
> 收件人: FreeSWITCH Users Help <freeswitch-users at lists.freeswitch.org>
> 日期: 2015年1月16日 GMT+808:18:10
> 回复-收件人: FreeSWITCH Users Help <freeswitch-users at lists.freeswitch.org>
> 主题: 回复: [Freeswitch-users] how can i keep A-LEG do not hangup
> 
> 
> Read about queues
> 
> On Jan 15, 2015 11:53 AM, "Brian West" <brian at freeswitch.org <mailto:brian at freeswitch.org>> wrote:
> Thats not relevant in this case, The autoHangup is when used in say lua...
> 
> This case you will probably want this combo:
> 
> https://freeswitch.org/confluence/display/FREESWITCH/mod_event_socket#mod_event_socket-linger <https://freeswitch.org/confluence/display/FREESWITCH/mod_event_socket#mod_event_socket-linger>
> https://wiki.freeswitch.org/wiki/Variable_park_after_bridge <https://wiki.freeswitch.org/wiki/Variable_park_after_bridge>
> 
> 
> 
> 
> On Thu, Jan 15, 2015 at 7:27 AM, Andrew <aademattia at comcast.net <mailto:aademattia at comcast.net>> wrote:
> This may be able to help you but I set session.SetAutoHangup(false);
> 
> This will stop the dial plan from ending.
> 
>   <>
> From: freeswitch-users-bounces at lists.freeswitch.org <mailto:freeswitch-users-bounces at lists.freeswitch.org> [mailto:freeswitch-users-bounces at lists.freeswitch.org <mailto:freeswitch-users-bounces at lists.freeswitch.org>] On Behalf Of ax lyb
> Sent: Thursday, January 15, 2015 2:52 AM
> To: freeswitch-users at lists.freeswitch.org <mailto:freeswitch-users at lists.freeswitch.org>
> Subject: [Freeswitch-users] how can i keep A-LEG do not hangup
> 
>  
> 
> All:
> 
>      recently i write a small program based freeswitch, in this program i only do things like callcenter mod,
> 
> here is what i do:
> 
>  
> 
>    1. originate a call (“ originate sofia/gateway/gw01/xxxx my-out-call XML default”), in the default.xml,
> 
>       i already config it as follow:
> 
>  
> 
>            <extension name=“my-call-out">
> 
>  65         <condition field="destination_number" expression="^my-call-out$">
> 
>  66             <action application="socket" data="127.0.0.1:9600 <http://127.0.0.1:9600/> async full"/>
> 
>  67             <!--    <action application="log" data="This is ax-call-out-park"/>
> 
>  68                         <action application="answer" />
> 
>  69             <action application="playback" data="/usr/local/freeswitch/sounds/1.wav"/>
> 
>  70             
> 
>  71             <action application="park" data=""/> -->
> 
>  72         </condition>
> 
>  73     </extension>
> 
>       
> 
>     2.  when call-out-destination customer pick up the call, i control the flow to playback a wav file, then ,
> 
>          bridge the call to a free agent while the wav file play over in CHANNEL_EXECUTE_COMPLETE,
> 
>          these steps run normally ok.
> 
>  
> 
>    3. the question is : if i have two agent in one moment, and this time i have 3 or > 3  out-call to bridge, 
> 
>        i’ll leave the other call do nothing,for i can not get more free agents to service; some special scene
> 
>       is i have two agents (A1,A2) service 3 call (C1,C2,C3), A1 service C1, A2 service C2,then C3 is only 
> 
>       A-LEG when play over a wav file,about 100 seconds later, C3 is hangup(it’s not user hangup manually),
> 
>      how can i do make the C3 call not hangup until i get a free agent to service it?
> 
>  
> 
>  
> 
>  any suggest is appreciate,
> 
>  
> 
>  
> 
>  
> 
>     ax.lyb.lei at gmail.com <mailto:ax.lyb.lei at gmail.com>
>      
> 
> 
> _________________________________________________________________________
> Professional FreeSWITCH Consulting Services:
> consulting at freeswitch.org <mailto:consulting at freeswitch.org>
> http://www.freeswitchsolutions.com <http://www.freeswitchsolutions.com/>
> 
> Official FreeSWITCH Sites
> http://www.freeswitch.org <http://www.freeswitch.org/>
> http://confluence.freeswitch.org <http://confluence.freeswitch.org/>
> http://www.cluecon.com <http://www.cluecon.com/>
> 
> FreeSWITCH-users mailing list
> FreeSWITCH-users at lists.freeswitch.org <mailto:FreeSWITCH-users at lists.freeswitch.org>
> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users <http://lists.freeswitch.org/mailman/listinfo/freeswitch-users>
> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users <http://lists.freeswitch.org/mailman/options/freeswitch-users>
> http://www.freeswitch.org <http://www.freeswitch.org/>
> 
> 
> 
> -- 
> Brian West
> brian at freeswitch.org <mailto:brian at freeswitch.org>
> 
> Twitter: @FreeSWITCH , @briankwest
> http://www.freeswitchbook.com <http://www.freeswitchbook.com/>
> http://www.freeswitchcookbook.com <http://www.freeswitchcookbook.com/>
> T:+19184209001 <tel:%2B19184209001> | F:+19184209002 <tel:%2B19184209002> | M:+1918424WEST (9378)
> iNUM:+883 5100 1420 9001 | ISN:410*543 | Skype:briankwest
> 
> 
> _________________________________________________________________________
> Professional FreeSWITCH Consulting Services:
> consulting at freeswitch.org <mailto:consulting at freeswitch.org>
> http://www.freeswitchsolutions.com <http://www.freeswitchsolutions.com/>
> 
> Official FreeSWITCH Sites
> http://www.freeswitch.org <http://www.freeswitch.org/>
> http://confluence.freeswitch.org <http://confluence.freeswitch.org/>
> http://www.cluecon.com <http://www.cluecon.com/>
> 
> FreeSWITCH-users mailing list
> FreeSWITCH-users at lists.freeswitch.org <mailto:FreeSWITCH-users at lists.freeswitch.org>
> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users <http://lists.freeswitch.org/mailman/listinfo/freeswitch-users>
> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users <http://lists.freeswitch.org/mailman/options/freeswitch-users>
> http://www.freeswitch.org <http://www.freeswitch.org/>
> 
> 
> _______________________________________________
> FreeSWITCH-users mailing list
> FreeSWITCH-users at lists.freeswitch.org
> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
> http://www.freeswitch.org

ax lyb
ax.lyb.lei at gmail.com



-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20150116/95972414/attachment-0001.html 


Join us at ClueCon 2016 Aug 8-12, 2016
More information about the FreeSWITCH-users mailing list