Author Topic: Routing some calls by javascript module  (Read 8096 times)

bnaetsch

  • Newbie
  • *
  • Posts: 9
    • View Profile
Routing some calls by javascript module
« on: December 28, 2017, 05:08:52 AM »
Hello Yate team

I want to route incomming calls by asking a separate web service for the destination.
I will write a script for instance named inboundjsrouting.js
I think the javascript module will be the best solution.
But I don't want route all of my calls using the javascript module
The most calls, I want to route by regexroute.conf (how it works currently)
Therefore I think I can do a pre-routing , for instance all calls which are comming in by the number +49123456987 in the section contexts in regexroute.conf to a separate context for instance jsrouting in which I can call the javascript module.
Is this the right way?
And how I have to call the javascript module and the script (in the example  inboundjsrouting.js) in the separate context (in the example jsrouting) in the regexroute.conf

Thanks for your help
Burkhard

Monica Tepelus

  • Administrator
  • Full Member
  • *****
  • Posts: 198
    • View Profile
Re: Routing some calls by javascript module
« Reply #1 on: January 03, 2018, 04:36:24 AM »
Hi,

To choose the best way you need to know the criterias for routing in js/regexroute. You can have different priorities of the call.route message. The smaller the number, the higher the priority.

You could set the javascript route first (just install the handler with priority 90). Default priority for call.route in regexroute is 100.
Route all the calls that you want from js, all those not routed (return false;  -- in code), will pass on to be routed in regexroute. If you "return true;" with/without an error, then call won't pass on to

Various combinations are possible. You can fix handling call.route/call.preroute and playing with the priorities when installing handlers.

You also need to choose the type of javascript script to use: global script/routing script. If many calls reach the script you should use a global script. The routing script allows you to route and build small ivr but it starts an instance for every call. If you just want to route, global script is more eficient.