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
Copy file name to clipboardExpand all lines: fern/assistants/assistant-hooks.mdx
+72-4Lines changed: 72 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,7 +15,7 @@ Supported events include:
15
15
-`customer.speech.interrupted`: When the customer's speech is interrupted
16
16
-`customer.speech.timeout`: When the customer doesn't speak within a specified time
17
17
18
-
You can combine actions and add filters to control when hooks trigger.
18
+
You can combine actions and add filters to control when hooks trigger. Multiple `customer.speech.timeout` hooks can be attached to an assistant with staggered trigger delay to support different actions at different timing in the conversation.
19
19
20
20
## How hooks work
21
21
@@ -145,6 +145,10 @@ Perform multiple actions—say a message, call a function, and transfer the call
145
145
}]
146
146
}
147
147
```
148
+
149
+
<Note>
150
+
Use `"oneOf": ["pipeline-error"]` as a catch-all filter for any pipeline-related error reason.
151
+
</Note>
148
152
149
153
## Example: Handle speech interruptions
150
154
@@ -205,9 +209,73 @@ The `customer.speech.timeout` hook supports special options:
205
209
-`triggerResetMode`: Whether to reset the trigger count when user speaks (default: "never")
206
210
</Note>
207
211
208
-
<Note>
209
-
Use `"oneOf": ["pipeline-error"]` as a catch-all filter for any pipeline-related error reason.
210
-
</Note>
212
+
## Example: End call if user hasn't spoken for 30s
213
+
214
+
Assistant checks with the user at the 10 and 20s mark from when the user is silent, and ends the call after 30s of silence.
215
+
216
+
```json
217
+
{
218
+
"hooks": [
219
+
{
220
+
"hooks": [
221
+
{
222
+
"on": "customer.speech.timeout",
223
+
"options": {
224
+
"timeoutSeconds": 10,
225
+
"triggerMaxCount": 3,
226
+
"triggerResetMode": "onUserSpeech"
227
+
},
228
+
"do": [
229
+
{
230
+
"type": "say",
231
+
"exact": "Are you still there? Please let me know how I can help you."
232
+
}
233
+
]
234
+
},
235
+
{
236
+
"on": "customer.speech.timeout",
237
+
"options": {
238
+
"timeoutSeconds": 20,
239
+
"triggerMaxCount": 3,
240
+
"triggerResetMode": "onUserSpeech"
241
+
},
242
+
"do": [
243
+
{
244
+
"type": "say",
245
+
"prompt": "The user has not responded in 20s. Based on the above conversation in {{transcript}} ask the user if they need help or if not you will be ending the call"
246
+
}
247
+
]
248
+
}
249
+
]
250
+
},
251
+
{
252
+
"hooks": [
253
+
{
254
+
"on": "customer.speech.timeout",
255
+
"options": {
256
+
"timeoutSeconds": 30,
257
+
"triggerMaxCount": 3,
258
+
"triggerResetMode": "onUserSpeech"
259
+
},
260
+
"do": [
261
+
{
262
+
"type" : "say",
263
+
"exact" : "I'll be ending the call now, please feel free to call back at any time."
0 commit comments