Digital Samba supports SIP/PSTN telephony integration allowing phone callers to join rooms. This guide explains how to build a custom telephony integration using any SIP/Voice API provider.
How It Works
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ Phone Callers │────▶│ Your Voice │────▶│ Digital Samba │
│ (PSTN) │ │ API Provider │ │ Room │
└─────────────────┘ └─────────────────┘ └─────────────────┘
│
│ SIP Connection
▼
┌─────────────────┐
│ Your Middleware│
│ Application │
└─────────────────┘
The integration consists of:
Voice API Provider - Handles phone calls, IVR prompts, and PSTN conferencing (e.g., Twilio, Sinch, Vonage, Plivo)
SIP Trunk - Connects your Voice API to Digital Samba
Middleware Application - Routes calls, manages PINs, and synchronises state between your Voice API and Digital Samba
Digital Samba Room - Video conferencing room with telephony enabled
Prerequisites
Before starting your integration:
Digital Samba Account with API access
Voice API Provider Account with:
A phone number for incoming calls
Voice/conferencing API access
SIP trunking capability
SIP Trunk Configuration - Contact Digital Samba support to configure IP whitelisting and authentication for your SIP trunk
Important: Before proceeding with implementation, contact Digital Samba support to set up your SIP trunk. Provide your SIP provider details and we will guide you through IP whitelisting and authentication configuration.
Architecture Overview
System Components
Call Flow Sequence
Step 1: Configure Digital Samba Room
Create a Telephony-Enabled Room
When creating a room via the API, include the telephony configuration:
Telephony Room Properties
Property
Type
Description
telephony_enabled
boolean
Enable telephony for this room
telephony_phone_number
string
The phone number for SIP to dial into your Voice API conference
telephony_pin_dtmf
string
DTMF sequence for SIP to enter when connecting to the conference
DTMF Sequence Format
The telephony_pin_dtmf field uses special characters:
Character
Meaning
W
Wait 1 second (for IVR prompts)
w
Wait 0.5 seconds
0-9
Dial digit
*
Dial asterisk
#
Dial pound/hash (often used as terminator)
Example: WWW123# means:
Wait 3 seconds for IVR prompt
Dial 123
Press # to confirm
Step 2: Build Your Middleware Application
Your middleware application handles communication between your Voice API provider and Digital Samba.
Core Responsibilities
Handle incoming calls from your Voice API provider
Play IVR prompts and collect PIN input
Route callers to the correct conference based on PIN
Manage SIP connection to Digital Samba room
Synchronise phone user state with Digital Samba API
Handle webhooks from both Voice API and Digital Samba
Conference and PIN Management
Your application must maintain a mapping between:
Digital Samba room IDs
Voice API conference IDs
PINs for phone callers
PINs for SIP bridge connections
Important: Voice API providers do not have inherent knowledge of conferences until you create them. You must build your own database and logic to:
Generate and assign PINs
Map PINs to conferences
Route callers based on PIN input
Example PIN Structure
Identifying the SIP Connection
When the SIP bridge connects to your Voice API conference, you must identify it distinctly from regular phone callers. Common approaches:
Reserved PIN - Use a specific PIN only for SIP connections
Display Name - Check for a specific display name (e.g., starts with "SIP")
Origination Type - Check call metadata for SIP origin
Domain - Check if domain equals "SIP"
Critical: Do NOT notify Digital Samba when the SIP bridge joins. The SIP connection is not a "real" phone user—it's the audio bridge between your Voice API conference and the Digital Samba room.
Step 3: Digital Samba Phone User API
Notify When Phone Users Join
When a phone caller successfully joins your Voice API conference (after PIN validation and only after SIP is connected), notify Digital Samba:
Request Parameters
Parameter
Type
Required
Description
callId
string
Yes
Unique identifier for this phone call (from your Voice API)
name
string
No
Display name for the phone user
callerNumber
string
No
Phone number of the caller
externalId
string
No
Your internal user identifier
Note: The externalId parameter is reserved for future functionality. It may be used to link phone participants with web participants who share the same external ID.
Notify When Phone Users Leave
When a phone caller disconnects:
Raise Hand for Phone User
Lower Hand for Phone User
Step 4: Configure Digital Samba Webhooks
Set up webhooks to receive events from Digital Samba rooms. This enables you to synchronise actions (like mute/unmute) with your Voice API.
Create a Webhook
Relevant Webhook Events
Event
Description
participant_joined
Triggered when any participant (web or phone) joins
participant_left
Triggered when any participant leaves
session_started
Triggered when a room session begins
session_ended
Triggered when a room session ends
Webhook Security
Always validate that webhook requests are legitimately from Digital Samba by checking the Authorization header matches your configured secret.
Step 5: Initiate SIP Connection
When a moderator in the Digital Samba room clicks "Connect Telephony" (requires the "Manage phone users" permission), Digital Samba initiates a SIP call to your Voice API.
What Happens
Digital Samba's SIP server calls the configured telephony_phone_number
Your Voice API answers and plays IVR
SIP sends the telephony_pin_dtmf sequence
Your application routes SIP to the correct conference
Room audio is now bridged to the PSTN conference
Important Timing
Moderators should connect telephony early in the session if phone users are expected
Phone users who call before SIP is connected will be in the Voice API conference but won't hear room audio
Only notify Digital Samba of phone users after SIP has connected
Step 6: Managing Phone Users in Room
Once connected, phone users appear in the Digital Samba participant list. Moderators can:
See phone users in the participants panel
Mute/unmute phone users via the menu
Remove phone users from the room
Handling Mute/Unmute
When a moderator mutes a phone user in Digital Samba, you'll receive a webhook. Your middleware should then call your Voice API to mute that participant in the PSTN conference.
Integration Checklist
Before Development
[ ] Contact Digital Samba support to configure SIP trunk
[ ] Set up Voice API provider account with phone number
[ ] Understand your Voice API's webhook/callback structure
[ ] Plan your PIN/conference management strategy
Development
[ ] Create rooms with telephony enabled via API
[ ] Build middleware to handle Voice API callbacks
[ ] Implement IVR flow for PIN collection
[ ] Build PIN validation and conference routing
[ ] Integrate Digital Samba Phone User API
[ ] Set up webhook handlers for Digital Samba events
[ ] Implement mute/unmute synchronisation
Testing
[ ] Test phone dial-in flow end-to-end
[ ] Verify SIP connection with correct PIN/DTMF
[ ] Confirm phone users appear in Digital Samba room
// Example mute handler
function handleMuteEvent(event) {
if (event.type === 'phone_participant_muted') {
const callId = event.data.callId;
// Call your Voice API to mute this participant
voiceApi.muteParticipant(callId);
}
}