Skip to content

Commit 0e25282

Browse files
authored
Updated hooks and idle timeout docs (#640)
1 parent 2f9bf03 commit 0e25282

File tree

2 files changed

+246
-127
lines changed

2 files changed

+246
-127
lines changed

fern/assistants/assistant-hooks.mdx

Lines changed: 72 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Supported events include:
1515
- `customer.speech.interrupted`: When the customer's speech is interrupted
1616
- `customer.speech.timeout`: When the customer doesn't speak within a specified time
1717

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.
1919

2020
## How hooks work
2121

@@ -145,6 +145,10 @@ Perform multiple actions—say a message, call a function, and transfer the call
145145
}]
146146
}
147147
```
148+
149+
<Note>
150+
Use `"oneOf": ["pipeline-error"]` as a catch-all filter for any pipeline-related error reason.
151+
</Note>
148152

149153
## Example: Handle speech interruptions
150154

@@ -205,9 +209,73 @@ The `customer.speech.timeout` hook supports special options:
205209
- `triggerResetMode`: Whether to reset the trigger count when user speaks (default: "never")
206210
</Note>
207211

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."
264+
},
265+
{
266+
"type": "tool",
267+
"tool": {
268+
"type": "endCall"
269+
}
270+
}
271+
]
272+
}
273+
]
274+
}
275+
]
276+
}
277+
```
278+
211279

212280
## Common use cases
213281

0 commit comments

Comments
 (0)