Forward calls to Synthflow

You can start a call from your own telephony system (e.g., Asterisk) and seamlessly transfer it to a Synthflow AI agent after the customer answers. This is useful if you want to handle your own voicemail detection or apply custom logic before handing off to the AI.

You can also pass custom variables into the conversation.

Call flow


Prerequisites

  • You must have an inbound Synthflow agent already set up and active.
  • You need a valid Synthflow API token.

Step 1: Prepare the inbound call in Synthflow

Before transferring the call, you must prepare it in Synthflow by making a POST request to:

POST /v2/prepare_inbound

Headers

1{
2 "Content-Type": "application/json",
3 "Authorization": "Bearer {YOUR_API_TOKEN}"
4}

Body

1{
2 "from_number": "+1234567890",
3 "to_number": "+1987654321",
4 "model_id": "your-model-id",
5 "workspace_id": "your-workspace-id",
6 "custom_variables": {
7 "customer_name": "John Doe",
8 "account_id": "A12345"
9 }
10}

Response: This request returns a Synthflow Call ID that you’ll use in the next step.


Step 2: Transfer the live call to Synthflow

Once your call is connected to the customer (and your custom logic has completed), you can transfer the call to Synthflow via SIP.

Asterisk example

1same => n,Set(PJSIP_HEADER(add,X-EI)=<SYNTHFLOW_CALL_ID>)
2same => n,Transfer(SIP/<NUMBER>@sipin.synthflow.ai:32681)
  • Replace <SYNTHFLOW_CALL_ID> with the ID you received from the /v2/prepare_inbound API call.
  • Replace <NUMBER> with the number associated with your inbound Synthflow AI Agent.

This will initiate a SIP INVITE to Synthflow, carrying the context of the original call.


Notes

  • The header X-EI must include the Synthflow Call ID.
  • The SIP transfer should only occur after the customer has answered the call.
  • The destination number must be linked to an active Synthflow AI agent.