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>
:
1<?xml version="1.0" encoding="UTF-8"?>2<Response>3<Start>4<Siprec connectorName="my_addon_connector" />5</Start>6</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 can only be configured within the 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.
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.
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 |
track | Optional. inbound_track , outbound_track , both_tracks | both_tracks |
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
.
1<Start>2<Siprec name="my_first_siprec_stream" connectorName="my_addon_connector" />3</Start>
You can later use the unique name
of my_first_siprec_stream
to stop the stream.
1<Stop>2<Siprec name="my_first_siprec_stream" />3</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.
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
If you'd like to use a specific partner and don't find them in the available Stream Connectors list, contact Twilio Support directly with details about your desired partner through the Console or Help Center 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 and outbound media event.
SIPREC partners often require additional metadata along with the audio stream. You can provide custom data by using <Parameter>
1<Start>2<Siprec name="my_stream_1" connectorName="Gridspace_1" track="outbound_track">3<Parameter name="Custom1" value ="Bob" />4<Parameter name="Custom2" value ="Blah" />5<Parameter name="Custom3" value ="Alice" />6</Siprec>7</Start>
The exact names of parameters vary from partner to partner. 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
.
1const VoiceResponse = require('twilio').twiml.VoiceResponse;23const response = new VoiceResponse();4const start = response.start();5start.siprec({6name: 'My SIPREC Stream',7connectorName: 'Gridspace_1'8});910console.log(response.toString());
1<?xml version="1.0" encoding="UTF-8"?>2<Response>3<Start>4<Siprec name="My SIPREC Stream" connectorName="Gridspace_1" />5</Start>6</Response>
To receive SIPREC streams from Twilio, ensure to include the following regions in your allow list (IP address whitelist).
Signaling IPs:
154.172.60.0/30 which translates to:254.172.60.0354.172.60.1454.172.60.2554.172.60.36Ports: 5060 (UDP/TCP), 5061 (TLS)7
Media IPs:
154.172.60.0/23234.203.250.0/233Port Range: 10,000 to 20,000 (UDP)4
Signaling IPs:
154.244.51.0/30 which translates to:254.244.51.0354.244.51.1454.244.51.2554.244.51.36Ports: 5060 (UDP/TCP), 5061 (TLS)7
Media IPs:
154.244.51.0/242Port Range: 10,000 to 20,000 (UDP)3
Signaling IPs:
154.171.127.192/30 which translates to:254.171.127.192354.171.127.193454.171.127.194554.171.127.1956Ports: 5060 (UDP/TCP), 5061 (TLS)7
Media IPs:
154.171.127.192/26252.215.127.0/243Port Range: 10,000 to 20,000 (UDP)4
Signaling IPs:
135.156.191.128/30 which translates to:235.156.191.128335.156.191.129435.156.191.130535.156.191.1316Ports: 5060 (UDP/TCP), 5061 (TLS)7
Media IPs:
135.156.191.128/2523.122.181.0/243Port Range: 10,000 to 20,000 (UDP)4
Signaling IPs:
154.65.63.192/30 which translates to:254.65.63.192354.65.63.193454.65.63.194554.65.63.1956Ports: 5060 (UDP/TCP), 5061 (TLS)7
Media IPs:
154.65.63.192/2623.112.80.0/243Port Range: 10,000 to 20,000 (UDP)4
Signaling IPs:
154.169.127.128/30 which translates to:254.169.127.128354.169.127.129454.169.127.130554.169.127.1316Ports: 5060 (UDP/TCP), 5061 (TLS)7
Media IPs:
154.169.127.128/2623.1.77.0/243Port Range: 10,000 to 20,000 (UDP)4
Signaling IPs:
154.252.254.64/30 which translates to:254.252.254.64354.252.254.65454.252.254.66554.252.254.676Ports: 5060 (UDP/TCP), 5061 (TLS)7
Media IPs:
154.252.254.64/2623.104.90.0/243Port Range: 10,000 to 20,000 (UDP)4
Signaling IPs:
1177.71.206.192/30 which translates to:2177.71.206.1923177.71.206.1934177.71.206.1945177.71.206.1956Ports: 5060 (UDP/TCP), 5061 (TLS)7
Media IPs:
1177.71.206.192/26218.228.249.0/243Port Range: 10,000 to 20,000 (UDP)4