Automatic ADC Transfer Function Lua implementation

Source: Internet
Author: User
Tags freeswitch

I. background:

Although mod_fifo and mod_callcenter can be used as call center applications, it is difficult to customize these two modules in the application, here I use Lua to implement the 5-way Customer Service (1000-1004), a call center number: 9958 ADC implementation solution, which is recorded here.

Ii. flowchart:

Iii. Specific settings:

1. Add/usr/local/freeswitch/CONF/autoload_confilgs/modules. conf. XML to the mod_lua module, which is loaded by default;

2. Add 5 global variables to/usr/local/freeswitch/CONF/var. XML to identify the call status of the customer service number. The content is as follows:

<! -- Yjcallcenter sets: 0 allow the call, 1 busy -->

<X-PRE-PROCESS cmd = "set" Data = "yj1000 = 0"/>

<X-PRE-PROCESS cmd = "set" Data = "yj1001 = 0"/>

<X-PRE-PROCESS cmd = "set" Data = "yj1002 = 0"/>

<X-PRE-PROCESS cmd = "set" Data = "yj1003 = 0"/>

<X-PRE-PROCESS cmd = "set" Data = "yj1004 = 0"/>

3. Add 9958_callcenter.xml in the/usr/local/freeswitch/CONF/dialplan/default directory. The content is as follows:

<Extension name = "yj_callcenter">

<Condition field = "destination_number" expression = "^ (9958) $">

<Action application = "Lua" Data = "yjcall. Lua"/>

</Condition>

</Extension>

4. Add yjcall. Lua in the/usr/local/freeswitch/scripts directory. The content is as follows:

Print ("\ n ******** logo_fox's callcenter ******* \ n ")

 

API = freeswitch. API ();

Local yj1000 = freeswitch. getglobalvariable ("yj1000 ");

Local yj1001 = freeswitch. getglobalvariable ("yj1001 ");

Local yj1002 = freeswitch. getglobalvariable ("yj1002 ");

Local yj1003 = freeswitch. getglobalvariable ("yj1003 ");

Local yj1004 = freeswitch. getglobalvariable ("yj1004 ");

 

Function yjcheck (command, linenum, Info)

Local yjdata = API: executestring (command );

Local I1, J1 = string. Find (yjdata, "100" .. linenum );

If (Info = "linestatuscheck") then

If (i1 ~ = Nil and I1> 0) then

API: executestring ("global_setvar yj100"... linenum... "= 1 ");

Else

API: executestring ("global_setvar yj100"... linenum... "= 0 ");

End

End

If (Info = "registioncheck") then

If (i1 ~ = Nil and I1> 0) then

Return 1;

Else

Return 0;

End

End

End

 

Local L1000 = yjcheck ("Sofia status profile internal Reg", 0, "registioncheck ");

Local L1001 = yjcheck ("Sofia status profile internal Reg", 1, "registioncheck ");

Local l1002 = yjcheck ("Sofia status profile internal Reg", 2, "registioncheck ");

Local l1003 = yjcheck ("Sofia status profile internal Reg", 3, "registioncheck ");

Local l1004 = yjcheck ("Sofia status profile internal Reg", 4, "registioncheck ");

 

 

For I = 0, 4, 1 do

Yjcheck ("show CILS", I, "linestatuscheck ");

End

 

 

Yj1000 = freeswitch. getglobalvariable ("yj1000 ");

Yj1001 = freeswitch. getglobalvariable ("yj1001 ");

Yj1002 = freeswitch. getglobalvariable ("yj1002 ");

Yj1003 = freeswitch. getglobalvariable ("yj1003 ");

Yj1004 = freeswitch. getglobalvariable ("yj1004 ");

 

If (yj1000 = "0" and L1000 = 1) then

Print ("------ customer 1000 is at your service ------");

API: executestring ("global_setvar yj1000 = 1 ");

Session: Transfer ("1000", "XML", "default ");

Return;

End

 

If (yj1001 = "0" and L1001 = 1) then

Print ("------ customer 1001 is at your service ------");

API: executestring ("global_setvar yj1001 = 1 ");

Session: Transfer ("1001", "XML", "default ");

Return;

End

 

If (yj1002 = "0" and l1002 = 1) then

Print ("------ customer 1002 is at your service ------");

API: executestring ("global_setvar yj1002 = 1 ");

Session: Transfer ("1002", "XML", "default ");

Return;

End

 

If (yj1003 = "0" and l1003 = 1) then

Print ("------ customer 1003 is at your service ------");

API: executestring ("global_setvar yj1003 = 1 ");

Session: Transfer ("1003", "XML", "default ");

Return;

End

 

If (yj1004 = "0" and l1004 = 1) then

Print ("------ customer 1004 is at your service ------");

API: executestring ("global_setvar yj1004 = 1 ");

Session: Transfer ("1004", "XML", "default ");

Return;

End

 

Print ("--------- no available line, please wait dial !! ----------");

Session: hangup ();

 

By now, the ADC function has been set up. Call 9958 to implement 5 customer service services.

 

 

 

Automatic ADC Transfer Function Lua implementation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.