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

    • ‘swap-system-message-in-history-and-remove-transfer-tool-messages`: This

    replaces the original system message with the new assistant’s system message on transfer and removes transfer tool messages from conversation history sent to the LLM. 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 transfer-tool transfer-tool-result 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`) @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



212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
# File 'lib/vapi_server_sdk/types/transfer_destination_assistant.rb', line 212

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



109
110
111
# File 'lib/vapi_server_sdk/types/transfer_destination_assistant.rb', line 109

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.



104
105
106
# File 'lib/vapi_server_sdk/types/transfer_destination_assistant.rb', line 104

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.



107
108
109
# File 'lib/vapi_server_sdk/types/transfer_destination_assistant.rb', line 107

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

  • ‘swap-system-message-in-history-and-remove-transfer-tool-messages`: This

replaces the original system message with the new assistant’s system message on transfer and removes transfer tool messages from conversation history sent to the LLM. 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 transfer-tool transfer-tool-result 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`) @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

    • ‘swap-system-message-in-history-and-remove-transfer-tool-messages`: This

    replaces the original system message with the new assistant’s system message on transfer and removes transfer tool messages from conversation history sent to the LLM. 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 transfer-tool transfer-tool-result 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`) @default ’rolling-history’



102
103
104
# File 'lib/vapi_server_sdk/types/transfer_destination_assistant.rb', line 102

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:



232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
# File 'lib/vapi_server_sdk/types/transfer_destination_assistant.rb', line 232

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)


266
267
268
269
270
271
# File 'lib/vapi_server_sdk/types/transfer_destination_assistant.rb', line 266

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)


256
257
258
# File 'lib/vapi_server_sdk/types/transfer_destination_assistant.rb', line 256

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