Handling delays in bots

Provide feedback to users while backend processing is happening

When the gather verb collects a user utterance and submits it to the jambonz webhook or websocket application for processing, there may be a noticeable delay depending on what the back-end logic needs to do.

For instance, it may need to update a CRM system, make an http request, or feed an LLM and wait for a response. Some of these operations may take a while to complete, and you may want to be able to provide a user with some calming feedback that this is normal system processing.

The actionhook delay feature provides a way to pre-program instructions on what to say or play something when these sorts of delays are experienced. This feature is enabled by the actionHookDelayAction property in either the gather or config verbs.

Parameters

actions
arrayRequired

An array of actions (jambonz verbs) to take when noResponseTimeout is triggered.

enabled
booleanRequired

Enable or disable the actionHookDelayAction feature.

noResponseGiveUpTimeout
number

Length of time (in seconds) to give up and stop performing actions.
Default: none.

noResponseTimeout
number

Length of delay (in seconds) that triggers an action.
Default: 0.

retries
number

Number of times to perform actions, with a noResponseTimeout between each retry.
Default: 1.

Examples

Providing filler noise

A simple use case is to provide filler noise when a back end operation takes a long time. Here, if the response takes longer than two seconds we play some typing sounds to the caller.

1{
2 "verb": "gather",
3 "actionHook": "/processUserUtterance",
4 "actionHookDelayAction" : {
5 "enabled": true,
6 "noResponseTimeout": 2,
7 "actions": [
8 {
9 "verb": "play",
10 "url": "http://adfads/typing-sounds.mp3"
11 }
12 ]
13 }
14}

Providing a series of prompts

A more complex use case would be to prompt multiple times as the delay gets longer, and then hang up the call if the bot does not respond in 20 seconds.

1{
2 "verb": "config",
3 "actionHookDelayAction" : {
4 "enabled": true,
5 "retries": 2,
6 "noResponseTimeout": 5,
7 "noResponseGiveupTimeout": 20,
8 "actions": [
9 {
10 "verb": "say",
11 "text": "Please hold while we complete your transaction"
12 },
13 {
14 "verb": "say",
15 "text": "Please continue to hold."
16 }
17 ]
18 }
19},
20{
21 "verb": "gather",
22 "say": "Would you like us to book your flight now?",
23 "input": ["speech"],
24 "actionHook": "/processUserUtterance"
25}

Note in the above that we have an array with two prompts. The first is played after 5 seconds of delay and a different prompt is played if the user is still waiting for a response after 10 seconds. If the delay reaches 20 seconds, then the call is terminated.

Built with