You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Assistant hooks allow you to configure actions that will be performed when specific events occur during a call. Currently, hooks support the `call.ending` event, which triggers when a call is ending.
8
+
Assistant hooks allow you to configure actions that will be performed when specific events occur during a call. Currently, hooks support the `call.ending` event (which is triggered when a call is ending), `assistant.speech.interrupted` (when the assistant's speech is interrupted), and `customer.speech.interrupted` (when the customer's speech is interrupted)
9
9
10
10
## Usage
11
11
12
12
Hooks are defined in the `hooks` array of an assistant. Each hook consists of:
13
13
14
-
-`on`: The event that triggers the hook (currently only supports `call.ending`)
15
-
-`do`: The actions to perform when the hook triggers (currently only supports `transfer`)
14
+
-`on`: The event that triggers the hook (supports `call.ending`, `assistant.speech.interrupted`, and `customer.speech.interrupted`)
15
+
-`do`: The actions to perform when the hook triggers (supports `transfer`, `function`, and `say`)
16
16
-`filters`: Optional conditions that must be met for the hook to trigger
17
17
18
18
The `call.endedReason` field in filters can be set to any of the [call ended reasons](https://docs.vapi.ai/api-reference/calls/get#response.body.endedReason). The transfer destination type follows the same schema as the [transfer call tool destinations](https://docs.vapi.ai/api-reference/tools/create#request.body.transferCall.destinations).
This example demonstrates how to combine multiple actions (say, function, and transfer) when a pipeline error occurs. The hook will first say a message, then call a function, and finally transfer the call:
"exact": "I apologize for the technical difficulty. Let me transfer you to our support team."
95
+
},
96
+
{
97
+
"type": "function",
98
+
"function": {
99
+
"name": "log_error",
100
+
"parameters": {
101
+
"type": "object",
102
+
"properties": {
103
+
"error_type": {
104
+
"type": "string",
105
+
"value": "pipeline_error"
106
+
}
107
+
}
108
+
},
109
+
"description": "Logs the error details for monitoring"
110
+
},
111
+
"async": true,
112
+
"server": {
113
+
"url": "https://your-server.com/api"
114
+
}
115
+
},
116
+
{
117
+
"type": "transfer",
118
+
"destination": {
119
+
"type": "number",
120
+
"number": "+1234567890",
121
+
"callerId": "+1987654321"
122
+
}
123
+
}
124
+
]
125
+
}]
126
+
}'
127
+
```
128
+
129
+
## Example: Handling Speech Interruptions
130
+
131
+
This example demonstrates how to handle when the assistant's speech is interrupted by the customer. The hook will respond with a polite acknowledgment:
Phone number hooks allow you to configure actions that will be performed when specific events occur during a call. Currently, hooks support the `call.ringing` event (which is triggered when a call is ringing).
9
+
10
+
## Usage
11
+
12
+
Hooks are defined in the `hooks` array of a phone number. Each hook consists of:
13
+
14
+
-`on`: The event that triggers the hook (supports `call.ringing`)
15
+
-`do`: The actions to perform when the hook triggers (supports `transfer` and `say`)
16
+
17
+
## Example: Say Message on Call Ringing
18
+
19
+
This example shows how to play a message when a call is ringing:
0 commit comments