Unable to use dynamic variables in transfer_call ...
# support
d
I’m integrating the transfer_call tool in an automated flow and need to include dynamic variables in the headers (for example id_registro, id_campania, etc.) to pass context to the receiving agent. The issue is that the system only allows static values, and I haven’t found a way to inject variables dynamically from the flow (e.g. {{input.id_registro}} or {{context.variable}}). Is there any way or workaround to make headers dynamic within the transfer_call call? If not currently supported, would you recommend an alternative approach (for instance, passing data via sipUri parameters or metadata)?
v
You can achieve dynamic SIP headers in
transfer_call
by using a webhook to set the headers at transfer time. In your webhook handler, extract the dynamic variables from the request context and inject them into the SIP headers before responding. For example:
Copy code
js
// Node.js/Express example
app.post('/webhook', (req, res) => {
  const { id_registro, id_campania } = req.body.context || {};
  res.json({
    destination: {
      type: "number",
      number: "+1234567890",
      transferPlan: {
        sipHeadersInReferToEnabled: true,
        sipHeaders: {
          "x-id_registro": id_registro,
          "x-id_campania": id_campania
        }
      }
    }
  });
});
This lets you pass dynamic context to the receiving agent via SIP headers at transfer time. See the [dynamic transfers documentation](https://docs.vapi.ai/calls/call-dynamic-transfers) for more details. Sources: - [Dynamic call transfers documentation](https://docs.vapi.ai/calls/call-dynamic-transfers) - [Changelog: SIP headers in Refer-To URI](https://docs.vapi.ai/changelog/2025/4/29)
v
I can help you with this, I’ve worked on dynamic variable passing in Vapi flows before. At the moment, transfer_call headers only support static values, but there are solid workarounds. You can append your variables as query parameters in the sipUri or route the transfer through a small middleware API that injects them dynamically. This way, the receiving agent still gets full context. Are you triggering the transfer from a Vapi flow or directly through the API? @DDX
d
I understand your point - the native "Transfer Call" tool only allows static headers in the UI. But I'm using a different approach: I created a custom async function called transfer_to_agent with a webhook. When the assistant calls this function, my webhook receives the call data and returns the SIP destination with dynamic headers based on that data: ` json{ "destination": { "type": "sip", "sipUri": "sip:1234@myserver.example.com", "transferPlan": { "sipHeadersInReferToEnabled": true, "sipHeaders": { "X-Id-Registro": "241", // ← Dynamic value from call data "X-Id-Campania": "751" // ← Dynamic value from call data } } } }``
The tool test shows Status 200, so VAPI accepts this response format. Have you tried this pattern before? Using a custom function (not the native Transfer Call tool) to return dynamic transfer destinations via webhook?
v
That’s a really smart setup using a custom async function with a webhook is the right way to get around the static header limitation. I’ve used this approach before and it works great for passing dynamic call data smoothly. There are a few tweaks you can make to make it even more stable and flexible. Let’s chat more in private, I can walk you through some best practices to make it run perfectly. @DDX
c
Thanks for clarifying your use case — you’re on the right track with wanting dynamic SIP headers. Right now the Transfer Call tool UI only supports static headers, but there is a supported way to handle this dynamically: Transfer Destination Request The Transfer Destination Request is Vapi's built-in mechanism for dynamic transfers. Instead of using static headers, you configure your transfer tool to call a webhook on your server, which then returns the transfer destination and headers dynamically. Example transfer tool setup:
Copy code
{
  "type": "transferCall",
  "destinations": [
    {
      "type": "assistantDestination",
      "transferPlan": {
        "type": "request",
        "url": "https://your-server.com/transfer-destination",
        "method": "POST"
      }
    }
  ]
}
Your server response could look like:
Copy code
{
  "destination": {
    "type": "sipDestination",
    "sipUri": "sip:agent@your-domain.com",
    "headers": {
      "X-id-registro": "{{dynamicValue1}}",
      "X-id-campania": "{{dynamicValue2}}",
      "X-context": "{{anyContextData}}"
    }
  }
}
Key Benefits - Your webhook receives the full call context (conversation history, variables, etc.) - You can compute headers dynamically in real time - Full control over routing logic and SIP metadata In short: using the Transfer Destination Request webhook is the cleanest and most flexible way to get dynamic headers into your transfer call flow.
2 Views