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:, transfer_mode: OMIT, message: OMIT, description: OMIT, additional_properties: nil) ⇒ Vapi::TransferDestinationAssistant

Parameters:

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

    This is the mode to use for the transfer. Default is ‘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`)

  • assistant_name (String)

    This is the assistant to transfer the call to.

  • message (String) (defaults to: OMIT)

    This is the message to say before transferring the call to the destination. 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.

  • 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



125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# File 'lib/vapi_server_sdk/types/transfer_destination_assistant.rb', line 125

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



65
66
67
# File 'lib/vapi_server_sdk/types/transfer_destination_assistant.rb', line 65

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.



51
52
53
# File 'lib/vapi_server_sdk/types/transfer_destination_assistant.rb', line 51

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.



63
64
65
# File 'lib/vapi_server_sdk/types/transfer_destination_assistant.rb', line 63

def description
  @description
end

#messageString (readonly)

Returns This is the message to say before transferring the call to the destination. 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.

Returns:

  • (String)

    This is the message to say before transferring the call to the destination. 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.



60
61
62
# File 'lib/vapi_server_sdk/types/transfer_destination_assistant.rb', line 60

def message
  @message
end

#transfer_modeVapi::TransferMode (readonly)

Returns This is the mode to use for the transfer. Default is ‘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`).

Returns:

  • (Vapi::TransferMode)

    This is the mode to use for the transfer. Default is ‘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`)



49
50
51
# File 'lib/vapi_server_sdk/types/transfer_destination_assistant.rb', line 49

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:



145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
# File 'lib/vapi_server_sdk/types/transfer_destination_assistant.rb', line 145

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


174
175
176
177
178
179
# File 'lib/vapi_server_sdk/types/transfer_destination_assistant.rb', line 174

def self.validate_raw(obj:)
  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.message&.is_a?(String) != false || raise("Passed value for field obj.message 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)


164
165
166
# File 'lib/vapi_server_sdk/types/transfer_destination_assistant.rb', line 164

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