Skip to contentSkip to navigationSkip to topbar
Rate this page:
On this page

TwiML™️ Voice: <Siprec>


The <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 <Siprec>:


_10
<?xml version="1.0" encoding="UTF-8"?>
_10
<Response>
_10
<Start>
_10
<Siprec connectorName="my_addon_connector" />
_10
</Start>
_10
</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.

(information)

Info

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.

(warning)

Warning

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(link takes you to an external page).
For example, sip:srs@foo.com:5060;edge=dublin would egress from the Dublin edge, and sip:srs@foo.com:5060;edge=umatilla would egress from Oregon.

(information)

Info

Any communication issues encountered while streaming media to the partner will be reported in the Twilio Debugger with additional information about the failure.

(warning)

Warning

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.


Attributes

attributes page anchor

<Siprec> supports the following attributes:

Attribute NameAllowed ValuesDefault Value
nameOptional. Unique name for the Streamnone
connectorNameUnique name used when configuring the connector via Marketplace Add-on.Default
trackOptional. inbound_track, outbound_track, both_tracksboth_tracks

name

attributes-name page anchor

Providing a name will allow you to reference the SIPREC stream directly. This name must be unique per Call SID.

For instance by naming the Stream my_first_siprec_stream.


_10
<Start>
_10
<Siprec name="my_first_siprec_stream" connectorName="my_addon_connector" />
_10
</Start>

You can later use the unique name of my_first_siprec_stream to stop the stream.


_10
<Stop>
_10
<Siprec name="my_first_siprec_stream" />
_10
</Stop>

The 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 connectorName="Gridspace_1", where 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.

(information)

Info

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:

sip:your-domain.com;secure=true&edge=ashburn

(information)

Info

If you'd like to use a specific partner and do not find them in the available Stream Connectors list, please contact Twilio Support directly with details about your desired partner through the Console(link takes you to an external page) or Help Center(link takes you to an external page) to submit a ticket.

The 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. If both_tracks is used, you will receive both the inbound media event and outbound media event.


Passing Custom Parameters

passing-custom-parameters page anchor

SIPREC partners often require additional metadata along with the audio stream. You can provide custom data by using <Parameter>


_10
<Start>
_10
<Siprec name="my_stream_1" connectorName="Gridspace_1" track="outbound_track">
_10
<Parameter name="Custom1" value ="Bob" />
_10
<Parameter name="Custom2" value ="Blah" />
_10
<Parameter name="Custom3" value ="Alice" />
_10
</Siprec>
_10
</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 Gridspace_1.

Start a new SIPREC Stream

start-a-new-siprec-stream page anchor
Node.js
Python
C#
Java
PHP
Ruby

_10
const VoiceResponse = require('twilio').twiml.VoiceResponse;
_10
_10
const response = new VoiceResponse();
_10
const start = response.start();
_10
start.siprec({
_10
name: 'My SIPREC Stream',
_10
connectorName: 'Gridspace_1'
_10
});
_10
_10
console.log(response.toString());

Output

_10
<?xml version="1.0" encoding="UTF-8"?>
_10
<Response>
_10
<Start>
_10
<Siprec name="My SIPREC Stream" connectorName="Gridspace_1" />
_10
</Start>
_10
</Response>


To receive SIPREC streams from Twilio, please ensure to include the following regions in your allow list (IP address whitelist).

North America Virginia Gateways

north-america-virginia-gateways page anchor

Signaling IPs:


_10
54.172.60.0/30 which translates to:
_10
54.172.60.0
_10
54.172.60.1
_10
54.172.60.2
_10
54.172.60.3
_10
Ports: 5060 (UDP/TCP), 5061 (TLS)

Media IPs:


_10
54.172.60.0/23
_10
34.203.250.0/23
_10
Port Range: 10,000 to 20,000 (UDP)

North America Oregon Gateways

north-america-oregon-gateways page anchor

Signaling IPs:


_10
54.244.51.0/30 which translates to:
_10
54.244.51.0
_10
54.244.51.1
_10
54.244.51.2
_10
54.244.51.3
_10
Ports: 5060 (UDP/TCP), 5061 (TLS)

Media IPs:


_10
54.244.51.0/24
_10
Port Range: 10,000 to 20,000 (UDP)

Signaling IPs:


_10
54.171.127.192/30 which translates to:
_10
54.171.127.192
_10
54.171.127.193
_10
54.171.127.194
_10
54.171.127.195
_10
Ports: 5060 (UDP/TCP), 5061 (TLS)

Media IPs:


_10
54.171.127.192/26
_10
52.215.127.0/24
_10
Port Range: 10,000 to 20,000 (UDP)

Europe Frankfurt Gateways

europe-frankfurt-gateways page anchor

Signaling IPs:


_10
35.156.191.128/30 which translates to:
_10
35.156.191.128
_10
35.156.191.129
_10
35.156.191.130
_10
35.156.191.131
_10
Ports: 5060 (UDP/TCP), 5061 (TLS)

Media IPs:


_10
35.156.191.128/25
_10
3.122.181.0/24
_10
Port Range: 10,000 to 20,000 (UDP)

Asia-Pacific Tokyo Gateways

asia-pacific-tokyo-gateways page anchor

Signaling IPs:


_10
54.65.63.192/30 which translates to:
_10
54.65.63.192
_10
54.65.63.193
_10
54.65.63.194
_10
54.65.63.195
_10
Ports: 5060 (UDP/TCP), 5061 (TLS)

Media IPs:


_10
54.65.63.192/26
_10
3.112.80.0/24
_10
Port Range: 10,000 to 20,000 (UDP)

Asia-Pacific Singapore Gateways

asia-pacific-singapore-gateways page anchor

Signaling IPs:


_10
54.169.127.128/30 which translates to:
_10
54.169.127.128
_10
54.169.127.129
_10
54.169.127.130
_10
54.169.127.131
_10
Ports: 5060 (UDP/TCP), 5061 (TLS)

Media IPs:


_10
54.169.127.128/26
_10
3.1.77.0/24
_10
Port Range: 10,000 to 20,000 (UDP)

Asia-Pacific Sydney Gateways

asia-pacific-sydney-gateways page anchor

Signaling IPs:


_10
54.252.254.64/30 which translates to:
_10
54.252.254.64
_10
54.252.254.65
_10
54.252.254.66
_10
54.252.254.67
_10
Ports: 5060 (UDP/TCP), 5061 (TLS)

Media IPs:


_10
54.252.254.64/26
_10
3.104.90.0/24
_10
Port Range: 10,000 to 20,000 (UDP)

South America São Paulo Gateways

south-america-são-paulo-gateways page anchor

Signaling IPs:


_10
177.71.206.192/30 which translates to:
_10
177.71.206.192
_10
177.71.206.193
_10
177.71.206.194
_10
177.71.206.195
_10
Ports: 5060 (UDP/TCP), 5061 (TLS)

Media IPs:


_10
177.71.206.192/26
_10
18.228.249.0/24
_10
Port Range: 10,000 to 20,000 (UDP)


Rate this page: