Make your first call
This walkthrough places a call to your phone and reads a message to you. You need:
- an account and its Auth ID and Auth Secret (Authentication);
- a SIPRTC number, or a verified caller ID, to call from;
- a phone to call to.
export SIPRTC_AUTH_ID=MA0000000000000000AB # yoursexport SIPRTC_AUTH_SECRET=your-auth-secret1. Place the call with inline TinyML
Section titled “1. Place the call with inline TinyML”The quickest way to try voice is to send the call’s instructions with the
request. TinyML is SIPRTC’s XML call-control language; this document speaks a
sentence and hangs up.
curl -u "$SIPRTC_AUTH_ID:$SIPRTC_AUTH_SECRET" \ -H 'Content-Type: application/json' \ "https://api.siprtc.io/v1/Accounts/$SIPRTC_AUTH_ID/Calls" \ -d '{ "From": "+15550100001", "To": "+15550100002", "TinyML": "<Response><Say>Hello from SIPRTC. Goodbye.</Say><Hangup/></Response>" }'The response is the new call resource. Keep its call SID: you use it to change or end the call, and every callback about the call carries it.
2. Serve TinyML from your own URL
Section titled “2. Serve TinyML from your own URL”Real applications decide what to do at the moment the call connects. Instead of
TinyML, pass Url: SIPRTC requests that URL when the call is answered and
executes the TinyML your server returns.
curl -u "$SIPRTC_AUTH_ID:$SIPRTC_AUTH_SECRET" \ -H 'Content-Type: application/json' \ "https://api.siprtc.io/v1/Accounts/$SIPRTC_AUTH_ID/Calls" \ -d '{ "From": "+15550100001", "To": "+15550100002", "Url": "https://example.com/voice/answer", "StatusCallback": "https://example.com/voice/status" }'A minimal answer handler in Node.js:
import http from 'node:http';
http.createServer((req, res) => { if (req.url.startsWith('/voice/answer')) { res.writeHead(200, { 'Content-Type': 'application/xml' }); res.end(`<?xml version="1.0" encoding="UTF-8"?><Response> <Gather action="https://example.com/voice/menu" numDigits="1"> <Say>Press 1 for sales, or 2 for support.</Say> </Gather></Response>`); return; } res.writeHead(204).end();}).listen(8080);3. Receive incoming calls
Section titled “3. Receive incoming calls”To handle calls to your number, create an application whose voice URL points at your answer handler, and attach it to the number. SIPRTC then fetches TinyML from that URL for every inbound call.
Next steps
Section titled “Next steps”- Browse every verb in the TinyML reference.
- Stream the call’s live audio to your own server with media streaming.
- See every request parameter for creating a call.