Passing a user specific token
Hi, I'm embedding a Vapi assistant widget in my UI and I'm going to use both mods - chat and voice (user is able to switch them via the UI toggle after which I mount the widget with the corresponding mode). In both mods the assistant should use a user-specific Bearer token when calling an API/MCP tool. Providing a static long-living token directly inside dashboard for the tools is not my use case as the tool suppose to return a user-specific data.
I tried to use my custom {{userToken}} variable and assistant-override property of the widget to pass this token from UI to Vapi
The assistant doesn't catch it and the request to the API tool is not working.
I'm providing an override property as it's suggested in documentation.
And it seems to work according to the network tab of the browser. The payload to the https://api.vapi.ai/chat/web is:
{
"assistantId": "20c771c...",
"assistantOverrides": {
"variableValues": {
"userToken": "eyJhb..."
}
},
"input": [...],
"stream": true
}
Inside the Dashboard, in the API Request tool I set the Bearer {{userToken}} value for an Authorization request header and added the following system prompt to the Assistant itself:
"You must use the {{userToken}} variable as a Bearer token value for Authorization request header when using backend tools and APIs."
However when I'm asking an assistant to show me the data it firstly asks to wait and later reports an "issue retrieving the data". When I'm providing a static access token directly in the dashboard ("Bearer eyh..") the tool works perfectly and the data is returned, so the issue is caused by the variable. In the logs of the dashboard I see that the assistant invokes the correct tool but there are no response displayed.
What might be an issue? Perhaps I'm doing something wrong?
I tried to use my custom {{userToken}} variable and assistant-override property of the widget to pass this token from UI to Vapi
The assistant doesn't catch it and the request to the API tool is not working.
I'm providing an override property as it's suggested in documentation.
And it seems to work according to the network tab of the browser. The payload to the https://api.vapi.ai/chat/web is:
{
"assistantId": "20c771c...",
"assistantOverrides": {
"variableValues": {
"userToken": "eyJhb..."
}
},
"input": [...],
"stream": true
}
Inside the Dashboard, in the API Request tool I set the Bearer {{userToken}} value for an Authorization request header and added the following system prompt to the Assistant itself:
"You must use the {{userToken}} variable as a Bearer token value for Authorization request header when using backend tools and APIs."
However when I'm asking an assistant to show me the data it firstly asks to wait and later reports an "issue retrieving the data". When I'm providing a static access token directly in the dashboard ("Bearer eyh..") the tool works perfectly and the data is returned, so the issue is caused by the variable. In the logs of the dashboard I see that the assistant invokes the correct tool but there are no response displayed.
What might be an issue? Perhaps I'm doing something wrong?



