<Siprec> TwiML instruction allows you to start a stream on a phone call and send that stream to one of the available partners via the configured SIPREC Connector.
Twilio operates as a Session Recording Client (SRC) for SIPREC and Twilio's partners, e.g. Gridspace, operate as Session Recording Server (SRS)
Alternately, you may provision your own SRS via configuration in the Twilio/Generic SIPREC Connector.
The SRC sends the SIPREC media to be recorded to the SRS. The SRS is responsible for storing/processing the media.
The most basic use of
<?xml version="1.0" encoding="UTF-8"?> <Response> <Start> <Siprec connectorName="my_addon_connector" /> </Start> </Response>
This TwiML will instruct Twilio to fork the audio stream of the current call and send it in real-time to the configured connector. DTMF will not be sent to the connector.
<Siprec> starts the audio stream asynchronously and immediately continues with the next TwiML instruction. If there is no instruction, the call will be disconnected. In order to avoid this, provide a TwiML instruction to continue the call.
Connectors are configured via the Marketplace Add-on in the Twilio Stream Connectors Console page. Connectors cannot be configured outside of Console. This requirement is in place to ensure that the credentials needed to send the stream to a partner are stored securely.
You can control which Twilio edge your SIPREC connections egress by appending an edge parameter to the Session Recording Server address in the SIPREC Connector Configuration.
sip:firstname.lastname@example.org:5060;edge=dublin would egress from the Dublin edge, and
sip:email@example.com:5060;edge=umatilla would egress from Oregon.
Any communication issues encountered while streaming media to the partner will be reported in the Twilio Debugger with additional information about the failure.
There are a maximum of four forked streams allowed per call.
<Siprec> by default uses two forked streams; one each for the inbound and outbound tracks.
<Siprec> supports the following attributes:
|Attribute Name||Allowed Values||Default Value|
|name||Optional. Unique name for the Stream||none|
|connectorName||Unique name used when configuring the connector via Marketplace Add-on.||Default|
name will allow you to reference the SIPREC stream directly. This name must be unique per Call SID.
For instance by naming the
<Start> <Siprec name="my_first_siprec_stream" connectorName="my_addon_connector" /> </Start>
You can later use the unique
my_first_siprec_stream to stop the stream.
<Stop> <Siprec name="my_first_siprec_stream" /> </Stop>
connectorName attribute must contain a unique name corresponding to the SIPREC Stream Connector installed via Twilio Stream Connectors console page.
For example, to use Gridspace Connector, use
Gridspace_1 is the unique name specified when configuring Gridspace Connector in the Stream Connectors page. In order to start a SIPREC session, you must first configure the appropriate SIPREC connector via Console.
The Twilio SIPREC Connector provides some additional SIP features.
You can configure these in your Connector instance. The SIP URI supports additional parameters,
secure which enables Secure Real-time Transport Protocol (SRTP), as well as,
edge which allows you to specify a specific edge location.
For instance, to enable SRTP and set the edge location to the ashburn edge, you would provide a similar SIP URI:
track attribute allows you to optionally request to receive a specific track of a call. On any given active call within Twilio there are inbound and outbound tracks, the former represents the audio Twilio receives from the call, and the later represents the audio generated by Twilio to the call. By default Twilio always streams the inbound track of a call. To request Twilio to stream audio it generates use
outbound_track, or to receive both tracks of a call use
both_tracks is used, you will receive both the inbound media event and outbound media event.
SIPREC partners often require additional metadata along with the audio stream. You can provide custom data by using
<Start> <Siprec name="my_stream_1" connectorName="Gridspace_1" track="outbound_track"> <Parameter name="Custom1" value ="Bob" /> <Parameter name="Custom2" value ="Blah" /> <Parameter name="Custom3" value ="Alice" /> </Siprec> </Start>
The exact names of parameters vary from partner to partner, so please refer to the appropriate partner tile in the Stream Connectors page to identify the custom parameters that need to be passed.
Start a new SIPREC stream with the name of
My SIPREC Stream and a connector of
To receive SIPREC streams from Twilio, please ensure to include the following regions in your allow list (IP address whitelist).
188.8.131.52/30 which translates to: 184.108.40.206 220.127.116.11 18.104.22.168 22.214.171.124 Ports: 5060 (UDP/TCP), 5061 (TLS)
126.96.36.199/23 188.8.131.52/23 Port Range: 10,000 to 20,000 (UDP)
184.108.40.206/30 which translates to: 220.127.116.11 18.104.22.168 22.214.171.124 126.96.36.199 Ports: 5060 (UDP/TCP), 5061 (TLS)
188.8.131.52/24 Port Range: 10,000 to 20,000 (UDP)
184.108.40.206/30 which translates to: 220.127.116.11 18.104.22.168 22.214.171.124 126.96.36.199 Ports: 5060 (UDP/TCP), 5061 (TLS)
188.8.131.52/26 184.108.40.206/24 Port Range: 10,000 to 20,000 (UDP)
220.127.116.11/30 which translates to: 18.104.22.168 22.214.171.124 126.96.36.199 188.8.131.52 Ports: 5060 (UDP/TCP), 5061 (TLS)
184.108.40.206/25 220.127.116.11/24 Port Range: 10,000 to 20,000 (UDP)
18.104.22.168/30 which translates to: 22.214.171.124 126.96.36.199 188.8.131.52 184.108.40.206 Ports: 5060 (UDP/TCP), 5061 (TLS)
220.127.116.11/26 18.104.22.168/24 Port Range: 10,000 to 20,000 (UDP)
22.214.171.124/30 which translates to: 126.96.36.199 188.8.131.52 184.108.40.206 220.127.116.11 Ports: 5060 (UDP/TCP), 5061 (TLS)
18.104.22.168/26 22.214.171.124/24 Port Range: 10,000 to 20,000 (UDP)
126.96.36.199/30 which translates to: 188.8.131.52 184.108.40.206 220.127.116.11 18.104.22.168 Ports: 5060 (UDP/TCP), 5061 (TLS)
22.214.171.124/26 126.96.36.199/24 Port Range: 10,000 to 20,000 (UDP)
188.8.131.52/30 which translates to: 184.108.40.206 220.127.116.11 18.104.22.168 22.214.171.124 Ports: 5060 (UDP/TCP), 5061 (TLS)
126.96.36.199/26 188.8.131.52/24 Port Range: 10,000 to 20,000 (UDP)