Class: Vapi::TransferDestinationAssistant

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

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(assistant_name:, message: OMIT, transfer_mode: OMIT, description: OMIT, additional_properties: nil) ⇒ Vapi::TransferDestinationAssistant

Parameters:

  • message (Vapi::TransferDestinationAssistantMessage) (defaults to: OMIT)

    This is spoken to the customer before connecting them to the destination. Usage:

    • If this is not provided and transfer tool messages is not provided, default is

    “Transferring the call now”.

    • If set to “”, nothing is spoken. This is useful when you want to silently

    transfer. This is especially useful when transferring between assistants in a squad. In this scenario, you likely also want to set ‘assistant.firstMessageMode=assistant-speaks-first-with-model-generated-message` for the destination assistant. This accepts a string or a ToolMessageStart class. Latter is useful if you want to specify multiple messages for different languages through the contents field.

  • transfer_mode (Vapi::TransferMode) (defaults to: OMIT)

    This is the mode to use for the transfer. Defaults to rolling-history.

    • rolling-history: This is the default mode. It keeps the entire conversation

    history and appends the new assistant’s system message on transfer. Example: Pre-transfer: system: assistant1 system message assistant: assistant1 first message user: hey, good morning assistant: how can i help? user: i need help with my account assistant: (destination.message) Post-transfer: system: assistant1 system message assistant: assistant1 first message user: hey, good morning assistant: how can i help? user: i need help with my account assistant: (destination.message) system: assistant2 system message assistant: assistant2 first message (or model generated if firstMessageMode is set to assistant-speaks-first-with-model-generated-message)

    • swap-system-message-in-history: This replaces the original system message

    with the new assistant’s system message on transfer. Example: Pre-transfer: system: assistant1 system message assistant: assistant1 first message user: hey, good morning assistant: how can i help? user: i need help with my account assistant: (destination.message) Post-transfer: system: assistant2 system message assistant: assistant1 first message user: hey, good morning assistant: how can i help? user: i need help with my account assistant: (destination.message) assistant: assistant2 first message (or model generated if firstMessageMode is set to assistant-speaks-first-with-model-generated-message)

    • delete-history: This deletes the entire conversation history on transfer.

    Example: Pre-transfer: system: assistant1 system message assistant: assistant1 first message user: hey, good morning assistant: how can i help? user: i need help with my account assistant: (destination.message) Post-transfer: system: assistant2 system message assistant: assistant2 first message user: Yes, please assistant: how can i help? user: i need help with my account @default ‘rolling-history’

  • assistant_name (String)

    This is the assistant to transfer the call to.

  • description (String) (defaults to: OMIT)

    This is the description of the destination, used by the AI to choose when and how to transfer the call.

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
# File 'lib/vapi_server_sdk/types/transfer_destination_assistant.rb', line 166

def initialize(assistant_name:, message: OMIT, transfer_mode: OMIT, description: OMIT, additional_properties: nil)
  @message = message if message != OMIT
  @transfer_mode = transfer_mode if transfer_mode != OMIT
  @assistant_name = assistant_name
  @description = description if description != OMIT
  @additional_properties = additional_properties
  @_field_set = {
    "message": message,
    "transferMode": transfer_mode,
    "assistantName": assistant_name,
    "description": description
  }.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



86
87
88
# File 'lib/vapi_server_sdk/types/transfer_destination_assistant.rb', line 86

def additional_properties
  @additional_properties
end

#assistant_nameString (readonly)

Returns This is the assistant to transfer the call to.

Returns:

  • (String)

    This is the assistant to transfer the call to.



81
82
83
# File 'lib/vapi_server_sdk/types/transfer_destination_assistant.rb', line 81

def assistant_name
  @assistant_name
end

#descriptionString (readonly)

Returns This is the description of the destination, used by the AI to choose when and how to transfer the call.

Returns:

  • (String)

    This is the description of the destination, used by the AI to choose when and how to transfer the call.



84
85
86
# File 'lib/vapi_server_sdk/types/transfer_destination_assistant.rb', line 84

def description
  @description
end

#messageVapi::TransferDestinationAssistantMessage (readonly)

Returns This is spoken to the customer before connecting them to the destination. Usage:

  • If this is not provided and transfer tool messages is not provided, default is

“Transferring the call now”.

  • If set to “”, nothing is spoken. This is useful when you want to silently

transfer. This is especially useful when transferring between assistants in a squad. In this scenario, you likely also want to set ‘assistant.firstMessageMode=assistant-speaks-first-with-model-generated-message` for the destination assistant. This accepts a string or a ToolMessageStart class. Latter is useful if you want to specify multiple messages for different languages through the contents field.

Returns:

  • (Vapi::TransferDestinationAssistantMessage)

    This is spoken to the customer before connecting them to the destination. Usage:

    • If this is not provided and transfer tool messages is not provided, default is

    “Transferring the call now”.

    • If set to “”, nothing is spoken. This is useful when you want to silently

    transfer. This is especially useful when transferring between assistants in a squad. In this scenario, you likely also want to set ‘assistant.firstMessageMode=assistant-speaks-first-with-model-generated-message` for the destination assistant. This accepts a string or a ToolMessageStart class. Latter is useful if you want to specify multiple messages for different languages through the contents field.



22
23
24
# File 'lib/vapi_server_sdk/types/transfer_destination_assistant.rb', line 22

def message
  @message
end

#transfer_modeVapi::TransferMode (readonly)

Returns This is the mode to use for the transfer. Defaults to rolling-history.

  • rolling-history: This is the default mode. It keeps the entire conversation

history and appends the new assistant’s system message on transfer. Example: Pre-transfer: system: assistant1 system message assistant: assistant1 first message user: hey, good morning assistant: how can i help? user: i need help with my account assistant: (destination.message) Post-transfer: system: assistant1 system message assistant: assistant1 first message user: hey, good morning assistant: how can i help? user: i need help with my account assistant: (destination.message) system: assistant2 system message assistant: assistant2 first message (or model generated if firstMessageMode is set to assistant-speaks-first-with-model-generated-message)

  • swap-system-message-in-history: This replaces the original system message

with the new assistant’s system message on transfer. Example: Pre-transfer: system: assistant1 system message assistant: assistant1 first message user: hey, good morning assistant: how can i help? user: i need help with my account assistant: (destination.message) Post-transfer: system: assistant2 system message assistant: assistant1 first message user: hey, good morning assistant: how can i help? user: i need help with my account assistant: (destination.message) assistant: assistant2 first message (or model generated if firstMessageMode is set to assistant-speaks-first-with-model-generated-message)

  • delete-history: This deletes the entire conversation history on transfer.

Example: Pre-transfer: system: assistant1 system message assistant: assistant1 first message user: hey, good morning assistant: how can i help? user: i need help with my account assistant: (destination.message) Post-transfer: system: assistant2 system message assistant: assistant2 first message user: Yes, please assistant: how can i help? user: i need help with my account @default ‘rolling-history’.

Returns:

  • (Vapi::TransferMode)

    This is the mode to use for the transfer. Defaults to rolling-history.

    • rolling-history: This is the default mode. It keeps the entire conversation

    history and appends the new assistant’s system message on transfer. Example: Pre-transfer: system: assistant1 system message assistant: assistant1 first message user: hey, good morning assistant: how can i help? user: i need help with my account assistant: (destination.message) Post-transfer: system: assistant1 system message assistant: assistant1 first message user: hey, good morning assistant: how can i help? user: i need help with my account assistant: (destination.message) system: assistant2 system message assistant: assistant2 first message (or model generated if firstMessageMode is set to assistant-speaks-first-with-model-generated-message)

    • swap-system-message-in-history: This replaces the original system message

    with the new assistant’s system message on transfer. Example: Pre-transfer: system: assistant1 system message assistant: assistant1 first message user: hey, good morning assistant: how can i help? user: i need help with my account assistant: (destination.message) Post-transfer: system: assistant2 system message assistant: assistant1 first message user: hey, good morning assistant: how can i help? user: i need help with my account assistant: (destination.message) assistant: assistant2 first message (or model generated if firstMessageMode is set to assistant-speaks-first-with-model-generated-message)

    • delete-history: This deletes the entire conversation history on transfer.

    Example: Pre-transfer: system: assistant1 system message assistant: assistant1 first message user: hey, good morning assistant: how can i help? user: i need help with my account assistant: (destination.message) Post-transfer: system: assistant2 system message assistant: assistant2 first message user: Yes, please assistant: how can i help? user: i need help with my account @default ‘rolling-history’



79
80
81
# File 'lib/vapi_server_sdk/types/transfer_destination_assistant.rb', line 79

def transfer_mode
  @transfer_mode
end

Class Method Details

.from_json(json_object:) ⇒ Vapi::TransferDestinationAssistant

Deserialize a JSON object to an instance of TransferDestinationAssistant

Parameters:

  • json_object (String)

Returns:



186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
# File 'lib/vapi_server_sdk/types/transfer_destination_assistant.rb', line 186

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  if parsed_json["message"].nil?
    message = nil
  else
    message = parsed_json["message"].to_json
    message = Vapi::TransferDestinationAssistantMessage.from_json(json_object: message)
  end
  transfer_mode = parsed_json["transferMode"]
  assistant_name = parsed_json["assistantName"]
  description = parsed_json["description"]
  new(
    message: message,
    transfer_mode: transfer_mode,
    assistant_name: assistant_name,
    description: description,
    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)


220
221
222
223
224
225
# File 'lib/vapi_server_sdk/types/transfer_destination_assistant.rb', line 220

def self.validate_raw(obj:)
  obj.message.nil? || Vapi::TransferDestinationAssistantMessage.validate_raw(obj: obj.message)
  obj.transfer_mode&.is_a?(Vapi::TransferMode) != false || raise("Passed value for field obj.transfer_mode is not the expected type, validation failed.")
  obj.assistant_name.is_a?(String) != false || raise("Passed value for field obj.assistant_name is not the expected type, validation failed.")
  obj.description&.is_a?(String) != false || raise("Passed value for field obj.description is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of TransferDestinationAssistant to a JSON object

Returns:

  • (String)


210
211
212
# File 'lib/vapi_server_sdk/types/transfer_destination_assistant.rb', line 210

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