Class: Vapi::HandoffStep

Inherits:
Object
  • Object
show all
Defined in:
lib/vapi_server_sdk/types/handoff_step.rb

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, block: OMIT, destinations: OMIT, block_id: OMIT, input: OMIT, additional_properties: nil) ⇒ Vapi::HandoffStep

Parameters:

  • block (Vapi::HandoffStepBlock) (defaults to: OMIT)

    This is the block to use. To use an existing block, use ‘blockId`.

  • destinations (Array<Vapi::StepDestination>) (defaults to: OMIT)

    These are the destinations that the step can go to after it’s done.

  • name (String)

    This is the name of the step.

  • block_id (String) (defaults to: OMIT)

    This is the id of the block to use. To use a transient block, use ‘block`.

  • input (Hash{String => Object}) (defaults to: OMIT)

    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:

    • “Vapi::HandoffStep.{your-step-name{your-step-name.output{your-step-name.output.your-property-name}” for another step’s output (in

    the same workflow; read caveat #1)

    • “Vapi::HandoffStep.{your-step-name{your-step-name.input{your-step-name.input.your-property-name}” for another step’s input (in the

    same workflow; read caveat #1)

    • “Vapi::HandoffStep.{your-block-name{your-block-name.output{your-block-name.output.your-property-name}” for another block’s output (in

    the same workflow; read caveat #2)

    • “Vapi::HandoffStep.{your-block-name{your-block-name.input{your-block-name.input.your-property-name}” for another block’s input (in

    the same workflow; read caveat #2)

    • “Vapi::HandoffStep.{workflow{workflow.input{workflow.input.your-property-name}” for the current workflow’s input

    • “Vapi::HandoffStep.{global{global.your-property-name}” for the global context

    Example: { “name”: “Vapi::HandoffStep.{my-tool-call-step{my-tool-call-step.output{my-tool-call-step.output.name}”, “age”: “Vapi::HandoffStep.{my-tool-call-step{my-tool-call-step.input{my-tool-call-step.input.age}”, “date”: “Vapi::HandoffStep.{workflow{workflow.input{workflow.input.date}” } You can dynamically change the key name. Example: { “Vapi::HandoffStep.{my-tool-call-step{my-tool-call-step.output{my-tool-call-step.output.key-name-for-name}”: “{name}”, “Vapi::HandoffStep.{my-tool-call-step{my-tool-call-step.input{my-tool-call-step.input.key-name-for-age}”: “{age}”, “Vapi::HandoffStep.{workflow{workflow.input{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”: “Vapi::HandoffStep.{my-tool-call-step{my-tool-call-step.output{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. Vapi::HandoffStep.{stepName{stepName.input/output{stepName.input/output.propertyName} will reference the latest usage of the step.

    1. 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. Vapi::HandoffStep.{blockName{blockName.input/output{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.

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
# File 'lib/vapi_server_sdk/types/handoff_step.rb', line 135

def initialize(name:, block: OMIT, destinations: OMIT, block_id: OMIT, input: OMIT, additional_properties: nil)
  @block = block if block != OMIT
  @destinations = destinations if destinations != OMIT
  @name = name
  @block_id = block_id if block_id != OMIT
  @input = input if input != OMIT
  @additional_properties = additional_properties
  @_field_set = {
    "block": block,
    "destinations": destinations,
    "name": name,
    "blockId": block_id,
    "input": input
  }.reject do |_k, v|
    v == OMIT
  end
end

Instance Attribute Details

#additional_propertiesOpenStruct (readonly)

Returns Additional properties unmapped to the current class definition.

Returns:

  • (OpenStruct)

    Additional properties unmapped to the current class definition



71
72
73
# File 'lib/vapi_server_sdk/types/handoff_step.rb', line 71

def additional_properties
  @additional_properties
end

#blockVapi::HandoffStepBlock (readonly)

Returns This is the block to use. To use an existing block, use ‘blockId`.

Returns:



11
12
13
# File 'lib/vapi_server_sdk/types/handoff_step.rb', line 11

def block
  @block
end

#block_idString (readonly)

Returns This is the id of the block to use. To use a transient block, use ‘block`.

Returns:

  • (String)

    This is the id of the block to use. To use a transient block, use ‘block`.



17
18
19
# File 'lib/vapi_server_sdk/types/handoff_step.rb', line 17

def block_id
  @block_id
end

#destinationsArray<Vapi::StepDestination> (readonly)

Returns These are the destinations that the step can go to after it’s done.

Returns:

  • (Array<Vapi::StepDestination>)

    These are the destinations that the step can go to after it’s done.



13
14
15
# File 'lib/vapi_server_sdk/types/handoff_step.rb', line 13

def destinations
  @destinations
end

#inputHash{String => Object} (readonly)

Returns 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:

  • “Vapi::HandoffStep.{your-step-name{your-step-name.output{your-step-name.output.your-property-name}” for another step’s output (in

the same workflow; read caveat #1)

  • “Vapi::HandoffStep.{your-step-name{your-step-name.input{your-step-name.input.your-property-name}” for another step’s input (in the

same workflow; read caveat #1)

  • “Vapi::HandoffStep.{your-block-name{your-block-name.output{your-block-name.output.your-property-name}” for another block’s output (in

the same workflow; read caveat #2)

  • “Vapi::HandoffStep.{your-block-name{your-block-name.input{your-block-name.input.your-property-name}” for another block’s input (in

the same workflow; read caveat #2)

  • “Vapi::HandoffStep.{workflow{workflow.input{workflow.input.your-property-name}” for the current workflow’s input

  • “Vapi::HandoffStep.{global{global.your-property-name}” for the global context

Example: { “name”: “Vapi::HandoffStep.{my-tool-call-step{my-tool-call-step.output{my-tool-call-step.output.name}”, “age”: “Vapi::HandoffStep.{my-tool-call-step{my-tool-call-step.input{my-tool-call-step.input.age}”, “date”: “Vapi::HandoffStep.{workflow{workflow.input{workflow.input.date}” } You can dynamically change the key name. Example: { “Vapi::HandoffStep.{my-tool-call-step{my-tool-call-step.output{my-tool-call-step.output.key-name-for-name}”: “{name}”, “Vapi::HandoffStep.{my-tool-call-step{my-tool-call-step.input{my-tool-call-step.input.key-name-for-age}”: “{age}”, “Vapi::HandoffStep.{workflow{workflow.input{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”: “Vapi::HandoffStep.{my-tool-call-step{my-tool-call-step.output{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. Vapi::HandoffStep.{stepName{stepName.input/output{stepName.input/output.propertyName} will reference the latest usage of the step.

  1. 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. Vapi::HandoffStep.{blockName{blockName.input/output{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.

Returns:

  • (Hash{String => Object})

    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:

    • “Vapi::HandoffStep.{your-step-name{your-step-name.output{your-step-name.output.your-property-name}” for another step’s output (in

    the same workflow; read caveat #1)

    • “Vapi::HandoffStep.{your-step-name{your-step-name.input{your-step-name.input.your-property-name}” for another step’s input (in the

    same workflow; read caveat #1)

    • “Vapi::HandoffStep.{your-block-name{your-block-name.output{your-block-name.output.your-property-name}” for another block’s output (in

    the same workflow; read caveat #2)

    • “Vapi::HandoffStep.{your-block-name{your-block-name.input{your-block-name.input.your-property-name}” for another block’s input (in

    the same workflow; read caveat #2)

    • “Vapi::HandoffStep.{workflow{workflow.input{workflow.input.your-property-name}” for the current workflow’s input

    • “Vapi::HandoffStep.{global{global.your-property-name}” for the global context

    Example: { “name”: “Vapi::HandoffStep.{my-tool-call-step{my-tool-call-step.output{my-tool-call-step.output.name}”, “age”: “Vapi::HandoffStep.{my-tool-call-step{my-tool-call-step.input{my-tool-call-step.input.age}”, “date”: “Vapi::HandoffStep.{workflow{workflow.input{workflow.input.date}” } You can dynamically change the key name. Example: { “Vapi::HandoffStep.{my-tool-call-step{my-tool-call-step.output{my-tool-call-step.output.key-name-for-name}”: “{name}”, “Vapi::HandoffStep.{my-tool-call-step{my-tool-call-step.input{my-tool-call-step.input.key-name-for-age}”: “{age}”, “Vapi::HandoffStep.{workflow{workflow.input{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”: “Vapi::HandoffStep.{my-tool-call-step{my-tool-call-step.output{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. Vapi::HandoffStep.{stepName{stepName.input/output{stepName.input/output.propertyName} will reference the latest usage of the step.

    1. 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. Vapi::HandoffStep.{blockName{blockName.input/output{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.



69
70
71
# File 'lib/vapi_server_sdk/types/handoff_step.rb', line 69

def input
  @input
end

#nameString (readonly)

Returns This is the name of the step.

Returns:

  • (String)

    This is the name of the step.



15
16
17
# File 'lib/vapi_server_sdk/types/handoff_step.rb', line 15

def name
  @name
end

Class Method Details

.from_json(json_object:) ⇒ Vapi::HandoffStep

Deserialize a JSON object to an instance of HandoffStep

Parameters:

  • json_object (String)

Returns:



157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
# File 'lib/vapi_server_sdk/types/handoff_step.rb', line 157

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  if parsed_json["block"].nil?
    block = nil
  else
    block = parsed_json["block"].to_json
    block = Vapi::HandoffStepBlock.from_json(json_object: block)
  end
  destinations = parsed_json["destinations"]&.map do |item|
    item = item.to_json
    Vapi::StepDestination.from_json(json_object: item)
  end
  name = parsed_json["name"]
  block_id = parsed_json["blockId"]
  input = parsed_json["input"]
  new(
    block: block,
    destinations: destinations,
    name: name,
    block_id: block_id,
    input: input,
    additional_properties: struct
  )
end

.validate_raw(obj:) ⇒ Void

Leveraged for Union-type generation, validate_raw attempts to parse the given

hash and check each fields type against the current object's property
definitions.

Parameters:

  • obj (Object)

Returns:

  • (Void)


196
197
198
199
200
201
202
# File 'lib/vapi_server_sdk/types/handoff_step.rb', line 196

def self.validate_raw(obj:)
  obj.block.nil? || Vapi::HandoffStepBlock.validate_raw(obj: obj.block)
  obj.destinations&.is_a?(Array) != false || raise("Passed value for field obj.destinations is not the expected type, validation failed.")
  obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
  obj.block_id&.is_a?(String) != false || raise("Passed value for field obj.block_id is not the expected type, validation failed.")
  obj.input&.is_a?(Hash) != false || raise("Passed value for field obj.input is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of HandoffStep to a JSON object

Returns:

  • (String)


186
187
188
# File 'lib/vapi_server_sdk/types/handoff_step.rb', line 186

def to_json(*_args)
  @_field_set&.to_json
end