Skip to main content

Voice Integration

Add voice calling capabilities to Linktor using providers like Twilio or Vonage. Build IVR systems, enable click-to-call, and integrate voice with your AI bots.

Overview​

The Voice integration enables you to:

  • Make and receive phone calls programmatically
  • Build interactive voice response (IVR) systems
  • Convert speech to text for AI processing
  • Generate dynamic text-to-speech responses
  • Record calls for quality assurance
  • Transfer calls to human agents
  • Handle conference calls

Prerequisites​

Before configuring Voice in Linktor, you'll need:

  1. Voice Provider Account: Twilio or Vonage account with voice capability
  2. Phone Number: A phone number with voice capability
  3. Webhook URL: Publicly accessible HTTPS endpoint

Supported Providers​

ProviderFeaturesBest For
TwilioFull-featured, global, STT/TTSEnterprise, global reach
VonageWebRTC support, competitive pricingWeb-based calling
PlivoAffordable, developer-friendlyCost-sensitive applications

Configuration in Linktor​

Twilio Voice Setup​

Step 1: Get Twilio Voice Credentials​

  1. Sign up at twilio.com
  2. From the Console, note your:
    • Account SID
    • Auth Token
  3. Buy a phone number with Voice capability
  4. Note the phone number

Step 2: Add Channel in Dashboard​

  1. Go to Settings → Channels in Linktor
  2. Click Add Channel and select Voice
  3. Choose Twilio as the provider
  4. Fill in the configuration:
FieldDescription
NameDisplay name (e.g., "Support Hotline")
Account SIDYour Twilio Account SID
Auth TokenYour Twilio Auth Token
Phone NumberYour Twilio voice number (E.164 format)
Default VoiceTTS voice (e.g., "Polly.Joanna")
Default LanguageSpeech recognition language
  1. Click Save to create the channel

Step 3: Configure Twilio Webhook​

  1. Go to Phone Numbers → Manage → Active Numbers
  2. Select your phone number
  3. Under Voice & Fax:
    • A Call Comes In: configure this only after exposing a voice inbound callback in your deployment
    • Call Status Changes: configure this only after exposing a voice status callback in your deployment

Vonage Voice Setup​

Step 1: Create Vonage Voice Application​

  1. Sign up at vonage.com
  2. Go to Applications and create a new application
  3. Enable Voice capability
  4. Set Answer URL and Event URL to your Linktor webhooks
  5. Generate and download the private key
  6. Link a phone number to the application

Step 2: Add Channel in Dashboard​

FieldDescription
NameDisplay name for this channel
Application IDYour Vonage Application ID
Private KeyYour Vonage private key content
Phone NumberYour Vonage voice number

API Usage​

Making Outbound Calls​

Basic Outbound Call​

import { Linktor } from '@linktor/sdk'

const client = new Linktor({ apiKey: 'YOUR_API_KEY' })

const call = await client.voice.calls.create({
channelId: 'ch_voice_123',
to: '+5511999999999',
flow: 'outbound_welcome' // IVR flow to execute
})

console.log(`Call initiated: ${call.id}, status: ${call.status}`)

Call with Custom TwiML/NCCO​

// Twilio TwiML
const call = await client.voice.calls.create({
channelId: 'ch_voice_123',
to: '+5511999999999',
twiml: `
<Response>
<Say voice="Polly.Joanna">Hello! This is a reminder about your appointment tomorrow at 3 PM.</Say>
<Gather input="speech dtmf" timeout="5" numDigits="1">
<Say>Press 1 to confirm, or 2 to reschedule.</Say>
</Gather>
</Response>
`
})

Call with Text-to-Speech​

const call = await client.voice.calls.create({
channelId: 'ch_voice_123',
to: '+5511999999999',
actions: [
{
action: 'say',
text: 'Hello! Your order has been shipped and will arrive tomorrow.',
voice: 'Polly.Joanna',
language: 'en-US'
},
{
action: 'say',
text: 'Press any key to repeat this message, or hang up.',
voice: 'Polly.Joanna'
},
{
action: 'gather',
input: ['dtmf'],
timeout: 10,
onGather: 'repeat_message'
}
]
})

Handling Inbound Calls​

IVR Flow Example​

Define an IVR flow that handles incoming calls:

// In your Linktor flow configuration
{
"name": "main_ivr",
"trigger": {
"type": "voice.inbound",
"channelId": "ch_voice_123"
},
"steps": [
{
"id": "welcome",
"action": "say",
"text": "Welcome to Acme Support. ",
"voice": "Polly.Joanna"
},
{
"id": "menu",
"action": "gather",
"input": ["dtmf", "speech"],
"timeout": 5,
"speechTimeout": "auto",
"hints": ["sales", "support", "billing"],
"prompt": {
"action": "say",
"text": "For sales, press 1 or say sales. For support, press 2 or say support. For billing, press 3 or say billing."
},
"onGather": "route_call"
},
{
"id": "route_call",
"action": "conditional",
"conditions": [
{
"if": "{{digits}} == '1' || {{speech}} contains 'sales'",
"then": "transfer_sales"
},
{
"if": "{{digits}} == '2' || {{speech}} contains 'support'",
"then": "transfer_support"
},
{
"if": "{{digits}} == '3' || {{speech}} contains 'billing'",
"then": "transfer_billing"
}
],
"default": "invalid_option"
},
{
"id": "transfer_sales",
"action": "dial",
"number": "+5511888888888",
"callerId": "{{channel.phoneNumber}}",
"timeout": 30,
"onNoAnswer": "voicemail"
}
]
}

Speech Recognition (STT)​

Gather Speech Input​

await client.voice.calls.update(callId, {
actions: [
{
action: 'say',
text: 'Please describe your issue after the beep.'
},
{
action: 'gather',
input: ['speech'],
speechTimeout: 'auto',
language: 'en-US',
hints: ['refund', 'shipping', 'product', 'account'],
onGather: async (result) => {
const transcription = result.speechResult
// Process with AI
const response = await processWithAI(transcription)
return {
action: 'say',
text: response
}
}
}
]
})

Text-to-Speech (TTS)​

Available Voices​

// List available voices
const voices = await client.voice.voices.list({
channelId: 'ch_voice_123',
language: 'en-US'
})

// Twilio Polly voices
// - Polly.Joanna (female, US)
// - Polly.Matthew (male, US)
// - Polly.Amy (female, UK)
// - Polly.Brian (male, UK)
// - Polly.Camila (female, Portuguese)

Using Different Voices​

await client.voice.calls.update(callId, {
actions: [
{
action: 'say',
text: 'Hello, this is your English assistant.',
voice: 'Polly.Joanna',
language: 'en-US'
},
{
action: 'say',
text: 'Ol\u00e1, sou sua assistente em portugu\u00eas.',
voice: 'Polly.Camila',
language: 'pt-BR'
}
]
})

Call Recording​

Enable Recording​

const call = await client.voice.calls.create({
channelId: 'ch_voice_123',
to: '+5511999999999',
record: true,
recordingStatusCallback: 'https://api.your-domain.com/your-voice-recording-callback',
flow: 'outbound_call'
})

Retrieve Recordings​

const recordings = await client.voice.recordings.list({
callId: call.id
})

recordings.forEach(recording => {
console.log(`Recording: ${recording.url}, duration: ${recording.duration}s`)
})

Call Transfer​

Warm Transfer​

await client.voice.calls.update(callId, {
actions: [
{
action: 'say',
text: 'Please hold while I transfer you to an agent.'
},
{
action: 'dial',
number: '+5511888888888',
callerId: '{{caller.number}}',
timeout: 30,
whisper: {
action: 'say',
text: 'Incoming call from {{caller.number}} regarding order issue.'
}
}
]
})

Cold Transfer​

await client.voice.calls.transfer(callId, {
to: '+5511888888888',
announce: 'Transferring to support team.'
})

AI Voice Bot Integration​

import { Linktor } from '@linktor/sdk'

const client = new Linktor({ apiKey: 'YOUR_API_KEY' })

// Handle incoming call with AI
client.voice.on('call.answered', async (call) => {
await client.voice.calls.update(call.id, {
actions: [
{
action: 'say',
text: 'Hello! I am your AI assistant. How can I help you today?'
},
{
action: 'gather',
input: ['speech'],
speechTimeout: 'auto',
onGather: async (result) => {
// Send to AI bot
const aiResponse = await client.bots.chat({
botId: 'bot_ai_123',
message: result.speechResult,
context: {
channel: 'voice',
callId: call.id,
caller: call.from
}
})

return {
action: 'say',
text: aiResponse.message
}
}
}
]
})
})

Webhook Events​

Call Events​

// Incoming call event
{
"event": "voice.call.incoming",
"data": {
"callId": "call_abc123",
"channelId": "ch_voice_123",
"direction": "inbound",
"from": "+5511999999999",
"to": "+5511888888888",
"status": "ringing",
"timestamp": "2024-01-15T10:30:00Z"
}
}

// Call answered
{
"event": "voice.call.answered",
"data": {
"callId": "call_abc123",
"status": "in-progress",
"answeredBy": "human", // or "machine"
"timestamp": "2024-01-15T10:30:05Z"
}
}

// Call completed
{
"event": "voice.call.completed",
"data": {
"callId": "call_abc123",
"status": "completed",
"duration": 125,
"recordingUrl": "https://...",
"timestamp": "2024-01-15T10:32:10Z"
}
}

DTMF Events​

{
"event": "voice.dtmf",
"data": {
"callId": "call_abc123",
"digits": "1",
"timestamp": "2024-01-15T10:30:15Z"
}
}

Webhook Setup​

Webhook URL Format​

Voice inbound callbacks are not exposed by the default API routes yet. Use a deployment-specific callback URL only if you add that route.

Webhook Security​

Twilio:

Vonage:

  • Validates JWT signature
  • Verify Authorization header

Common Issues and Troubleshooting​

"Call failed to connect"​

Possible causes:

  • Invalid phone number
  • Number not voice-capable
  • Carrier issues
  • Insufficient balance

Solution:

  • Verify number format (E.164)
  • Check number capabilities in provider dashboard
  • Test with different numbers
  • Check account balance

Poor Audio Quality​

Possible causes:

  • Network latency
  • Codec issues
  • TTS voice quality

Solution:

  • Use high-quality TTS voices (Polly Neural)
  • Check network connectivity
  • Use appropriate audio codecs

Speech Recognition Failures​

Possible causes:

  • Background noise
  • Accent not recognized
  • Wrong language configured

Solution:

  • Add speech hints for expected words
  • Use appropriate language model
  • Consider gathering DTMF as fallback

Webhook Timeout​

Possible causes:

  • Slow webhook response (>15 seconds for Twilio)
  • Complex processing

Solution:

  • Respond immediately with TwiML
  • Use async processing for complex logic
  • Implement proper caching

Recording Not Available​

Possible causes:

  • Recording not enabled
  • Call too short
  • Storage issues

Solution:

  • Verify recording is enabled
  • Check minimum duration requirements
  • Verify storage configuration

Best Practices​

  1. Always Identify Yourself: State who is calling at the start of outbound calls.

  2. Provide Options: Always give callers a way to reach a human.

  3. Handle Errors Gracefully: Have fallback flows for unrecognized input.

  4. Keep IVR Menus Short: Maximum 3-4 options per menu level.

  5. Use Appropriate Voices: Match voice gender, accent, and language to your audience.

  6. Record with Consent: Announce recording at the start of calls where required.

  7. Monitor Call Quality: Track metrics like answer rates, duration, and drop-offs.

  8. Test Regularly: Call your numbers regularly to verify they're working.

Compliance​

TCPA (US)​

  • Get prior express consent before calling
  • Honor Do Not Call requests
  • Follow calling hour restrictions (8am-9pm local)
  • Provide opt-out mechanism
  • One-party consent states: Only one party needs to consent
  • Two-party consent states: All parties must consent
  • Always announce recording to be safe

Rate Limits​

ProviderConcurrent CallsCalls per Second
TwilioBased on CPS1 CPS default (can increase)
VonageBased on account1 CPS default

Pricing Considerations​

Voice calls are billed by:

  • Per-minute rates: Varies by destination
  • Phone number rental: Monthly fee
  • Recording storage: Per minute stored
  • Transcription: Per minute transcribed

Next Steps​