vapi_client/models/
callback_step.rs

1/*
2 * Vapi API
3 *
4 * API for building voice assistants
5 *
6 * The version of the OpenAPI document: 1.0
7 *
8 * Generated by: https://openapi-generator.tech
9 */
10
11use serde::{Deserialize, Serialize};
12use utoipa::ToSchema;
13
14
15use crate::models;
16
17#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize, ToSchema)]
18pub struct CallbackStep {
19    #[serde(rename = "block", skip_serializing_if = "Option::is_none")]
20    pub block: Option<models::HandoffStepBlock>,
21    /// This is a step that calls back to the previous step after it's done. This effectively means we're spawning a new conversation thread. The previous conversation thread will resume where it left off once this step is done.  Use case: - You are collecting a customer's order and while they were on one item, they start a new item or try to modify a previous one. You would make a OrderUpdate block which calls the same block repeatedly when a new update starts.
22    #[serde(rename = "type")]
23    pub r#type: Type,
24    /// This is the mutations to apply to the context after the step is done.
25    #[serde(rename = "mutations", skip_serializing_if = "Option::is_none")]
26    pub mutations: Option<Vec<models::CallbackStepMutationsInner>>,
27    /// This is the name of the step.
28    #[serde(rename = "name")]
29    pub name: String,
30    /// This is the id of the block to use. To use a transient block, use `block`.
31    #[serde(rename = "blockId", skip_serializing_if = "Option::is_none")]
32    pub block_id: Option<String>,
33    /// This is the input to the block. You can use any key-value map as input to the block.  Example: {   \"name\": \"John Doe\",   \"age\": 20 }  You can reference any variable in the context of the current block: - \"{{your-step-name.output.your-property-name}}\" for another step's output (in the same workflow; read caveat #1) - \"{{your-step-name.input.your-property-name}}\" for another step's input (in the same workflow; read caveat #1) - \"{{your-block-name.output.your-property-name}}\" for another block's output (in the same workflow; read caveat #2) - \"{{your-block-name.input.your-property-name}}\" for another block's input (in the same workflow; read caveat #2) - \"{{workflow.input.your-property-name}}\" for the current workflow's input - \"{{global.your-property-name}}\" for the global context  Example: {   \"name\": \"{{my-tool-call-step.output.name}}\",   \"age\": \"{{my-tool-call-step.input.age}}\",   \"date\": \"{{workflow.input.date}}\" }  You can dynamically change the key name.  Example: {   \"{{my-tool-call-step.output.key-name-for-name}}\": \"{{name}}\",   \"{{my-tool-call-step.input.key-name-for-age}}\": \"{{age}}\",   \"{{workflow.input.key-name-for-date}}\": \"{{date}}\" }  You can represent the value as a string, number, boolean, array, or object.  Example: {   \"name\": \"john\",   \"age\": 20,   \"date\": \"2021-01-01\",   \"metadata\": {     \"unique-key\": \"{{my-tool-call-step.output.unique-key}}\"   },   \"array\": [\"A\", \"B\", \"C\"], }  Caveats: 1. a workflow can execute a step multiple times. example, if a loop is used in the graph. {{stepName.input/output.propertyName}} will reference the latest usage of the step. 2. a workflow can execute a block multiple times. example, if a step is called multiple times or if a block is used in multiple steps. {{blockName.input/output.propertyName}} will reference the latest usage of the block. this liquid variable is just provided for convenience when creating blocks outside of a workflow.
34    #[serde(rename = "input", skip_serializing_if = "Option::is_none")]
35    pub input: Option<serde_json::Value>,
36}
37
38impl CallbackStep {
39    pub fn new(r#type: Type, name: String) -> CallbackStep {
40        CallbackStep {
41            block: None,
42            r#type,
43            mutations: None,
44            name,
45            block_id: None,
46            input: None,
47        }
48    }
49}
50/// This is a step that calls back to the previous step after it's done. This effectively means we're spawning a new conversation thread. The previous conversation thread will resume where it left off once this step is done.  Use case: - You are collecting a customer's order and while they were on one item, they start a new item or try to modify a previous one. You would make a OrderUpdate block which calls the same block repeatedly when a new update starts.
51#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize, ToSchema)]
52pub enum Type {
53    #[serde(rename = "callback")]
54    Callback,
55}
56
57impl Default for Type {
58    fn default() -> Type {
59        Self::Callback
60    }
61}