Class: Vapi::CreateWebChatDto

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

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(assistant_id:, input:, session_id: OMIT, assistant_overrides: OMIT, customer: OMIT, stream: OMIT, additional_properties: nil) ⇒ Vapi::CreateWebChatDto

Parameters:

  • assistant_id (String)

    The assistant ID to use for this chat

  • session_id (String) (defaults to: OMIT)

    This is the ID of the session that will be used for the chat. If provided, the conversation will continue from the previous state. If not provided or expired, a new session will be created.

  • assistant_overrides (Vapi::ChatAssistantOverrides) (defaults to: OMIT)

    These are the variable values that will be used to replace template variables in the assistant messages. Only variable substitution is supported in web chat - other assistant properties cannot be overridden.

  • customer (Vapi::CreateWebCustomerDto) (defaults to: OMIT)

    This is the customer information for the chat. Used to automatically manage sessions for repeat customers.

  • input (Vapi::CreateWebChatDtoInput)

    This is the input text for the chat. Can be a string or an array of chat messages.

  • stream (Boolean) (defaults to: OMIT)

    This is a flag that determines whether the response should be streamed. When true, the response will be sent as chunks of text.

  • 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
69
70
71
72
73
74
# File 'lib/vapi_server_sdk/types/create_web_chat_dto.rb', line 55

def initialize(assistant_id:, input:, session_id: OMIT, assistant_overrides: OMIT, customer: OMIT, stream: OMIT,
               additional_properties: nil)
  @assistant_id = assistant_id
  @session_id = session_id if session_id != OMIT
  @assistant_overrides = assistant_overrides if assistant_overrides != OMIT
  @customer = customer if customer != OMIT
  @input = input
  @stream = stream if stream != OMIT
  @additional_properties = additional_properties
  @_field_set = {
    "assistantId": assistant_id,
    "sessionId": session_id,
    "assistantOverrides": assistant_overrides,
    "customer": customer,
    "input": input,
    "stream": stream
  }.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



32
33
34
# File 'lib/vapi_server_sdk/types/create_web_chat_dto.rb', line 32

def additional_properties
  @additional_properties
end

#assistant_idString (readonly)

Returns The assistant ID to use for this chat.

Returns:

  • (String)

    The assistant ID to use for this chat



12
13
14
# File 'lib/vapi_server_sdk/types/create_web_chat_dto.rb', line 12

def assistant_id
  @assistant_id
end

#assistant_overridesVapi::ChatAssistantOverrides (readonly)

Returns These are the variable values that will be used to replace template variables in the assistant messages. Only variable substitution is supported in web chat - other assistant properties cannot be overridden.

Returns:

  • (Vapi::ChatAssistantOverrides)

    These are the variable values that will be used to replace template variables in the assistant messages. Only variable substitution is supported in web chat - other assistant properties cannot be overridden.



21
22
23
# File 'lib/vapi_server_sdk/types/create_web_chat_dto.rb', line 21

def assistant_overrides
  @assistant_overrides
end

#customerVapi::CreateWebCustomerDto (readonly)

Returns This is the customer information for the chat. Used to automatically manage sessions for repeat customers.

Returns:

  • (Vapi::CreateWebCustomerDto)

    This is the customer information for the chat. Used to automatically manage sessions for repeat customers.



24
25
26
# File 'lib/vapi_server_sdk/types/create_web_chat_dto.rb', line 24

def customer
  @customer
end

#inputVapi::CreateWebChatDtoInput (readonly)

Returns This is the input text for the chat. Can be a string or an array of chat messages.

Returns:



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

def input
  @input
end

#session_idString (readonly)

Returns This is the ID of the session that will be used for the chat. If provided, the conversation will continue from the previous state. If not provided or expired, a new session will be created.

Returns:

  • (String)

    This is the ID of the session that will be used for the chat. If provided, the conversation will continue from the previous state. If not provided or expired, a new session will be created.



16
17
18
# File 'lib/vapi_server_sdk/types/create_web_chat_dto.rb', line 16

def session_id
  @session_id
end

#streamBoolean (readonly)

Returns This is a flag that determines whether the response should be streamed. When true, the response will be sent as chunks of text.

Returns:

  • (Boolean)

    This is a flag that determines whether the response should be streamed. When true, the response will be sent as chunks of text.



30
31
32
# File 'lib/vapi_server_sdk/types/create_web_chat_dto.rb', line 30

def stream
  @stream
end

Class Method Details

.from_json(json_object:) ⇒ Vapi::CreateWebChatDto

Deserialize a JSON object to an instance of CreateWebChatDto

Parameters:

  • json_object (String)

Returns:



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/vapi_server_sdk/types/create_web_chat_dto.rb', line 80

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  assistant_id = parsed_json["assistantId"]
  session_id = parsed_json["sessionId"]
  if parsed_json["assistantOverrides"].nil?
    assistant_overrides = nil
  else
    assistant_overrides = parsed_json["assistantOverrides"].to_json
    assistant_overrides = Vapi::ChatAssistantOverrides.from_json(json_object: assistant_overrides)
  end
  if parsed_json["customer"].nil?
    customer = nil
  else
    customer = parsed_json["customer"].to_json
    customer = Vapi::CreateWebCustomerDto.from_json(json_object: customer)
  end
  if parsed_json["input"].nil?
    input = nil
  else
    input = parsed_json["input"].to_json
    input = Vapi::CreateWebChatDtoInput.from_json(json_object: input)
  end
  stream = parsed_json["stream"]
  new(
    assistant_id: assistant_id,
    session_id: session_id,
    assistant_overrides: assistant_overrides,
    customer: customer,
    input: input,
    stream: stream,
    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)


128
129
130
131
132
133
134
135
# File 'lib/vapi_server_sdk/types/create_web_chat_dto.rb', line 128

def self.validate_raw(obj:)
  obj.assistant_id.is_a?(String) != false || raise("Passed value for field obj.assistant_id is not the expected type, validation failed.")
  obj.session_id&.is_a?(String) != false || raise("Passed value for field obj.session_id is not the expected type, validation failed.")
  obj.assistant_overrides.nil? || Vapi::ChatAssistantOverrides.validate_raw(obj: obj.assistant_overrides)
  obj.customer.nil? || Vapi::CreateWebCustomerDto.validate_raw(obj: obj.customer)
  Vapi::CreateWebChatDtoInput.validate_raw(obj: obj.input)
  obj.stream&.is_a?(Boolean) != false || raise("Passed value for field obj.stream is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of CreateWebChatDto to a JSON object

Returns:

  • (String)


118
119
120
# File 'lib/vapi_server_sdk/types/create_web_chat_dto.rb', line 118

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