correct-apricot
correct-apricot3mo ago

how to pass custom variables when I call workflow

Hi all, how can I pass custom variables to workflow through HTTP request? I've tried different approaches This approach is not accepted when I call workflow "assistantOverrides": { "variableValues": { "name": "John" } This doesn't throw an error but the assistant doesn't get the variables in metadata and they just read the variables name. { "type": "outboundPhoneCall", "workflowId": "asdfdsafd", "phoneNumberId": "fdsafdsafdsa", "customer": { "number": "{{ $node['Recruiter with Phone Number?'].json.message.content.phoneNumber }}" }, "metadata": { "messageID": "{{ $node['Get a message'].json.id }}", "recruiterName": "{{ $node['Recruiter with Phone Number?'].json.message.content.recruiterName }}", "emailSummary": "{{ $node['Recruiter with Phone Number?'].json.message.content.Summary }}" } } I made sure that the variable names are identical. Any idea how to approach it? #support #office-hours #general-english
10 Replies
rising-crimson
rising-crimson3mo ago
Pass custom variables via assistantOverrides.variableValues in your HTTP request, not metadata, then use {{variableName}} in your workflow prompts..
rising-crimson
rising-crimson3mo ago
Variables | Vapi
Personalize assistant messages with dynamic and default variables
correct-apricot
correct-apricotOP3mo ago
I've tried that, the problem is that I don't call assisstant but the workflow, That message with assistantOverrides.variableValues errors out
rising-crimson
rising-crimson3mo ago
You can’t pass custom variables to a workflow directly only assistant calls support assistantOverrides.variableValues, so use an assistant to inject variables before routing to the workflow..
evolutionary-blush
evolutionary-blush3mo ago
i'm having the same issue, i can pass things like customer.name works fine but any variables passed in the assistantOverrides and variableValues aren't being picked up in the workflow, the agent is just reading the variable names Im posting to api.vapi.ai/campaign with a body of{ "name": "Q2 Sales Campaign", "phoneNumberId": "0592481e-5f55-4307-8422-redacted", "workflowId":"e6b05790-8be4-4b77-8e4b-redacted", "customers": [ { "name":"Johnson the Fourth", "number":"+redacted", "assistantOverrides":{ "variableValues":{ "id2":"Wooly", "specific.product":"Beef Burgers", "id22":"Big Jumpers" } } } ] } and the worflow in the introduction node first message i have "Hello, this is Morgan from GrowthPartners. Do you have a few minutes to chat about how we might be able to help your business? Am i right in saying your name is {{customer.name}}? We do {{specific.product}} and {{id22}}." trying to test it extracting these variables. It Uses customer.name perfectly everytime.
Shubham Bajaj
Shubham Bajaj3mo ago
Variables only work if passed via workflowOverrides.variableValues in a webhook response or assistantOverrides.variableValues when starting from an assistant, direct workflow calls can't use dynamic variables yet..
evolutionary-blush
evolutionary-blush3mo ago
I see, thank you. So what is the point in workflowOverrides.variableValues then if you can't use dynamic variables? And what's the workaround for this? i know you used to be able to make assistants that use workflows but i can't understand how to do this since recent updates. thanks again!
rising-crimson
rising-crimson3mo ago
workflowOverrides.variableValues only works when routing from an assistant via webhook; to use dynamic variables, start with an assistant using assistantOverrides, then redirect to a workflow..
evolutionary-blush
evolutionary-blush2mo ago
Hi to anyone here, i fixed this issue just by having an API tool make a call home to retrieve the information and submitting the externalId variable to declare the ID for this call for when the tool calls home for all the variables it needs.
rising-crimson
rising-crimson2mo ago
Glad it fixed

Did you find this page helpful?