Issue with VAPI custom function implementation
# support
n
Hi. I am trying to develop a simple vapi AI assistant that can check the ticket booking status of a user and inform them if it is confirmed or not confirmed or waiting list. So just to understand the basic functionality, I created a mock database with PNR number and status given as an array. I created a server with a function that takes the pnr number given by the user and returns the status as per the mock database. I am working with node and express. In vapi, I am tring to implement this using the function in tools. As per the format they have given I have added all the necessary parameters , headers, deloyed server url etc. I have also completed the code according to the vapi documentation provided for custom functions. When I test the tool using the test tool option provided inside the tool itself, I am getting the output correctly. It shows status code 200 as success. But when I create an assistant and add this tool and when I interact with the assistant by giving a certain pnr number which is already there in the mock database that I created, it just shows : check_pnr_tool Success. How can I resolve this? The code is working properly when I test it manually with postman and vapi tool test as well, but when it comes to interacting with live assistant, I am not really sure what the issue is. Can someone please help me with this.
s
Hi, is there a call id attached to your tests that you can give us to investigate?
n
The call id from the call logs for one of my test calls is 79dd372e-2e40-41b7-b25a-de9bf8763a26
k
Looking into it
n
Okay
s
Can you also provide screenshots of the results from vapi test tool and postman? I am currently investigating the logs but would like some more information
s
In your call, it seems like it was able to fetch the data from the database. Was the ticket status for that particular number incorrect when the assistant said 'the ticket was confirmed'? What is the desired output you are trying to achieve?
n
For any ticket number that I give, the assistant replies as 'the ticket is confirmed' . As per the database that I created, all tickets are not in a confirmed status. I have given not confirmed, waiting list and cancelled as well. So when I ask the assistant regarding a ticket number that is in the waiting list or that is cancelled or not confirmed, it does not respond with the correct output as per the database I have given. It just says that the ticket is confirmed. Whereas when I test it in postman or vapi tool test, it does give the correct output.
s
Thats a cool system you have running. So you've done all the hard work and you're almost there. So basically you have everything set up perfectly on your end. Now its on Vapi to grab that info and say it to the user. I think this is a simple fix with the promping of the agent. Especially if its working correctly with the test tool option. So in your prompt try to be very specific about directions on how to handle this. What’s happening is that the assistant isn’t properly using the response from your check_pnr_tool. Instead, it’s likely defaulting to a generic reply like “the ticket is confirmed” because it’s not being clearly instructed to read and use the exact status returned by the tool. Try adding something like this to your prompt: "When you receive a response from
check_pnr_tool
, always read the
status
field exactly as returned. Do not guess or assume the status. If the status is 'Waiting List', say 'Your ticket is on the waiting list.' If it is 'Cancelled', say 'Your ticket has been cancelled.' If it is 'Confirmed', say 'Your ticket is confirmed.'” Also you can say this is the information you have: and give all the variables of the info you have in {{example}}. Be sure to be very specific in the prompt. Let me know if this helped.
n
Hi..Thank you for responding really appreciate it. I tried changing the prompt as per this, but still I am getting the same response from the AI assistant. I'll just paste my exact prompt that I used below: You are a helpful railway ticket assistant. When the user asks about their PNR status, ask them for their 10-digit PNR number. Once you receive the number, call the
check_pnr_tool
tool with the parameter
pnr
. The tool will return a
result
field with one of the following values: - "Confirmed" - "Not Confirmed" - "Waiting List" - "Cancelled" - "PNR not found" Based on the result, respond accordingly: When you receive a response from check_pnr_tool, always read the status field exactly as returned. Do not guess or assume the status. If the status is 'Waiting List', say 'Your ticket is on the waiting list.' If it is 'Cancelled', say 'Your ticket has been cancelled.' If it is 'Confirmed', say 'Your ticket is confirmed. If it is 'not confirmed' say 'your ticket is not confirmed.' and if there is no such PNR number just say 'PNR not found' Never guess or make up PNR statuses. Always wait for the correct tool result before answering.
s
Add me to your dashboard as an editor Just want to take a look. My email is mason.d@vapi.ai
n
I have sent an invite. The assistant that I am using here is named Kate
s
Try testing it out again. The prompt looks good.
n
I tried testing it, it still says confirmed for all ticket numbers
s
checking if this is resolved/solved for you?
n
Not solved
s
To help track down this issue, could you share: - The call ID - When exactly this happened (the timestamp) - What response you expected to get - What response you actually got instead This would really help us figure out what went wrong!
n
Hi, thank you for responding, The call ID for one of the test calls: 79dd372e-2e40-41b7-b25a-de9bf8763a26 When exactly this happened (the timestamp for the above mentioned call): Apr 20, 2025, 14:12 What response you expected to get: The status for the ticket number that I gave as per the mock database is "waiting list" What response you actually got instead: The response that I got is "the ticket is confirmed"
should I attach the code file as well? will that help?