Adding user=phone to URI and headers
2 posters
Page 1 of 1
Adding user=phone to URI and headers
In some cases far ends wants to see user=phone on URI and headers. You can simply add this to your URI and headers with following;
- Create a new script named add_user_phone
- Copy following script part and Save
- Code:
#
# Script version 1.0
#
# Version history:
# 1.0 Initial version of this script
#
# This filter is used to add "user=phone" to call URI's
#
module AddUserPhone
def init_add_user_phone(params)
end
def add_sip_header_param( call, field, param_level, value )
call[ field ] = {} unless call[ field ].is_a? Hash
call[ field ] ||= {} # Create a hash if not already present
call[ field ][ param_level ] ||= "" # Create a string if not already present
call[ field ][ param_level ] += ";" if call[ field ][ param_level ] != "" # Append ; if already some parameters
call[ field ][ param_level ] += value # Append the value
end
def add_user_phone(params)
call = params[ :call ]
# Add to SIP URI
call[:request_uri_forward_enabled] = true
if call[:request_uri] && !call[:request_uri].include?( "user=phone" )
call[:request_uri] += ";user=phone"
end
add_sip_header_param( call, :calling_parameters, :uri_param, "user=phone" ) # Add to From header
add_sip_header_param( call, :called_parameters, :uri_param, "user=phone" ) # Add to To header
add_sip_header_param( call, :contact_parameters, :uri_param, "user=phone" ) # Add to Contact header
add_sip_header_param( call, :private_address_parameters, :uri_param, "user=phone" ) # Add to P-Asserted-Identity
add_sip_header_param( call, :redirecting_number_parameters, :uri_param, "user=phone") # Add to SIP Diversion
# header
# Remote-party-id -> Can't modify for now
params
end
end
- Select simple_routing_sbc script and add following script parts and Save
- Code:
.
.
require 'add_user_phone'
.
.
include AddUserPhone
.
.
after_filter :method => :add_user_phone
.
.
[*]Activate the configuration
Re: Adding user=phone to URI and headers
Hi, I tried to follow the instructions, but is doesn't work.
I'm using weight and load balance filter script also, do I need to merge both ?
I'm using weight and load balance filter script also, do I need to merge both ?
zictec- Number of Messages : 5
Point : 9
Registration Date : 2018-06-18
Re: Adding user=phone to URI and headers
You could use an after filter script to add user=phone easily to the field required. This script is called “sip_header_params.rb” from routing script section of web portal.
Below is a detailed instruction to use this script (it is available in the script itself),
# How to use this script
# 1. Import this script with other filter script in the Web Portal (if not already done)
# 2. Locate your "main" script (the routing scripts entry point, like "simple_routing.rb")
# and include current filter as an after_remap_filter
# 2.1. Add the following line at begining of the main routing script to load current filter script:
# require 'sip_header_params' unless defined?(SipHeaderParams)
# 2.2. Include the current filter to your routing script's main class (first line afer 'class MyScriptName')
# include SipHeaderParams
# 2.3. Attach current filter as an 'after_remap_filter', passing as argument an array that defines headers to add.
# Example:
# after_remap_filter :method => :sip_header_params, :headers_to_add => [{ :type=>:user_param, :contents=>"user=phone", :sip_headers=>[:called] }]
# Each element of this array is a hash that contains the following keys:
# - :type Define the type of SIP header parameter to add.
# :user_param, :uri_param, or :header_param
# (see documentation above in this file for more information)
# - :contents Contents to add for this parameter. No need to add ; separator, this will be automatically handled.
# Example: "user=phone"
# - :sip_headers An array of headers to add the parameter to. Possible values:
# :calling (SIP "From" header)
# :called (SIP "To" header)
# :private_address (SIP "P-Asserted-Identity" or "Remote-Party-ID header" header)
# :contact (SIP "Contact" header)
# :redirecting_number (SIP first "Diversion" header)
# :original_called_number (SIP second "Diversion" header)
# This can also be any "generic" SIP header (unparsed by routing script):
# "X-CustomHeader"
# In this case, the script will attempt to find this header (raw) and add header parameters to it.
# This may not work in all cases...
# Other headers with specific handling:
# :request_uri (SIP request-URI header)
# Normally automatically build using information from "To" header.
# So use this ONLY if you need request_uri to be different from "To".
# Not recomended, this may generate inappropriate Request URI header.
# Longer example:
# after_remap_filter :method => :sip_header_params, :headers_to_add => [
# {
# :documentation => "Add user=phone to user parameters of most SIP headers",
# :type => :uri_param,
# :contents => "user=phone",
# :sip_headers => [
# :calling,
# :called,
# :private_address,
# :contact,
# :redirecting_number,
# :original_called_number,
# "X-CustomHeader"
# ]
# },
# {
# :documentation => "Add foo=123 to uri parameters of 'From' header",
# :type => :uri_param,
# :contents => "foo=bar",
# :sip_headers => [ :calling ]
# }
# ]
# 3. Optionnally, you can create a new route column named "add_sip_header_params", type boolean.
# This route column (attribute) will determine, per route, if the defined SIP headers must be added or not.
# (custom route column can be created in the "Routes" section of the web portal under "Create New Route Column")
#
It is self explanatory. The above script also can cater if you want to do this just per route, using point 3, create a new route column. You could do this at static route, “create new route column,
For adding after filter, please also see below,
How to Setup Filters - TBwiki (telcobridges.com)
You could also copy existing configuration to another new configuration with new name, and work on the new name configuration, so you would not affect the current active configuration.
For any change, please do save and activate configuration. If there is any question, we could advise you further.
Kindly note routing script development normally would require a purchase of 9-5 professional service package.
Below is a detailed instruction to use this script (it is available in the script itself),
# How to use this script
# 1. Import this script with other filter script in the Web Portal (if not already done)
# 2. Locate your "main" script (the routing scripts entry point, like "simple_routing.rb")
# and include current filter as an after_remap_filter
# 2.1. Add the following line at begining of the main routing script to load current filter script:
# require 'sip_header_params' unless defined?(SipHeaderParams)
# 2.2. Include the current filter to your routing script's main class (first line afer 'class MyScriptName')
# include SipHeaderParams
# 2.3. Attach current filter as an 'after_remap_filter', passing as argument an array that defines headers to add.
# Example:
# after_remap_filter :method => :sip_header_params, :headers_to_add => [{ :type=>:user_param, :contents=>"user=phone", :sip_headers=>[:called] }]
# Each element of this array is a hash that contains the following keys:
# - :type Define the type of SIP header parameter to add.
# :user_param, :uri_param, or :header_param
# (see documentation above in this file for more information)
# - :contents Contents to add for this parameter. No need to add ; separator, this will be automatically handled.
# Example: "user=phone"
# - :sip_headers An array of headers to add the parameter to. Possible values:
# :calling (SIP "From" header)
# :called (SIP "To" header)
# :private_address (SIP "P-Asserted-Identity" or "Remote-Party-ID header" header)
# :contact (SIP "Contact" header)
# :redirecting_number (SIP first "Diversion" header)
# :original_called_number (SIP second "Diversion" header)
# This can also be any "generic" SIP header (unparsed by routing script):
# "X-CustomHeader"
# In this case, the script will attempt to find this header (raw) and add header parameters to it.
# This may not work in all cases...
# Other headers with specific handling:
# :request_uri (SIP request-URI header)
# Normally automatically build using information from "To" header.
# So use this ONLY if you need request_uri to be different from "To".
# Not recomended, this may generate inappropriate Request URI header.
# Longer example:
# after_remap_filter :method => :sip_header_params, :headers_to_add => [
# {
# :documentation => "Add user=phone to user parameters of most SIP headers",
# :type => :uri_param,
# :contents => "user=phone",
# :sip_headers => [
# :calling,
# :called,
# :private_address,
# :contact,
# :redirecting_number,
# :original_called_number,
# "X-CustomHeader"
# ]
# },
# {
# :documentation => "Add foo=123 to uri parameters of 'From' header",
# :type => :uri_param,
# :contents => "foo=bar",
# :sip_headers => [ :calling ]
# }
# ]
# 3. Optionnally, you can create a new route column named "add_sip_header_params", type boolean.
# This route column (attribute) will determine, per route, if the defined SIP headers must be added or not.
# (custom route column can be created in the "Routes" section of the web portal under "Create New Route Column")
#
It is self explanatory. The above script also can cater if you want to do this just per route, using point 3, create a new route column. You could do this at static route, “create new route column,
For adding after filter, please also see below,
How to Setup Filters - TBwiki (telcobridges.com)
You could also copy existing configuration to another new configuration with new name, and work on the new name configuration, so you would not affect the current active configuration.
For any change, please do save and activate configuration. If there is any question, we could advise you further.
Kindly note routing script development normally would require a purchase of 9-5 professional service package.
Guest- Guest
Similar topics
» enabling user=phone on sip invite
» 3CX Call Queue and SIP Headers
» Routing script to create a User-to-User Indication (UUI) based on the incoming called number
» ProSBC - Support for "IP-Based" registration for 3CX Phone System
» FreeSBC dropping all responses from IP Phone
» 3CX Call Queue and SIP Headers
» Routing script to create a User-to-User Indication (UUI) based on the incoming called number
» ProSBC - Support for "IP-Based" registration for 3CX Phone System
» FreeSBC dropping all responses from IP Phone
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum