Class: Vapi::TransferDestinationNumber

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

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(number:, number_e_164_check_enabled: OMIT, extension: OMIT, caller_id: OMIT, message: OMIT, description: OMIT, additional_properties: nil) ⇒ Vapi::TransferDestinationNumber

Parameters:

  • number_e_164_check_enabled (Boolean) (defaults to: OMIT)

    This is the flag to toggle the E164 check for the ‘number` field. This is an advanced property which should be used if you know your use case requires it. Use cases:

    • ‘false`: To allow non-E164 numbers like `+001234567890`, `1234`, or `abc`.

    This is useful for dialing out to non-E164 numbers on your SIP trunks.

    • ‘true` (default): To allow only E164 numbers like `+14155551234`. This is

    standard for PSTN calls. If ‘false`, the `number` is still required to only contain alphanumeric characters (regex: `/^+?[a-zA-Z0-9]+$/`). @default true (E164 check is enabled)

  • number (String)

    This is the phone number to transfer the call to.

  • extension (String) (defaults to: OMIT)

    This is the extension to dial after transferring the call to the ‘number`.

  • caller_id (String) (defaults to: OMIT)

    This is the caller ID to use when transferring the call to the ‘number`. Usage:

    • If not provided, the caller ID will be the number the call is coming from.

    Example, 14151111111 calls in to and the assistant transfers out to 16470000000. 16470000000 will see 14151111111 as the caller.

    • To change this behavior, provide a ‘callerId`.

    • Set to ‘Vapi::TransferDestinationNumber.{customer{customer.number}’ to always use the customer’s number as the caller

    ID.

    • Set to ‘Vapi::TransferDestinationNumber.{phoneNumber{phoneNumber.number}’ to always use the phone number of the

    assistant as the caller ID.

    • Set to any E164 number to always use that number as the caller ID. This needs

    to be a number that is owned or verified by your Transport provider like Twilio. For Twilio, you can read up more here: www.twilio.com/docs/voice/twiml/dial#callerid

  • 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



96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# File 'lib/vapi_server_sdk/types/transfer_destination_number.rb', line 96

def initialize(number:, number_e_164_check_enabled: OMIT, extension: OMIT, caller_id: OMIT, message: OMIT,
               description: OMIT, additional_properties: nil)
  @number_e_164_check_enabled = number_e_164_check_enabled if number_e_164_check_enabled != OMIT
  @number = number
  @extension = extension if extension != OMIT
  @caller_id = caller_id if caller_id != OMIT
  @message = message if message != OMIT
  @description = description if description != OMIT
  @additional_properties = additional_properties
  @_field_set = {
    "numberE164CheckEnabled": number_e_164_check_enabled,
    "number": number,
    "extension": extension,
    "callerId": caller_id,
    "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



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

def additional_properties
  @additional_properties
end

#caller_idString (readonly)

Returns This is the caller ID to use when transferring the call to the ‘number`. Usage:

  • If not provided, the caller ID will be the number the call is coming from.

Example, 14151111111 calls in to and the assistant transfers out to 16470000000. 16470000000 will see 14151111111 as the caller.

  • To change this behavior, provide a ‘callerId`.

  • Set to ‘Vapi::TransferDestinationNumber.{customer{customer.number}’ to always use the customer’s number as the caller

ID.

  • Set to ‘Vapi::TransferDestinationNumber.{phoneNumber{phoneNumber.number}’ to always use the phone number of the

assistant as the caller ID.

  • Set to any E164 number to always use that number as the caller ID. This needs

to be a number that is owned or verified by your Transport provider like Twilio. For Twilio, you can read up more here: www.twilio.com/docs/voice/twiml/dial#callerid.

Returns:

  • (String)

    This is the caller ID to use when transferring the call to the ‘number`. Usage:

    • If not provided, the caller ID will be the number the call is coming from.

    Example, 14151111111 calls in to and the assistant transfers out to 16470000000. 16470000000 will see 14151111111 as the caller.

    • To change this behavior, provide a ‘callerId`.

    • Set to ‘Vapi::TransferDestinationNumber.{customer{customer.number}’ to always use the customer’s number as the caller

    ID.

    • Set to ‘Vapi::TransferDestinationNumber.{phoneNumber{phoneNumber.number}’ to always use the phone number of the

    assistant as the caller ID.

    • Set to any E164 number to always use that number as the caller ID. This needs

    to be a number that is owned or verified by your Transport provider like Twilio. For Twilio, you can read up more here: www.twilio.com/docs/voice/twiml/dial#callerid



37
38
39
# File 'lib/vapi_server_sdk/types/transfer_destination_number.rb', line 37

def caller_id
  @caller_id
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.



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

def description
  @description
end

#extensionString (readonly)

Returns This is the extension to dial after transferring the call to the ‘number`.

Returns:

  • (String)

    This is the extension to dial after transferring the call to the ‘number`.



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

def extension
  @extension
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.



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

def message
  @message
end

#numberString (readonly)

Returns This is the phone number to transfer the call to.

Returns:

  • (String)

    This is the phone number to transfer the call to.



20
21
22
# File 'lib/vapi_server_sdk/types/transfer_destination_number.rb', line 20

def number
  @number
end

#number_e_164_check_enabledBoolean (readonly)

Returns This is the flag to toggle the E164 check for the ‘number` field. This is an advanced property which should be used if you know your use case requires it. Use cases:

  • ‘false`: To allow non-E164 numbers like `+001234567890`, `1234`, or `abc`.

This is useful for dialing out to non-E164 numbers on your SIP trunks.

  • ‘true` (default): To allow only E164 numbers like `+14155551234`. This is

standard for PSTN calls. If ‘false`, the `number` is still required to only contain alphanumeric characters (regex: `/^+?[a-zA-Z0-9]+$/`). @default true (E164 check is enabled).

Returns:

  • (Boolean)

    This is the flag to toggle the E164 check for the ‘number` field. This is an advanced property which should be used if you know your use case requires it. Use cases:

    • ‘false`: To allow non-E164 numbers like `+001234567890`, `1234`, or `abc`.

    This is useful for dialing out to non-E164 numbers on your SIP trunks.

    • ‘true` (default): To allow only E164 numbers like `+14155551234`. This is

    standard for PSTN calls. If ‘false`, the `number` is still required to only contain alphanumeric characters (regex: `/^+?[a-zA-Z0-9]+$/`). @default true (E164 check is enabled)



18
19
20
# File 'lib/vapi_server_sdk/types/transfer_destination_number.rb', line 18

def number_e_164_check_enabled
  @number_e_164_check_enabled
end

Class Method Details

.from_json(json_object:) ⇒ Vapi::TransferDestinationNumber

Deserialize a JSON object to an instance of TransferDestinationNumber

Parameters:

  • json_object (String)

Returns:



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

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  number_e_164_check_enabled = parsed_json["numberE164CheckEnabled"]
  number = parsed_json["number"]
  extension = parsed_json["extension"]
  caller_id = parsed_json["callerId"]
  message = parsed_json["message"]
  description = parsed_json["description"]
  new(
    number_e_164_check_enabled: number_e_164_check_enabled,
    number: number,
    extension: extension,
    caller_id: caller_id,
    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)


154
155
156
157
158
159
160
161
# File 'lib/vapi_server_sdk/types/transfer_destination_number.rb', line 154

def self.validate_raw(obj:)
  obj.number_e_164_check_enabled&.is_a?(Boolean) != false || raise("Passed value for field obj.number_e_164_check_enabled is not the expected type, validation failed.")
  obj.number.is_a?(String) != false || raise("Passed value for field obj.number is not the expected type, validation failed.")
  obj.extension&.is_a?(String) != false || raise("Passed value for field obj.extension is not the expected type, validation failed.")
  obj.caller_id&.is_a?(String) != false || raise("Passed value for field obj.caller_id 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 TransferDestinationNumber to a JSON object

Returns:

  • (String)


144
145
146
# File 'lib/vapi_server_sdk/types/transfer_destination_number.rb', line 144

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