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_timeout_seconds: 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_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

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/vapi_server_sdk/types/message_plan.rb', line 55

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



29
30
31
# File 'lib/vapi_server_sdk/types/message_plan.rb', line 29

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_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



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

def idle_timeout_seconds
  @idle_timeout_seconds
end

Class Method Details

.from_json(json_object:) ⇒ Vapi::MessagePlan

Deserialize a JSON object to an instance of MessagePlan

Parameters:

  • json_object (String)

Returns:



74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/vapi_server_sdk/types/message_plan.rb', line 74

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_timeout_seconds = parsed_json["idleTimeoutSeconds"]
  new(
    idle_messages: idle_messages,
    idle_message_max_spoken_count: idle_message_max_spoken_count,
    idle_timeout_seconds: idle_timeout_seconds,
    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)


101
102
103
104
105
# File 'lib/vapi_server_sdk/types/message_plan.rb', line 101

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_timeout_seconds&.is_a?(Float) != false || raise("Passed value for field obj.idle_timeout_seconds 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)


91
92
93
# File 'lib/vapi_server_sdk/types/message_plan.rb', line 91

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