Skip to content

Stacks & Call Flows

Voice agents/bots in VoiceBooker consist of multiple stages. Stages can be active, i.e., the prompts and tools as well as functions will be part of the LLM query, hence the LLM can potentially call and execute your functions based in their purpose.

The stack is a simple string array/list that contains all names of the currently active stages. The prompts, tools and functions are added to the LLM query in the order as the stages are listed in the stack, i.e., the stages that is listed last in the stack, its prompt is the most recent one (added last) defining the behavior of the conversation/LLM.

Stack Modifications - Stage Transitions

In order to define a call flow, i.e., each function can optionally receive the state of the stack as part of the parameters. This parameter is a string array and can be modified by appending or popping entries and returning the modified stack. This allows developers to build complex voice agent/bot flows. For instance, an existing customer who wants to cancel a contract will be asked/queried a different set of questions/information than a customer who wants to book a certain product.

No Code Stage Transitions

Stage transitions are happening during an action, i.e., a function call. Hence, it is possible to define a stage transition directly in the tools tools section of a function definition/configuration:

First, you define the next stage, that should be added to the stack, i.e., should be the next active stage.

Secondly, you can specify with Drop current stage if the current stage should be removed from the stack. Hence, its tools/functions will not be available anymore.

Code Stage Transitions

In order to perform stage transitions in a programmatic way, you first need to enable the stack flag for the function in order to receive the stack as parameters in the function call.

The following example shows how to add the stage "Next Stage" to the stack, and returning it upon leaving the function:

function someFunction(params) {
    params["stack"].push("Next Stage");
    return { stack: params["stack"] };
}