Outbound Calls

Learn how to programmatically trigger outbound calls using Pinecall's API. This enables automated notifications, reminders, and proactive customer outreach with your AI agents.

bulk-calls.js
// Create a bulk campaign for multiple outbound calls
const campaign = await pinecall.campaigns.create({
name: 'Appointment Reminders - October 24',
agentId: 'agent_12345',
calls: [
{
to: '+15551234567',
agentContext: { customerName: 'John Smith', appointmentTime: '2023-10-24T14:00:00Z' },
metadata: { customerId: 'cust_001', appointmentId: 'apt_123' }
},
{
to: '+15559876543',
agentContext: { customerName: 'Jane Doe', appointmentTime: '2023-10-24T15:30:00Z' },
metadata: { customerId: 'cust_002', appointmentId: 'apt_124' }
},
// Add more recipients as needed
],
// Optional: Define common settings for all calls in this campaign
callSettings: {
from: '+15551112222', // Use the same caller ID for all calls
initialMessage: 'Hello, this is ABC Dental calling to confirm your appointment...',
maxAttempts: 2, // Try twice if the first call fails
attemptSpacing: 30, // Wait 30 minutes between attempts
callWindowSettings: {
timezone: 'America/New_York',
startTime: '09:00',
endTime: '18:00',
daysOfWeek: [1, 2, 3, 4, 5]
}
}
});
console.log(`Campaign created with ID: ${campaign.id}, containing ${campaign.calls.length} calls`);

Managing Active Calls

Once calls are initiated, you can monitor and manage them:

manage-calls.js
// Get information about a specific call
const call = await pinecall.calls.get('call_12345');
console.log(`Call status: ${call.status}`);
// Get call events and transcripts
const events = await pinecall.calls.events('call_12345');
events.forEach(event => {
if (event.type === 'speech') {
console.log(`${event.speaker}: ${event.text}`);
}
});
// End an active call
await pinecall.calls.terminate('call_12345');

Call Status Webhook Events

Receive real-time updates about your outbound calls by configuring webhooks:

webhook-events.json
// call.initiated event
{
"event": "call.initiated",
"timestamp": "2023-10-23T14:30:00Z",
"data": {
"callId": "call_12345",
"direction": "outbound",
"to": "+15551234567",
"from": "+15559876543",
"agentId": "agent_12345",
"metadata": { "customerId": "cust_001" }
}
}
// call.answered event
{
"event": "call.answered",
"timestamp": "2023-10-23T14:30:15Z",
"data": {
"callId": "call_12345",
"duration": 0
}
}
// call.completed event
{
"event": "call.completed",
"timestamp": "2023-10-23T14:35:20Z",
"data": {
"callId": "call_12345",
"duration": 305,
"outcome": "completed",
"agentSummary": "Customer confirmed their appointment for tomorrow at 2pm."
}
}

Best Practices

  • Respect time zones - Use call windows to ensure calls are only made during appropriate business hours in the recipient's time zone.
  • Keep it concise - Start with a clear introduction and purpose. Avoid long initial messages that might cause users to hang up.
  • Provide context - Always give your agent sufficient context about the call's purpose and the recipient.
  • Test thoroughly - Always test outbound calls with internal numbers before launching campaigns to customers.
  • Monitor and analyze - Track call outcomes and adjust your agent's prompts based on successful interactions.

Next Steps

Now that you understand outbound calls, you can: