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};
12
13use crate::models;
14
15#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
16pub struct CallbackStep {
17    #[serde(rename = "block", skip_serializing_if = "Option::is_none")]
18    pub block: Option<models::HandoffStepBlock>,
19    /// 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.
20    #[serde(rename = "type")]
21    pub r#type: Type,
22    /// This is the mutations to apply to the context after the step is done.
23    #[serde(rename = "mutations", skip_serializing_if = "Option::is_none")]
24    pub mutations: Option<Vec<models::CallbackStepMutationsInner>>,
25    /// This is the name of the step.
26    #[serde(rename = "name")]
27    pub name: String,
28    /// This is the id of the block to use. To use a transient block, use `block`.
29    #[serde(rename = "blockId", skip_serializing_if = "Option::is_none")]
30    pub block_id: Option<String>,
31    /// 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.
32    #[serde(rename = "input", skip_serializing_if = "Option::is_none")]
33    pub input: Option<serde_json::Value>,
34}
35
36impl CallbackStep {
37    pub fn new(r#type: Type, name: String) -> CallbackStep {
38        CallbackStep {
39            block: None,
40            r#type,
41            mutations: None,
42            name,
43            block_id: None,
44            input: None,
45        }
46    }
47}
48/// 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.
49#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
50pub enum Type {
51    #[serde(rename = "callback")]
52    Callback,
53}
54
55impl Default for Type {
56    fn default() -> Type {
57        Self::Callback
58    }
59}