Class: Vapi::MessagePlan

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

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(idle_messages: OMIT, idle_message_max_spoken_count: OMIT, idle_message_reset_count_on_user_speech_enabled: OMIT, idle_timeout_seconds: OMIT, silence_timeout_message: OMIT, additional_properties: nil) ⇒ Vapi::MessagePlan

Parameters:

  • idle_messages (Array<String>) (defaults to: OMIT)

    This are the messages that the assistant will speak when the user hasn’t responded for ‘idleTimeoutSeconds`. Each time the timeout is triggered, a random message will be chosen from this array. Usage:

    • If user gets distracted and doesn’t respond for a while, this can be used to

    grab their attention.

    • If the transcriber doesn’t pick up what the user said, this can be used to ask

    the user to repeat themselves. (From the perspective of the assistant, the conversation is idle since it didn’t “hear” any user messages.) @default null (no idle message is spoken)

  • idle_message_max_spoken_count (Float) (defaults to: OMIT)

    This determines the maximum number of times ‘idleMessages` can be spoken during the call. @default 3

  • idle_message_reset_count_on_user_speech_enabled (Boolean) (defaults to: OMIT)

    This determines whether the idle message count is reset whenever the user speaks. @default false

  • idle_timeout_seconds (Float) (defaults to: OMIT)

    This is the timeout in seconds before a message from ‘idleMessages` is spoken. The clock starts when the assistant finishes speaking and remains active until the user speaks. @default 10

  • silence_timeout_message (String) (defaults to: OMIT)

    This is the message that the assistant will say if the call ends due to silence. If unspecified, it will hang up without saying anything.

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/vapi_server_sdk/types/message_plan.rb', line 67

def initialize(idle_messages: OMIT, idle_message_max_spoken_count: OMIT,
               idle_message_reset_count_on_user_speech_enabled: OMIT, idle_timeout_seconds: OMIT, silence_timeout_message: OMIT, additional_properties: nil)
  @idle_messages = idle_messages if idle_messages != OMIT
  @idle_message_max_spoken_count = idle_message_max_spoken_count if idle_message_max_spoken_count != OMIT
  if idle_message_reset_count_on_user_speech_enabled != OMIT
    @idle_message_reset_count_on_user_speech_enabled = idle_message_reset_count_on_user_speech_enabled
  end
  @idle_timeout_seconds = idle_timeout_seconds if idle_timeout_seconds != OMIT
  @silence_timeout_message = silence_timeout_message if silence_timeout_message != OMIT
  @additional_properties = additional_properties
  @_field_set = {
    "idleMessages": idle_messages,
    "idleMessageMaxSpokenCount": idle_message_max_spoken_count,
    "idleMessageResetCountOnUserSpeechEnabled": idle_message_reset_count_on_user_speech_enabled,
    "idleTimeoutSeconds": idle_timeout_seconds,
    "silenceTimeoutMessage": silence_timeout_message
  }.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



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

def additional_properties
  @additional_properties
end

#idle_message_max_spoken_countFloat (readonly)

Returns This determines the maximum number of times ‘idleMessages` can be spoken during the call. @default 3.

Returns:

  • (Float)

    This determines the maximum number of times ‘idleMessages` can be spoken during the call. @default 3



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

def idle_message_max_spoken_count
  @idle_message_max_spoken_count
end

#idle_message_reset_count_on_user_speech_enabledBoolean (readonly)

Returns This determines whether the idle message count is reset whenever the user speaks. @default false.

Returns:

  • (Boolean)

    This determines whether the idle message count is reset whenever the user speaks. @default false



26
27
28
# File 'lib/vapi_server_sdk/types/message_plan.rb', line 26

def idle_message_reset_count_on_user_speech_enabled
  @idle_message_reset_count_on_user_speech_enabled
end

#idle_messagesArray<String> (readonly)

Returns This are the messages that the assistant will speak when the user hasn’t responded for ‘idleTimeoutSeconds`. Each time the timeout is triggered, a random message will be chosen from this array. Usage:

  • If user gets distracted and doesn’t respond for a while, this can be used to

grab their attention.

  • If the transcriber doesn’t pick up what the user said, this can be used to ask

the user to repeat themselves. (From the perspective of the assistant, the conversation is idle since it didn’t “hear” any user messages.) @default null (no idle message is spoken).

Returns:

  • (Array<String>)

    This are the messages that the assistant will speak when the user hasn’t responded for ‘idleTimeoutSeconds`. Each time the timeout is triggered, a random message will be chosen from this array. Usage:

    • If user gets distracted and doesn’t respond for a while, this can be used to

    grab their attention.

    • If the transcriber doesn’t pick up what the user said, this can be used to ask

    the user to repeat themselves. (From the perspective of the assistant, the conversation is idle since it didn’t “hear” any user messages.) @default null (no idle message is spoken)



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

def idle_messages
  @idle_messages
end

#idle_timeout_secondsFloat (readonly)

Returns This is the timeout in seconds before a message from ‘idleMessages` is spoken. The clock starts when the assistant finishes speaking and remains active until the user speaks. @default 10.

Returns:

  • (Float)

    This is the timeout in seconds before a message from ‘idleMessages` is spoken. The clock starts when the assistant finishes speaking and remains active until the user speaks. @default 10



31
32
33
# File 'lib/vapi_server_sdk/types/message_plan.rb', line 31

def idle_timeout_seconds
  @idle_timeout_seconds
end

#silence_timeout_messageString (readonly)

Returns This is the message that the assistant will say if the call ends due to silence. If unspecified, it will hang up without saying anything.

Returns:

  • (String)

    This is the message that the assistant will say if the call ends due to silence. If unspecified, it will hang up without saying anything.



34
35
36
# File 'lib/vapi_server_sdk/types/message_plan.rb', line 34

def silence_timeout_message
  @silence_timeout_message
end

Class Method Details

.from_json(json_object:) ⇒ Vapi::MessagePlan

Deserialize a JSON object to an instance of MessagePlan

Parameters:

  • json_object (String)

Returns:



92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'lib/vapi_server_sdk/types/message_plan.rb', line 92

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  idle_messages = parsed_json["idleMessages"]
  idle_message_max_spoken_count = parsed_json["idleMessageMaxSpokenCount"]
  idle_message_reset_count_on_user_speech_enabled = parsed_json["idleMessageResetCountOnUserSpeechEnabled"]
  idle_timeout_seconds = parsed_json["idleTimeoutSeconds"]
  silence_timeout_message = parsed_json["silenceTimeoutMessage"]
  new(
    idle_messages: idle_messages,
    idle_message_max_spoken_count: idle_message_max_spoken_count,
    idle_message_reset_count_on_user_speech_enabled: idle_message_reset_count_on_user_speech_enabled,
    idle_timeout_seconds: idle_timeout_seconds,
    silence_timeout_message: silence_timeout_message,
    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)


123
124
125
126
127
128
129
# File 'lib/vapi_server_sdk/types/message_plan.rb', line 123

def self.validate_raw(obj:)
  obj.idle_messages&.is_a?(Array) != false || raise("Passed value for field obj.idle_messages is not the expected type, validation failed.")
  obj.idle_message_max_spoken_count&.is_a?(Float) != false || raise("Passed value for field obj.idle_message_max_spoken_count is not the expected type, validation failed.")
  obj.idle_message_reset_count_on_user_speech_enabled&.is_a?(Boolean) != false || raise("Passed value for field obj.idle_message_reset_count_on_user_speech_enabled is not the expected type, validation failed.")
  obj.idle_timeout_seconds&.is_a?(Float) != false || raise("Passed value for field obj.idle_timeout_seconds is not the expected type, validation failed.")
  obj.silence_timeout_message&.is_a?(String) != false || raise("Passed value for field obj.silence_timeout_message is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of MessagePlan to a JSON object

Returns:

  • (String)


113
114
115
# File 'lib/vapi_server_sdk/types/message_plan.rb', line 113

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