Learn how to programmatically trigger outbound calls using Pinecall's API. This enables automated notifications, reminders, and proactive customer outreach with your AI agents.
// Create a bulk campaign for multiple outbound callsconst 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`);
Once calls are initiated, you can monitor and manage them:
// Get information about a specific callconst call = await pinecall.calls.get('call_12345');console.log(`Call status: ${call.status}`);
// Get call events and transcriptsconst events = await pinecall.calls.events('call_12345');events.forEach(event => { if (event.type === 'speech') { console.log(`${event.speaker}: ${event.text}`); }});
// End an active callawait pinecall.calls.terminate('call_12345');
Receive real-time updates about your outbound calls by configuring webhooks:
// 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." }}
Now that you understand outbound calls, you can: