Send 1000 Phone Calls

Learn how to send batch phone calls using our API

Send 1000 Phone Calls

This tutorial will guide you through sending batch phone calls using our API. You'll learn how to set up authorization, create prompts, and handle responses.

Step 1: Setup Your Authorization

To initiate a batch call, you must first authenticate your request. Ensure you have your API key from signing up on the developer portal.

Step 2: Create the Base Prompt

Craft a base prompt that will be common across all calls in the batch. Use placeholders {{curly braces}} for dynamic content.

Example:

'You are calling {{business}} to renew their subscription to {{service}} before it expires on {{date}}.';

Step 3: Define the Call Data

Specify the list of calls in the call_data array. Each call must have a phone_number and can include other properties corresponding to placeholders in your base prompt.

Example:

[
	{
		phone_number: '1234567890',
		business: 'ABC co.',
		service: 'Netflix',
		date: 'September 4th'
	},
	{
		phone_number: '32176540987',
		business: 'XYZ inc.',
		service: 'Window Cleaning',
		date: 'December 20th'
	}
];

Step 4: Additional Configuration

You can customize your batch calls with the following options:

  • label: Assign a label to your batch for easy tracking.
  • campaign_id: Organize related batches under a campaign.
  • test_mode: Set to true for testing with the first call only.
  • batch_id: Manually set or auto-generated for tracking.
  • Voice and Language Settings: Select voice_id, reduce_latency, and language.
  • request_data: Include specific facts for the AI to know during the call.
  • webhook: For real-time notifications and transcripts post-call.
  • max_duration: Define the maximum length of each call.
  • amd: Enable for navigating phone trees or leaving voicemails.
  • wait_for_greeting: Control if the AI speaks immediately or waits.

Step 5: Send the API Request

Use the provided JavaScript or Python code snippet to make the API request:

// Headers
const headers = {
	authorization: 'YOUR-API-KEY-HERE'
};

// Data
const data = {
	base_prompt:
		'You are calling {{business}} to renew their subscription to {{service}} before it expires on {{date}}.',
	call_data: [
		{
			phone_number: '1234567890',
			business: 'ABC co.',
			service: 'Netflix',
			date: 'September 4th'
		},
		{
			phone_number: '32176540987',
			business: 'XYZ inc.',
			service: 'Window Cleaning',
			date: 'December 20th'
		}
	],
	label: 'Renewal Reminder - Wednesday Afternoon with female voice',
	voice_id: 0,
	max_duration: 10,
	reduce_latency: true,
	wait_for_greeting: true
};

// API request
const response = await fetch('https://api.example.com/v1/batches', {
	method: 'POST',
	headers,
	body: JSON.stringify(data)
});

Step 6: Handle the Response

After sending the batch request, you'll receive a response with a message and the batch_id. Monitor the progress of your calls and any responses via your specified webhook.

Here's what an example response might look like:

{
	"message": "success",
	"batch_id": "3p$7rQ3p9sT5bzmF-gen-batch"
}

Step 7: Monitoring and Analytics

Track the performance and outcomes of your batch calls through the provided batch_id and campaign analytics. Adjust future batches based on the insights gained.

Best Practices

  • Always test with test_mode: true before sending large batches
  • Use descriptive labels to organize your batches
  • Monitor your webhook for real-time updates
  • Set appropriate max_duration limits to control costs
  • Use reduce_latency for faster response times when needed