Jump to content

Recommended Posts

Posted

Hello there,

Happy to be among you.

I'm testing Kazoo on premise and checked several documentation, unfortunately (for sure I'm missing something) I couldn't find how to route OUTGOING calls based on :

1. Destination
2. Caller ID

Considering I have 3 SIP Trunks:
a) Trunk A (Preferred for France outgoing Calls)
b) Trunk B (Preferred for China outgoing Calls)
c) Trunk C (Preferred for the rest of the world outgoing Calls)

Below some scenarios:
Scenario 1 "Destination based routing":
I would like to apply a rule that will check Called ID (ie. destination) and based on that it will use Trunk A, B or C. 
For example:
- If I call +33 xxxxxxxxx, the call will be routed through TRUNK A
- If I call +86 xxxxxxxxx, the call will be routed through TRUNK B
- If I call +1 or +32 or any other prefix (different from +33 and +86) the call will be routed through TRUNK C


Scenario 2 "Caller ID based routing":
I have 2 customers:
a) Customer A: Has been assigned following block of fixed numbers: +352 412 300 to +352 412 350
b) Customer B: Has been assigned following block of fixed numbers: +34 411 111 700  to +34 411 111 730

I would like to apply a rule that will check Caller ID and based on that it will route the call through Trunk A or C. 
For example:
- All calls made with a caller ID belonging to block of fixed numbers: +352 412 300 to +352 412 350,  will be routed through TRUNK A 
- All calls made with a caller ID belonging to block of fixed numbers: +34 411 111 700  to +34 411 111 730,  will be routed through TRUNK C 

Hopefully the below scenarios are clear.

Please don't hesitate if you need further information/details.

Thank your for your help

Posted

Hi,

We have solved this by having a  Kamailio/Sipproxy handling all inbound and outbound connections to all carrier. This Sipproxy does the routing to the correct carrier. On Kazoo side we have hack the ratecard, so that before each call it's getting the rate and a prefix from a mysql.

 

E.g. we have a call to Germany we get back from mysql *5+49221999999999. The Sipproxy know to route this with the Prefix to a carrier set in the mysql.

 

Best

David

  • Administrators
Posted

@Matrixdz2002

As @mat1010 points out, you can use the "rules" regular expressions to filter what types of numbers can be routed using a particular resource (carrier). See https://docs.2600hz.com/dev/applications/crossbar/doc/resources/

There's also a 'resource selectors' option: https://docs.2600hz.com/dev/applications/crossbar/doc/resource_selectors/ contributed to the community. May help you too (though I haven't personally used it).

That should cover the "destination" portion of your question.

For caller ID, you would need to setup the callflow(s) with branching based on the caller ID: https://docs.2600hz.com/dev/applications/callflow/doc/check_cid/

Using the match/nomatch branches, you could then use the "resources" callflow action and set an outbound_flag "use_c" or whatever, which the resource doc would need to have in its "flags" as well. See https://docs.2600hz.com/dev/applications/callflow/doc/resources/

Posted

Hi all,

Thank you for your help. 

Indeed the  "rules" regular expressions helped to set the routes conditions. I was able to route a call based on destination I will test also callflow to route based the Caller ID.

Thank you all, I couldn't find it without your help :-)

I take this opportunity also to ask another question regarding Call Diversion. 
I read on some forum that Call Diversion headers are used to support call forwarding and deflection, and also enable outbound calls from phone numbers that aren't assigned by the carrier

The question is how to set the call diversion using regex to allow the below scenario:

I have a caller from UK calling one of our employee/customer on his fixed line and that employee/customer has set a call forwarding to his mobile number 

For example:
Caller ID : +44 2 11 11 11
Called ID : +33 1 23 45 67 89
FORWARD CALL TO: +33 6 78 00 00

Without a Call diversion, the call will be rejected by the carrier, so how can we fix it?

Thanks

  • Administrators
Posted

I think you want to set the forwarded device's call_forward:{keep_caller_id:true} (assuming you're doing the forwarding server-side. Then look in your system_config's kazoo_endpoint doc for "should_add_diversion_header" and set it to true. `sup kapps_config set_default kazoo_endpoint should_add_diversion_header true` should work.

See if the carrier likes that.

Posted (edited)

Hi @mc_ , 

 

Thank you for the support.

Unfortunately I still can't apply the diversion header

I applied on kazoo_endpoints (cf. below): 

{
   "_id": "kazoo_endpoint",
   "_rev": "17-85c7845s62ca8b0dec9fed889ef5c6661",
   "default": {
       "should_add_diversion_header": "true",
       "default_ignore_completed_elsewhere": true,
       "restrict_to_known_types": false
   }
}

+++++++++

Below information of the resources:
{
   "_id": "ad9850e6484b13b3e54781a210dffbb2",
   "_rev": "71-72b87146c01e1dd9547bf7f2b47e94133",
   "pvt_type": "resource",
   "name": "Carrier Test FR",
   "enabled": true,
   "flags": [
   ],
   "weight_cost": 1,
   "rules": [
       "^\\+33\\d{9,}$"
   ],
   "gateways": [
       {
           "server": "sip.xxxxx.com",
           "username": "myusername",
           "password": "mypassword",
           "prefix": "",
           "suffix": "",
           "media": {
               "fax_option": false
           },
           "codecs": [
               "PCMA",
               "PCMU",
               "G729"
           ],
           "enabled": true
       }
   ],
   "grace_period": 5,
   "formatters": {
       "request": [
           {
               "regex": "^(\\d{9,})$",
               "prefix": "+33",
               "suffix": ""
           }
       ],
       "diversion": [
           {
               "match_invite_format": true,
               "direction": "outbound"
           }
       ]
   }
}

 

According to the carrier, to use a third party number, I will need to add a diversion header in the INVITE that contains a Carrier DID enabled for outbound

Edited by Matrixdz2002 (see edit history)
Posted (edited)

Hello all,

@tomas_, Thanks  for your reply.
I tried it and the carrier accepted the call, but since I specified a number (+33123456789) on the diversion, all outgoing calls are under that number "+33123456789"

"custom_sip_headers": {
               "Diversion": "<sip:+33123456789@sip.provider.com>;reason=unconditional"
           },

But in my case, I have several users where everyone has his own number (for example: +33111111111, +33122222222, +33133333333) and each forward the calls to another number

Example:
UserA: +33111111111 --> Forward to --> +33 6 78 00 00 00
UserB: +33122222222 --> Forward to --> +33 6 49 11 88 88
UserC: +33133333333 --> Forward to --> +33 6 41 10 10 10

What I'm looking for is how to set the correct configuration that can replace the "<sip:+33xxxxxxxxx@sip.provider.com> by the correct number of each user:
<sip:UserA_number@sip.provider.com>, <sip:UserB_number@sip.provider.com>, <sip:UserC_number@sip.provider.com>

For the moment, What I did is:
- Deleting "custom_sip_headers" settings from the resources doc
- Setting "should_add_diversion_header": "true" to system_config -> Kazoo_endpoint
- On monster-ui, all users that have "Call Forwarding" enabled, have "Keep Original Caller-ID" checked


With these setting, calls are forwarded and accepted by the carrier, but what I noticed is, all tested incoming calls from +33 xxxx are correctly working, while any call coming from other prefixes like +44, +32... is rejected

Below example calls
Scenario 1 (Working):
Caller ID: +33 6 35 00 00 00 (French Mobile)
Called ID: +33 1 11 11 11 11
Forwarded to: +33 6 78 00 00 00(French Mobile)

But when I try to call from +32 xxxxx number to the SAME number the call is rejected with message error "503 Service Unavailable"
Scenario 2 (Not working):
Caller ID: + 32 2 33 12 345 (Belgian DID)
Called ID: +33 1 11 11 11 11
Forwarded to: +33 6 78 00 00 00(French Mobile)

I also noticed on the PCAP that on Scenario 1 , that diversion is applied and I see the Called ID, while on Scenario 2 the diversion is not applied, which led the carrier to reject the call.

I still didn't figure out why it's happening. The only possible solution for me now is to use /force again custom_sip_headers, but only if I can assign the correct called ID on the Diversion (ie. <sip:UserA_number@sip.provider.com>, <sip:UserB_number@sip.provider.com>, <sip:UserC_number@sip.provider.com> )

 

Best Regards,

Edited by Matrixdz2002 (see edit history)
Posted

I'm not familiar with your specific issue, and not the setting that _mc mentioned above that sounds promising.

However we've created some Pivot scripts to set the diversion header dynamically for each call, that approach might help you.
Instead of "account/global carrier" in the "no_match" callflow we use Pivot to launch the script.

An example of the output from the script with diversion header could look like this:
 

{"module":"resources",
	"data":{
		"to_did":"NUMBER_TO_CALL",
		"use_local_resources": true,
		"custom_sip_headers":{
			"Diversion": "<sip:DIVERSION_NUMBER@SIP_SERVER.COM>;reason=unconditional"
		}
	}
}

 

Posted (edited)

Hi all,

Just to let you know that after checking and monitoring the calls with diversion header enabled, I can find who is calling (Caller Originator) even the caller ID is what I set on Custom SIP header.

To resume, here what I set on my Kazzo/BigCouch:
- Adding "custom_sip_headers" settings to the resources doc (as per @tomas_ recommendation)
- Setting "should_add_diversion_header": "true" to system_config -> Kazoo_endpoint (as per @mc_ recommendation)
- On monster-ui, I enabled "Call Forwarding" and set "Keep Original Caller-ID" checked on all concerned users

This way all call are correctly forwarded to the carrier and the latter is routing the calls without issue.

I would like to thank each of you who assisted me on that issue.

Best Regards,
 

Edited by Matrixdz2002 (see edit history)
  • 3 weeks later...
Posted

Hello to the great community,

Hope doing well. Now that I have a working Kazoo and outgoing calls based on destination. I would like to apply a rule to route some calls through specific SIP trunk (offnet/ressources)

Below the need:
I would like to apply a rule that will check the Called ID, if it's fixed number or mobile number and based on that, the call will be routed to Trunk A or B. 
The scenario is for Belgium.

Please note:

1. Most of the callers will NOT dial the prefix +32 (they will dial  0x xxx xx xx)
2. For Belgium, the (Landlines in Liège have numbers starting with 04, and so do mobile phones all over the country. But mobile numbers are 04xx xx xx xx – 10 digits in total – while Liège numbers are 04 xxx xx xx – 9 digits in total. Liège also never starts with 04 6x, 04 7x, 04 8x or 04 9x )

Based on that:

- If I call 02 xxx xx xx (Fix number), the call will be routed through TRUNK A
- If I call 04 xxx xx xx (Fix Number), the call will be routed through TRUNK A
- If I call 04xx xx xx xx (Mobile Number), the call will be routed through TRUNK B

Adding to that the VoIP Provider requests always to send the number on E.164 format (ie. adding the prefix +32) so I need to apply it on the offnet doc 

 

Voilà, hope as usual someone can help 

 

Best Regards,

 

×
×
  • Create New...