Class: Vapi::ConversationBlock

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

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, org_id:, created_at:, updated_at:, instruction:, messages: OMIT, input_schema: OMIT, output_schema: OMIT, name: OMIT, additional_properties: nil) ⇒ Vapi::ConversationBlock

Parameters:

  • messages (Array<Vapi::ConversationBlockMessagesItem>) (defaults to: OMIT)

    These are the pre-configured messages that will be spoken to the user while the block is running.

  • input_schema (Vapi::JsonSchema) (defaults to: OMIT)

    This is the input schema for the block. This is the input the block needs to run. It’s given to the block as ‘steps.input` These are accessible as variables:

    • (Vapi::ConversationBlock.{input{input.propertyName}) in context of the block execution (step)

    • (Vapi::ConversationBlock.{stepName{stepName.input{stepName.input.propertyName}) in context of the workflow

  • output_schema (Vapi::JsonSchema) (defaults to: OMIT)

    This is the output schema for the block. This is the output the block will return to the workflow (‘Vapi::ConversationBlock.{stepName{stepName.output}`). These are accessible as variables:

    • (Vapi::ConversationBlock.{output{output.propertyName}) in context of the block execution (step)

    • (Vapi::ConversationBlock.{stepName{stepName.output{stepName.output.propertyName}) in context of the workflow (read caveat #1)

    • (Vapi::ConversationBlock.{blockName{blockName.output{blockName.output.propertyName}) in context of the workflow (read caveat

    #2) Caveats:

    1. a workflow can execute a step multiple times. example, if a loop is used in

    the graph. Vapi::ConversationBlock.{stepName{stepName.output{stepName.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::ConversationBlock.{blockName{blockName.output{blockName.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 with steps.

  • id (String)

    This is the unique identifier for the block.

  • org_id (String)

    This is the unique identifier for the organization that this block belongs to.

  • created_at (DateTime)

    This is the ISO 8601 date-time string of when the block was created.

  • updated_at (DateTime)

    This is the ISO 8601 date-time string of when the block was last updated.

  • name (String) (defaults to: OMIT)

    This is the name of the block. This is just for your reference.

  • instruction (String)

    This is the instruction to the model. You can reference any variable in the context of the current block execution (step):

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

    • “Vapi::ConversationBlock.{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::ConversationBlock.{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::ConversationBlock.{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::ConversationBlock.{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::ConversationBlock.{workflow{workflow.input{workflow.input.your-property-name}” for the current workflow’s input

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

    This can be as simple or as complex as you want it to be.

    • “say hello and ask the user about their day!”

    • “collect the user’s first and last name”

    • “user is Vapi::ConversationBlock.{input{input.firstName} Vapi::ConversationBlock.{input{input.lastName}. their age is Vapi::ConversationBlock.{input{input.age}.

    ask them about their salary and if they might be interested in buying a house. we offer Vapi::ConversationBlock.{input{input.offer}“ Caveats:

    1. a workflow can execute a step multiple times. example, if a loop is used in

    the graph. Vapi::ConversationBlock.{stepName{stepName.output/input{stepName.output/input.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::ConversationBlock.{blockName{blockName.output/input{blockName.output/input.propertyName} will reference the latest usage of the block. this liquid variable is just provided for convenience when creating blocks outside of a workflow with steps.

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
# File 'lib/vapi_server_sdk/types/conversation_block.rb', line 144

def initialize(id:, org_id:, created_at:, updated_at:, instruction:, messages: OMIT, input_schema: OMIT, output_schema: OMIT,
               name: OMIT, additional_properties: nil)
  @messages = messages if messages != OMIT
  @input_schema = input_schema if input_schema != OMIT
  @output_schema = output_schema if output_schema != OMIT
  @id = id
  @org_id = org_id
  @created_at = created_at
  @updated_at = updated_at
  @name = name if name != OMIT
  @instruction = instruction
  @additional_properties = additional_properties
  @_field_set = {
    "messages": messages,
    "inputSchema": input_schema,
    "outputSchema": output_schema,
    "id": id,
    "orgId": org_id,
    "createdAt": created_at,
    "updatedAt": updated_at,
    "name": name,
    "instruction": instruction
  }.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



78
79
80
# File 'lib/vapi_server_sdk/types/conversation_block.rb', line 78

def additional_properties
  @additional_properties
end

#created_atDateTime (readonly)

Returns This is the ISO 8601 date-time string of when the block was created.

Returns:

  • (DateTime)

    This is the ISO 8601 date-time string of when the block was created.



42
43
44
# File 'lib/vapi_server_sdk/types/conversation_block.rb', line 42

def created_at
  @created_at
end

#idString (readonly)

Returns This is the unique identifier for the block.

Returns:

  • (String)

    This is the unique identifier for the block.



38
39
40
# File 'lib/vapi_server_sdk/types/conversation_block.rb', line 38

def id
  @id
end

#input_schemaVapi::JsonSchema (readonly)

Returns This is the input schema for the block. This is the input the block needs to run. It’s given to the block as ‘steps.input` These are accessible as variables:

  • (Vapi::ConversationBlock.{input{input.propertyName}) in context of the block execution (step)

  • (Vapi::ConversationBlock.{stepName{stepName.input{stepName.input.propertyName}) in context of the workflow.

Returns:

  • (Vapi::JsonSchema)

    This is the input schema for the block. This is the input the block needs to run. It’s given to the block as ‘steps.input` These are accessible as variables:

    • (Vapi::ConversationBlock.{input{input.propertyName}) in context of the block execution (step)

    • (Vapi::ConversationBlock.{stepName{stepName.input{stepName.input.propertyName}) in context of the workflow



19
20
21
# File 'lib/vapi_server_sdk/types/conversation_block.rb', line 19

def input_schema
  @input_schema
end

#instructionString (readonly)

Returns This is the instruction to the model. You can reference any variable in the context of the current block execution (step):

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

  • “Vapi::ConversationBlock.{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::ConversationBlock.{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::ConversationBlock.{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::ConversationBlock.{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::ConversationBlock.{workflow{workflow.input{workflow.input.your-property-name}” for the current workflow’s input

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

This can be as simple or as complex as you want it to be.

  • “say hello and ask the user about their day!”

  • “collect the user’s first and last name”

  • “user is Vapi::ConversationBlock.{input{input.firstName} Vapi::ConversationBlock.{input{input.lastName}. their age is Vapi::ConversationBlock.{input{input.age}.

ask them about their salary and if they might be interested in buying a house. we offer Vapi::ConversationBlock.{input{input.offer}“ Caveats:

  1. a workflow can execute a step multiple times. example, if a loop is used in

the graph. Vapi::ConversationBlock.{stepName{stepName.output/input{stepName.output/input.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::ConversationBlock.{blockName{blockName.output/input{blockName.output/input.propertyName} will reference the latest usage of the block. this liquid variable is just provided for convenience when creating blocks outside of a workflow with steps.

Returns:

  • (String)

    This is the instruction to the model. You can reference any variable in the context of the current block execution (step):

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

    • “Vapi::ConversationBlock.{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::ConversationBlock.{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::ConversationBlock.{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::ConversationBlock.{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::ConversationBlock.{workflow{workflow.input{workflow.input.your-property-name}” for the current workflow’s input

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

    This can be as simple or as complex as you want it to be.

    • “say hello and ask the user about their day!”

    • “collect the user’s first and last name”

    • “user is Vapi::ConversationBlock.{input{input.firstName} Vapi::ConversationBlock.{input{input.lastName}. their age is Vapi::ConversationBlock.{input{input.age}.

    ask them about their salary and if they might be interested in buying a house. we offer Vapi::ConversationBlock.{input{input.offer}“ Caveats:

    1. a workflow can execute a step multiple times. example, if a loop is used in

    the graph. Vapi::ConversationBlock.{stepName{stepName.output/input{stepName.output/input.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::ConversationBlock.{blockName{blockName.output/input{blockName.output/input.propertyName} will reference the latest usage of the block. this liquid variable is just provided for convenience when creating blocks outside of a workflow with steps.



76
77
78
# File 'lib/vapi_server_sdk/types/conversation_block.rb', line 76

def instruction
  @instruction
end

#messagesArray<Vapi::ConversationBlockMessagesItem> (readonly)

Returns These are the pre-configured messages that will be spoken to the user while the block is running.

Returns:



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

def messages
  @messages
end

#nameString (readonly)

Returns This is the name of the block. This is just for your reference.

Returns:

  • (String)

    This is the name of the block. This is just for your reference.



46
47
48
# File 'lib/vapi_server_sdk/types/conversation_block.rb', line 46

def name
  @name
end

#org_idString (readonly)

Returns This is the unique identifier for the organization that this block belongs to.

Returns:

  • (String)

    This is the unique identifier for the organization that this block belongs to.



40
41
42
# File 'lib/vapi_server_sdk/types/conversation_block.rb', line 40

def org_id
  @org_id
end

#output_schemaVapi::JsonSchema (readonly)

This is the output schema for the block. This is the output the block will return to the workflow (‘Vapi::ConversationBlock.{stepName{stepName.output}`). These are accessible as variables:

  • (Vapi::ConversationBlock.{output{output.propertyName}) in context of the block execution (step)

  • (Vapi::ConversationBlock.{stepName{stepName.output{stepName.output.propertyName}) in context of the workflow (read caveat #1)

  • (Vapi::ConversationBlock.{blockName{blockName.output{blockName.output.propertyName}) in context of the workflow (read caveat

#2) Caveats:

  1. a workflow can execute a step multiple times. example, if a loop is used in

the graph. Vapi::ConversationBlock.{stepName{stepName.output{stepName.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::ConversationBlock.{blockName{blockName.output{blockName.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 with steps.

Returns:

  • (Vapi::JsonSchema)

    This is the output schema for the block. This is the output the block will return to the workflow (‘Vapi::ConversationBlock.{stepName{stepName.output}`). These are accessible as variables:

    • (Vapi::ConversationBlock.{output{output.propertyName}) in context of the block execution (step)

    • (Vapi::ConversationBlock.{stepName{stepName.output{stepName.output.propertyName}) in context of the workflow (read caveat #1)

    • (Vapi::ConversationBlock.{blockName{blockName.output{blockName.output.propertyName}) in context of the workflow (read caveat

    #2) Caveats:

    1. a workflow can execute a step multiple times. example, if a loop is used in

    the graph. Vapi::ConversationBlock.{stepName{stepName.output{stepName.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::ConversationBlock.{blockName{blockName.output{blockName.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 with steps.



36
37
38
# File 'lib/vapi_server_sdk/types/conversation_block.rb', line 36

def output_schema
  @output_schema
end

#updated_atDateTime (readonly)

Returns This is the ISO 8601 date-time string of when the block was last updated.

Returns:

  • (DateTime)

    This is the ISO 8601 date-time string of when the block was last updated.



44
45
46
# File 'lib/vapi_server_sdk/types/conversation_block.rb', line 44

def updated_at
  @updated_at
end

Class Method Details

.from_json(json_object:) ⇒ Vapi::ConversationBlock

Deserialize a JSON object to an instance of ConversationBlock

Parameters:

  • json_object (String)

Returns:



175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
# File 'lib/vapi_server_sdk/types/conversation_block.rb', line 175

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  messages = parsed_json["messages"]&.map do |item|
    item = item.to_json
    Vapi::ConversationBlockMessagesItem.from_json(json_object: item)
  end
  if parsed_json["inputSchema"].nil?
    input_schema = nil
  else
    input_schema = parsed_json["inputSchema"].to_json
    input_schema = Vapi::JsonSchema.from_json(json_object: input_schema)
  end
  if parsed_json["outputSchema"].nil?
    output_schema = nil
  else
    output_schema = parsed_json["outputSchema"].to_json
    output_schema = Vapi::JsonSchema.from_json(json_object: output_schema)
  end
  id = parsed_json["id"]
  org_id = parsed_json["orgId"]
  created_at = (DateTime.parse(parsed_json["createdAt"]) unless parsed_json["createdAt"].nil?)
  updated_at = (DateTime.parse(parsed_json["updatedAt"]) unless parsed_json["updatedAt"].nil?)
  name = parsed_json["name"]
  instruction = parsed_json["instruction"]
  new(
    messages: messages,
    input_schema: input_schema,
    output_schema: output_schema,
    id: id,
    org_id: org_id,
    created_at: created_at,
    updated_at: updated_at,
    name: name,
    instruction: instruction,
    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)


227
228
229
230
231
232
233
234
235
236
237
# File 'lib/vapi_server_sdk/types/conversation_block.rb', line 227

def self.validate_raw(obj:)
  obj.messages&.is_a?(Array) != false || raise("Passed value for field obj.messages is not the expected type, validation failed.")
  obj.input_schema.nil? || Vapi::JsonSchema.validate_raw(obj: obj.input_schema)
  obj.output_schema.nil? || Vapi::JsonSchema.validate_raw(obj: obj.output_schema)
  obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
  obj.org_id.is_a?(String) != false || raise("Passed value for field obj.org_id is not the expected type, validation failed.")
  obj.created_at.is_a?(DateTime) != false || raise("Passed value for field obj.created_at is not the expected type, validation failed.")
  obj.updated_at.is_a?(DateTime) != false || raise("Passed value for field obj.updated_at 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.instruction.is_a?(String) != false || raise("Passed value for field obj.instruction is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of ConversationBlock to a JSON object

Returns:

  • (String)


217
218
219
# File 'lib/vapi_server_sdk/types/conversation_block.rb', line 217

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