Special Tool Call Support That Gets Triggered Imme...
# support
k
We're using VAPI for our appointment booking chatbot and need a tool call to trigger immediately at the start of a call to provide better context to the chatbot. Currently, it only runs after or at the first human reply, even when we explicitly prompt it to run earlier (tried async, sync, etc.). This would be very useful for many use cases where prerequisite data needs to be fetched from webhooks at the start of a call. Let us know if there's a way to achieve this or if it can be considered as an enhancement.
v
Hi there! 👋 I understand you're trying to trigger a tool call immediately at the start of a call in VAPI for your appointment booking chatbot. While I couldn't find a guaranteed solution for triggering tool calls right at call start, I can share what I found about current limitations and possible approaches. ## Current Limitations Based on the information I found, this appears to be a known issue. Several users have reported similar challenges with tool calls not triggering immediately at the start of a call, even when prompted to run earlier. According to [user discussions](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1329542939160084624), tool calling functionality can break frequently after new feature rollouts, and tools can sometimes automatically become async. ## Possible Approaches Here are some approaches that might help: ### 1. Custom Tools with Explicit Tool Calls You could try creating a custom tool and associating it with your assistant, using explicit tool calls with prompts to trigger the tool. According to [this discussion](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1333245023319494707), Vapi will send a server request where you can use the SDK to trigger actions by inferring the server message tool call payload. ### 2. Synchronous Tool Configuration Ensure your tool is set to
synchronous
instead of
async
as mentioned in [this thread](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1342315282198298729). However, be aware that synchronous tool calls might face issues where the server immediately regards them as failed, sending a
tool_call_result
message with "No result returned" to the LLM. ### 3. Webhook Approach
One alternative approach is to set up your own webhook endpoint first, process the call as needed, and then forward it to VAPI. This allows you to intercept the call and fetch data before VAPI processes it, as suggested in [this conversation](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1343397177182912553). ### 4. Using assistantOverrides You can include relevant data in the
variableValues
object within
assistantOverrides
when starting a Vapi instance:
Copy code
javascript
vapiInstance = vapiSDK.run({
  apiKey: apiKey,
  assistant: assistant,
  config: buttonConfig,
  assistantOverrides: {
    variableValues: {
      userId: "yourUserIdHere"
    }
  }
});
This way, the data will be available when Vapi calls the webhook, as mentioned in [this thread](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1339495894801711186). ## Enhancement Potential Based on the information I found, this capability would indeed be a valuable enhancement to VAPI. Multiple users have reported issues with tool calls not working as expected, with some expressing a desire for more control and flexibility in their handling. Is there anything specific about your implementation that you'd like me to help with further? Sources: - [Discord Thread](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1329542939160084624) - [Discord Thread](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1333245023319494707) - [Discord Thread](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1342315282198298729) - [Discord Thread](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1343397177182912553) - [Discord Thread](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1339495894801711186) - [Discord Thread](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1343933426721488896)
k
You can raise an feature request for it over here: https://roadmap.vapi.ai