Assistant hooks
Overview
Assistant hooks let you automate actions when specific events occur during a call. Use hooks to transfer calls, run functions, or send messages in response to events like call ending or speech interruptions.
Supported events include:
call.ending
: When a call is endingassistant.speech.interrupted
: When the assistant’s speech is interruptedcustomer.speech.interrupted
: When the customer’s speech is interrupted
You can combine actions and add filters to control when hooks trigger.
How hooks work
Hooks are defined in the hooks
array of your assistant configuration. Each hook includes:
on
: The event that triggers the hookdo
: The actions to perform (supportstransfer
,function
, andsay
)filters
: (Optional) Conditions that must be met for the hook to trigger
The call.endedReason
filter can be set to any of the call ended reasons.
The transfer destination type follows the transfer call tool destinations schema.
Example: Transfer on pipeline error
Transfer a call to a fallback number if a pipeline error occurs:
You can also transfer to a SIP destination:
Example: Combine actions on pipeline error
Perform multiple actions—say a message, call a function, and transfer the call—when a pipeline error occurs:
Example: Handle speech interruptions
Respond when the assistant’s speech is interrupted by the customer:
Handle customer speech interruptions in a similar way:
Use "oneOf": ["pipeline-error"]
as a catch-all filter for any pipeline-related error reason.
Common use cases
- Transfer to a human agent on errors
- Route to a fallback system if the assistant fails
- Handle customer or assistant interruptions gracefully
- Log errors or events for monitoring
Slack Webhook on Call Failure
You can set up automatic Slack notifications when calls fail by combining assistant hooks with Slack webhooks. This is useful for monitoring call quality and getting immediate alerts when issues occur.
Step 1: Generate a Slack webhook
Follow the Slack webhook documentation to create an incoming webhook:
- Create a Slack app (if you don’t have one already)
- Enable incoming webhooks in your app settings
- Create an incoming webhook for your desired channel
- Copy the webhook URL (it will look like
https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX
)
Step 2: Create a serverless function
Set up a serverless function (using a service like val.town) to convert Vapi tool call requests into Slack messages:
Step 3: Configure the assistant hook
Add this hook configuration to your assistant to trigger Slack notifications on call failures:
Replace <your-slack-webhook-url>
with your actual Slack webhook URL and <your-serverless-function-url>
with your serverless function endpoint.