Outbound - Receiving SIP from Twilio
概要
TwilioのProgrammable Voice SIP Interface製品では、既存のSIP通信インフラを使用してTwilioクラウドでのSIPセッションの開始、Twilioの TwiML 言語やREST APIの使用で高度な音声通話アプリケーションを行うことができます。
動作の仕組み
Programmable Voice SIPでは、あなたのTwilioアプリケーションとSIP通信インフラを接続する手段がいくつかあります。
- アプリケーションはTwilioのREST APIを使って、SIP通信インフラに対して新規にSIP通話を開始することができます
- 着信のPSTNまたはSIPの通話は、<Dial>動詞の<Sip>名詞を使用して応答できるアプリケーションを呼び出してSIPエンドポイントとの通話を確立できます。
<?xml version="1.0" encoding="UTF-8"?> <Response> <Dial> <Sip>sip:jack@example.com</Sip> </Dial> </Response>
はじめましょう
Twilioからあなたの通信インフラへのSIPの受信を開始するには、従うべき主要な手順がひとつあります。
Allow Twilio’s SIP IP addresses and media ports in your system
To ensure that your communications infrastructure doesn’t block communication, you must update your allowed list of IP Addresses. See here for details.
Now that Twilio’s IPs are allowed in your system, your Twilio app can begin sending SIP traffic to your SIP communications infrastructure. If you are new to Twilio, it’s best to start out with <Sip> noun of the <Dial> for your first app. See here for details.
高度な機能
SIP Custom Headers
Twilio allows you to send custom SIP headers as part of the outgoing initial INVITE request.
<?xml version="1.0" encoding="UTF-8"?> <Response> <Dial> <Sip>sip:jack@example.com?x-myotherheader=bar</Sip> </Dial> </Response>
You can also send multiple param & value pairs as part of the same header. For example,
<?xml version="1.0" encoding="UTF-8"?> <Response> <Dial> <Sip>sip:+14158675309@your.domain?X-customName=Bob%2CShield%2BTitle%2DManager&X-otherHeader=true</Sip> </Dial> </Response>
Twilio allows you to pass the custom header as part of Dial action URL or the call screening URL. On a successful call setup (when a 200 OK SIP response is returned) any X-headers in the 200 OK message are posted in the format SipHeader_X-headername=headervalue and in the final SIP response message (any 4xx or 5xx message or the final BYE/200) are posted in the format DialSipHeader_X-headername=headervalue.
UUI (User-to-User Information) Header
In order to pass the contextual information of the caller, customers use UUI (User-to-User Information) header in SIP request messages. Twilio allows you to pass UUI header as part of <Sip> request.
Note: For non X-headers like UUI action and call screening URL are not supported.
UUI headers is the only header that can be sent without "X-" prefix. See below...
<?xml version="1.0" encoding="UTF-8"?> <Response> <Dial> <Sip>sip:jack@example.com?User-to-User=123456789%3Bencoding%3Dhex&x-myotherheader=bar</Sip> </Dial> </Response>
UUI headers can also send with "X-" prefix. See below...
<?xml version="1.0" encoding="UTF-8"?> <Response> <Dial> <Sip>sip:jack@example.com?X-User-to-User=123456789%3Bencoding%3Dhex&x-myotherheader=bar</Sip> </Dial> </Response>
The edge
Parameter
To specify the geographic edge from which Twilio will send SIP-out traffic towards your communication infrastructure, you must include the edge
parameter in your SIP URI. For example, if the edge=frankfurt
parameter is included in your SIP URI, Twilio will send the SIP traffic from the Frankfurt, Germany edge:
<?xml version="1.0" encoding="UTF-8"?> <Response> <Dial> <Sip>sip:alice@example.com;edge=frankfurt</Sip> </Dial> </Response>
エッジ | 所在地 |
---|---|
ashburn | 北米 ヴァージニア |
san-jose | 北米 オレゴン |
dublin | 欧州 アイルランド |
frankfurt | 欧州 フランクフルト |
singapore | アジア太平洋 シンガポール |
tokyo | アジア太平洋 東京 |
sao-paulo | South America São Paulo |
sydney | アジア太平洋 シドニー |
You can find the legacy region list here.
eg: <Sip>sip:alice@example.com;region=de1</Sip>
If the edge
parameter is not specified, Twilio will send SIP-out traffic from the North America, Virginia edge.
メモ:
- You must make sure you allow the IP addresses of the Twilio edge for SIP signaling and RTP media traffic.
- The
edge
parameter is not supported when calling SIP registered endpoints, the parameter will be ignored if present. SIP-out traffic will always be sent from the Twilio edge the SIP endpoint registered with.
ヘルプが必要ですか?
誰しもが一度は考える「コーディングって難しい」。そんな時は、お問い合わせフォームから質問してください。 または、Stack Overflow でTwilioタグのついた情報から欲しいものを探してみましょう。