Question

Not sure what's the best approach to do this and not even sure if it's doable. I have PHP and MySQL, FreeSWITCH, FreeSWITCH PHP ESL setup on my server and a SIP phone number binded to the gateway. In the database I have a table storing pairs of phone numbers that I want to bridge calls between. A short version of the table looks like below:

+-----+--------------+--------------+
|     |   Callee_1   |   Callee_2   |
+-----+--------------+--------------+
|  1  |  1112223333  |  2223334444  |
|  2  |  6667778888  |  7778889999  |
|  3  |  1123581321  |  3455891442  |
+-----+--------------+--------------+

What I've been trying to achieve is to build a automated call center with FreeSWITCH in a way that I can make an automated call to Callee_1 in the table and play an IVR once Callee_1 picks up. If Callee_1 presses 1 I will bridge the the call to Callee_2 so they can speak on the phone.

I was thinking about to setup a CronJob that fetches new rows from the table periodically then loop through them and use PHP ESL to originate calls to Callee_1. Something like

$sock->api("originate sofia/gateway/myProvider/$Callee_1 &ivr(my_ivr)");

my_ivr:

<menu name="my_ivr"
    greet-long="say:Thank you for filling out the form."
    greet-short="say:Thank you.
    ......
    digit-len="4">
  <entry action="menu-exec-app" digit="1" param="bridge sofia/gateway/myProvider/Callee_2/>
</menu>

Everything seems fine up till now yet I ran into the problem of how to pass the corresponding Callee_2's phone number to the IVR entry dynamically. Should I rewrite the ivr xml and do a reload for every pair? I tried configuring the mod_xml_curl yet no luck. The fs_cli generates "405 not allowed" error every time I try to reload IVR. I also checked out the HTTAPI seems it doesn't fit my need here as it requires using session. Any insight is appreciated. Thanks!

Was it helpful?

Solution

I'm the OP and now answering my own question. It turned out that I was over complicating the whole thing and FreeSWITCH is extremely intuitive to use. Simply setting a channel variable

originate {callee_2=2223334444}sofia/gateway/myProvider/1112223333 &ivr(my_ivr)

and accessing the channel variable in the ivr xml

<menu name="my_ivr"
    greet-long="say:Thank you for filling out the form."
    greet-short="say:Thank you.
    ......
    digit-len="4">
  <entry action="menu-exec-app" digit="1" param="bridge sofia/gateway/myProvider/${callee_2}/>
</menu>

will do the trick. Hopefully it helps.

OTHER TIPS

in menu-exec-app, you can execute a Lua or some other script which looks up the destination in the database.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top