Creating a V2 agent via API
This guide walks you through the process of creating a V2 agent using the SynthFlow API. The setup consists of three primary steps:
- Creating a custom phone number
- Creating the agent and linking it to the phone number
- Dialing to the SIP Endpoint
API Base URL: https://api.synthflow.ai
Step 1: Create a Custom Phone Number
Endpoint:
POST /v2/custom-numbers
Headers:
Request Body:
trunk_username
andtrunk_pwd
are optional and can be omitted unless required for your configuration.
Step 2: Create a V2 agent
This step registers a V2 agent and links it to the custom phone number created in Step 1. Ensure the phone number is successfully created before proceeding.
Endpoint:
POST /v2/agents
Headers:
Request Body:
For additional fields and configurations, refer to the official API documentation.
Final Step: Configure Twilio
After the trunk is set up on SynthFlow, redirect Twilio calls to it using TwiML commands. Be sure to include the GHL unique call ID or Twilio Call SID in the SIP header using the X-EI
key.
Here’s a code snippet for redirecting a call:
Pre-Actions with Custom Variables
You can use Pre-Actions to fetch custom variables via API and incorporate them into the agent prompt for more personalized responses by using the <twilio_call_sid> verb in API request.
Note: The transfer call will work the same as before.