06-19-2023 01:33 AM - last edited on 06-21-2023 04:31 AM by Shahzad_Ismail
Hi,
In my account I have multiple numbers in a project. For all numbers, I want to route to my SIP server so I am using Handle call events with SIP forwarding where I defined sip:61489901111@sip-server.com:5060. I receive calls on my SIP server all time from 61489901111 but It should be virtual number on which call received so is there any way to define dynamic SIP forwarding value like sip:{number}@sip-server.com:5060 where number will assigned at run time.
Solved! Go to Solution.
06-20-2023 10:58 PM
Hi Uday,
As discussed we can do that but you will have to use a callback server and connectSIP to route the called did to your sip endpoint. Perhaps not suitable for your use case but worth mentioning in case others are interested.
Making the call with a callback server used for routing the call
If you have a callback server then it will receive the ICE event as an HTTP POST request once the call is received by us on the did (a purchased number from us for routing incoming calls).
Here you can discern the endpoint to which the call was made. Here it is +4622222222 (Endpoint type "did", your purchased number).
The ICE you receive once the call is incoming to your did
{
event: 'ice',
callid: '8372c600-bfce-4508-nnnn-c6dc3a49b150',
callResourceUrl: 'https://calling-euc1.api.sinch.com/calling/v1/calls/id/8372c600-bfce-4508-nnnn-c6dc3a49b150',
timestamp: '2023-06-20T16:30:09Z',
version: 1,
userRate: { currencyId: 'USD', amount: 0 },
cli: '461111111111',
to: { type: 'did', endpoint: '+4622222222' },
domain: 'pstn',
applicationKey: 3b216e8d-e385-4ff9-ae80-5d11897006b0,
originationType: 'PSTN',
rdnis: '+46111111111'
}
You can then use application logic to use the endpoint in the ICE to be the destination portion of your SIP URI in your connectSip,
This way it is connected to the correct SIP user in your infrastructure.
The cli you could use as any number (did) you purchase from us in this scenario. Here I have just used the did that was dialed.
The Response from your application server
{
action: {
name: 'connectSip',
destination: { endpoint: '+4622222222@mysipinfrastructure:5060' },
maxDuration: 3000,
cli: '+4622222222',
transport: 'tls',
suppressCallbacks: false,
}
}
*The cli shown above you could use as any number (did) you purchase from us in this scenario.
The ACE you receive once the call is answered
Once the call is answered an incoming ACE is received at the callback server
{
event: 'ace',
callid: '8372c600-bfce-4508-nnnn-c6dc3a49b150',
timestamp: '2023-06-20T16:30:10Z',
version: 1,
applicationKey: 3b216e8d-e385-4ff9-ae80-5d11897006b0,
}
You can just choose to continue here, or you could play a message, start recording, responses to ACE are outlined here https://developers.sinch.com/docs/voice/api-reference/svaml/#svaml-quick-reference
action: {
name: 'continue',
suppressCallbacks: false,
},
The DICE you receive once the call is ended
When the call is hungup you will receive A DICE event, showing information related to the call such as duration and cost.
{
event: 'dice',
callid: '8372c600-bfce-4508-nnnn-c6dc3a49b150',
timestamp: '2023-06-20T16:30:18Z',
reason: 'CALLERHANGUP',
result: 'ANSWERED',
version: 1,
debit: { currencyId: 'USD', amount: 0.5},
userRate: { currencyId: 'USD', amount: 0.368},
to: {
type: 'sip',
endpoint: '+4622222222@mysipinfrastructure:5060'
},
applicationKey: 3b216e8d-e385-4ff9-ae80-5d11897006b0,
duration: 8,
from: '4622222222'
}
06-20-2023 10:58 PM
Hi Uday,
As discussed we can do that but you will have to use a callback server and connectSIP to route the called did to your sip endpoint. Perhaps not suitable for your use case but worth mentioning in case others are interested.
Making the call with a callback server used for routing the call
If you have a callback server then it will receive the ICE event as an HTTP POST request once the call is received by us on the did (a purchased number from us for routing incoming calls).
Here you can discern the endpoint to which the call was made. Here it is +4622222222 (Endpoint type "did", your purchased number).
The ICE you receive once the call is incoming to your did
{
event: 'ice',
callid: '8372c600-bfce-4508-nnnn-c6dc3a49b150',
callResourceUrl: 'https://calling-euc1.api.sinch.com/calling/v1/calls/id/8372c600-bfce-4508-nnnn-c6dc3a49b150',
timestamp: '2023-06-20T16:30:09Z',
version: 1,
userRate: { currencyId: 'USD', amount: 0 },
cli: '461111111111',
to: { type: 'did', endpoint: '+4622222222' },
domain: 'pstn',
applicationKey: 3b216e8d-e385-4ff9-ae80-5d11897006b0,
originationType: 'PSTN',
rdnis: '+46111111111'
}
You can then use application logic to use the endpoint in the ICE to be the destination portion of your SIP URI in your connectSip,
This way it is connected to the correct SIP user in your infrastructure.
The cli you could use as any number (did) you purchase from us in this scenario. Here I have just used the did that was dialed.
The Response from your application server
{
action: {
name: 'connectSip',
destination: { endpoint: '+4622222222@mysipinfrastructure:5060' },
maxDuration: 3000,
cli: '+4622222222',
transport: 'tls',
suppressCallbacks: false,
}
}
*The cli shown above you could use as any number (did) you purchase from us in this scenario.
The ACE you receive once the call is answered
Once the call is answered an incoming ACE is received at the callback server
{
event: 'ace',
callid: '8372c600-bfce-4508-nnnn-c6dc3a49b150',
timestamp: '2023-06-20T16:30:10Z',
version: 1,
applicationKey: 3b216e8d-e385-4ff9-ae80-5d11897006b0,
}
You can just choose to continue here, or you could play a message, start recording, responses to ACE are outlined here https://developers.sinch.com/docs/voice/api-reference/svaml/#svaml-quick-reference
action: {
name: 'continue',
suppressCallbacks: false,
},
The DICE you receive once the call is ended
When the call is hungup you will receive A DICE event, showing information related to the call such as duration and cost.
{
event: 'dice',
callid: '8372c600-bfce-4508-nnnn-c6dc3a49b150',
timestamp: '2023-06-20T16:30:18Z',
reason: 'CALLERHANGUP',
result: 'ANSWERED',
version: 1,
debit: { currencyId: 'USD', amount: 0.5},
userRate: { currencyId: 'USD', amount: 0.368},
to: {
type: 'sip',
endpoint: '+4622222222@mysipinfrastructure:5060'
},
applicationKey: 3b216e8d-e385-4ff9-ae80-5d11897006b0,
duration: 8,
from: '4622222222'
}