Class: Vapi::ChatsClient

Inherits:
Object
  • Object
show all
Defined in:
lib/vapi_server_sdk/chats/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(request_client:) ⇒ Vapi::ChatsClient

Parameters:



23
24
25
# File 'lib/vapi_server_sdk/chats/client.rb', line 23

def initialize(request_client:)
  @request_client = request_client
end

Instance Attribute Details

#request_clientVapi::RequestClient (readonly)

Returns:



19
20
21
# File 'lib/vapi_server_sdk/chats/client.rb', line 19

def request_client
  @request_client
end

Instance Method Details

#create(input:, assistant_id: nil, assistant: nil, assistant_overrides: nil, name: nil, session_id: nil, stream: nil, previous_chat_id: nil, request_options: nil) ⇒ Vapi::Chat, Vapi::CreateChatStreamResponse

Creates a new chat. Requires at least one of: assistantId/assistant, sessionId,

or previousChatId. Note: sessionId and previousChatId are mutually exclusive.

Parameters:

  • assistant_id (String) (defaults to: nil)

    This is the assistant that will be used for the chat. To use an existing assistant, use ‘assistantId` instead.

  • assistant (Hash) (defaults to: nil)

    This is the assistant that will be used for the chat. To use an existing assistant, use ‘assistantId` instead.Request of type Vapi::CreateAssistantDto, as a Hash

    * :transcriber (Hash)
    * :model (Hash)
    * :voice (Hash)
    * :first_message (String)
    * :first_message_interruptions_enabled (Boolean)
    * :first_message_mode (Vapi::CreateAssistantDtoFirstMessageMode)
    * :voicemail_detection (Hash)
    * :client_messages (Array<Vapi::CreateAssistantDtoClientMessagesItem>)
    * :server_messages (Array<Vapi::CreateAssistantDtoServerMessagesItem>)
    * :silence_timeout_seconds (Float)
    * :max_duration_seconds (Float)
    * :background_sound (Hash)
    * :background_denoising_enabled (Boolean)
    * :model_output_in_messages_enabled (Boolean)
    * :transport_configurations (Array<Vapi::TransportConfigurationTwilio>)
    * :observability_plan (Hash)
      * :provider (String)
      * :tags (Array<String>)
      * :metadata (Hash{String => Object})
    * :credentials (Array<Vapi::CreateAssistantDtoCredentialsItem>)
    * :hooks (Array<Vapi::CreateAssistantDtoHooksItem>)
    * :name (String)
    * :voicemail_message (String)
    * :end_call_message (String)
    * :end_call_phrases (Array<String>)
    * :compliance_plan (Hash)
      * :hipaa_enabled (Boolean)
      * :pci_enabled (Boolean)
    * :metadata (Hash{String => Object})
    * :background_speech_denoising_plan (Hash)
      * :smart_denoising_plan (Hash)
        * :enabled (Boolean)
      * :fourier_denoising_plan (Hash)
        * :enabled (Boolean)
        * :media_detection_enabled (Boolean)
        * :static_threshold (Float)
        * :baseline_offset_db (Float)
        * :window_size_ms (Float)
        * :baseline_percentile (Float)
    * :analysis_plan (Hash)
      * :min_messages_threshold (Float)
      * :summary_plan (Hash)
        * :messages (Array<Hash{String => Object}>)
        * :enabled (Boolean)
        * :timeout_seconds (Float)
      * :structured_data_plan (Hash)
        * :messages (Array<Hash{String => Object}>)
        * :enabled (Boolean)
        * :schema (Hash)
          * :type (Vapi::JsonSchemaType)
          * :items (Hash{String => Object})
          * :properties (Hash{String => Object})
          * :description (String)
          * :pattern (String)
          * :format (Vapi::JsonSchemaFormat)
          * :required (Array<String>)
          * :enum (Array<String>)
          * :title (String)
        * :timeout_seconds (Float)
      * :structured_data_multi_plan (Array<Vapi::StructuredDataMultiPlan>)
      * :success_evaluation_plan (Hash)
        * :rubric (Vapi::SuccessEvaluationPlanRubric)
        * :messages (Array<Hash{String => Object}>)
        * :enabled (Boolean)
        * :timeout_seconds (Float)
    * :artifact_plan (Hash)
      * :recording_enabled (Boolean)
      * :recording_format (Vapi::ArtifactPlanRecordingFormat)
      * :video_recording_enabled (Boolean)
      * :pcap_enabled (Boolean)
      * :pcap_s_3_path_prefix (String)
      * :transcript_plan (Hash)
        * :enabled (Boolean)
        * :assistant_name (String)
        * :user_name (String)
      * :recording_path (String)
    * :message_plan (Hash)
      * :idle_messages (Array<String>)
      * :idle_message_max_spoken_count (Float)
      * :idle_message_reset_count_on_user_speech_enabled (Boolean)
      * :idle_timeout_seconds (Float)
      * :silence_timeout_message (String)
    * :start_speaking_plan (Hash)
      * :wait_seconds (Float)
      * :smart_endpointing_enabled (Hash)
      * :smart_endpointing_plan (Hash)
      * :custom_endpointing_rules (Array<Vapi::StartSpeakingPlanCustomEndpointingRulesItem>)
      * :transcription_endpointing_plan (Hash)
        * :on_punctuation_seconds (Float)
        * :on_no_punctuation_seconds (Float)
        * :on_number_seconds (Float)
    * :stop_speaking_plan (Hash)
      * :num_words (Float)
      * :voice_seconds (Float)
      * :backoff_seconds (Float)
      * :acknowledgement_phrases (Array<String>)
      * :interruption_phrases (Array<String>)
    * :monitor_plan (Hash)
      * :listen_enabled (Boolean)
      * :listen_authentication_enabled (Boolean)
      * :control_enabled (Boolean)
      * :control_authentication_enabled (Boolean)
    * :credential_ids (Array<String>)
    * :server (Hash)
      * :timeout_seconds (Float)
      * :url (String)
      * :headers (Hash{String => Object})
      * :backoff_plan (Hash)
        * :type (Hash{String => Object})
        * :max_retries (Float)
        * :base_delay_seconds (Float)
    * :keypad_input_plan (Hash)
      * :enabled (Boolean)
      * :timeout_seconds (Float)
      * :delimiters (Vapi::KeypadInputPlanDelimiters)
    
  • assistant_overrides (Hash) (defaults to: nil)

    These are the variable values that will be used to replace template variables in the assistant messages. Only variable substitution is supported in chat contexts - other assistant properties cannot be overridden.Request of type Vapi::AssistantOverrides, as a Hash

    * :transcriber (Hash)
    * :model (Hash)
    * :voice (Hash)
    * :first_message (String)
    * :first_message_interruptions_enabled (Boolean)
    * :first_message_mode (Vapi::AssistantOverridesFirstMessageMode)
    * :voicemail_detection (Hash)
    * :client_messages (Array<Vapi::AssistantOverridesClientMessagesItem>)
    * :server_messages (Array<Vapi::AssistantOverridesServerMessagesItem>)
    * :silence_timeout_seconds (Float)
    * :max_duration_seconds (Float)
    * :background_sound (Hash)
    * :background_denoising_enabled (Boolean)
    * :model_output_in_messages_enabled (Boolean)
    * :transport_configurations (Array<Vapi::TransportConfigurationTwilio>)
    * :observability_plan (Hash)
      * :provider (String)
      * :tags (Array<String>)
      * :metadata (Hash{String => Object})
    * :credentials (Array<Vapi::AssistantOverridesCredentialsItem>)
    * :hooks (Array<Vapi::AssistantOverridesHooksItem>)
    * :variable_values (Hash{String => Object})
    * :name (String)
    * :voicemail_message (String)
    * :end_call_message (String)
    * :end_call_phrases (Array<String>)
    * :compliance_plan (Hash)
      * :hipaa_enabled (Boolean)
      * :pci_enabled (Boolean)
    * :metadata (Hash{String => Object})
    * :background_speech_denoising_plan (Hash)
      * :smart_denoising_plan (Hash)
        * :enabled (Boolean)
      * :fourier_denoising_plan (Hash)
        * :enabled (Boolean)
        * :media_detection_enabled (Boolean)
        * :static_threshold (Float)
        * :baseline_offset_db (Float)
        * :window_size_ms (Float)
        * :baseline_percentile (Float)
    * :analysis_plan (Hash)
      * :min_messages_threshold (Float)
      * :summary_plan (Hash)
        * :messages (Array<Hash{String => Object}>)
        * :enabled (Boolean)
        * :timeout_seconds (Float)
      * :structured_data_plan (Hash)
        * :messages (Array<Hash{String => Object}>)
        * :enabled (Boolean)
        * :schema (Hash)
          * :type (Vapi::JsonSchemaType)
          * :items (Hash{String => Object})
          * :properties (Hash{String => Object})
          * :description (String)
          * :pattern (String)
          * :format (Vapi::JsonSchemaFormat)
          * :required (Array<String>)
          * :enum (Array<String>)
          * :title (String)
        * :timeout_seconds (Float)
      * :structured_data_multi_plan (Array<Vapi::StructuredDataMultiPlan>)
      * :success_evaluation_plan (Hash)
        * :rubric (Vapi::SuccessEvaluationPlanRubric)
        * :messages (Array<Hash{String => Object}>)
        * :enabled (Boolean)
        * :timeout_seconds (Float)
    * :artifact_plan (Hash)
      * :recording_enabled (Boolean)
      * :recording_format (Vapi::ArtifactPlanRecordingFormat)
      * :video_recording_enabled (Boolean)
      * :pcap_enabled (Boolean)
      * :pcap_s_3_path_prefix (String)
      * :transcript_plan (Hash)
        * :enabled (Boolean)
        * :assistant_name (String)
        * :user_name (String)
      * :recording_path (String)
    * :message_plan (Hash)
      * :idle_messages (Array<String>)
      * :idle_message_max_spoken_count (Float)
      * :idle_message_reset_count_on_user_speech_enabled (Boolean)
      * :idle_timeout_seconds (Float)
      * :silence_timeout_message (String)
    * :start_speaking_plan (Hash)
      * :wait_seconds (Float)
      * :smart_endpointing_enabled (Hash)
      * :smart_endpointing_plan (Hash)
      * :custom_endpointing_rules (Array<Vapi::StartSpeakingPlanCustomEndpointingRulesItem>)
      * :transcription_endpointing_plan (Hash)
        * :on_punctuation_seconds (Float)
        * :on_no_punctuation_seconds (Float)
        * :on_number_seconds (Float)
    * :stop_speaking_plan (Hash)
      * :num_words (Float)
      * :voice_seconds (Float)
      * :backoff_seconds (Float)
      * :acknowledgement_phrases (Array<String>)
      * :interruption_phrases (Array<String>)
    * :monitor_plan (Hash)
      * :listen_enabled (Boolean)
      * :listen_authentication_enabled (Boolean)
      * :control_enabled (Boolean)
      * :control_authentication_enabled (Boolean)
    * :credential_ids (Array<String>)
    * :server (Hash)
      * :timeout_seconds (Float)
      * :url (String)
      * :headers (Hash{String => Object})
      * :backoff_plan (Hash)
        * :type (Hash{String => Object})
        * :max_retries (Float)
        * :base_delay_seconds (Float)
    * :keypad_input_plan (Hash)
      * :enabled (Boolean)
      * :timeout_seconds (Float)
      * :delimiters (Vapi::KeypadInputPlanDelimiters)
    
  • name (String) (defaults to: nil)

    This is the name of the chat. This is just for your own reference.

  • session_id (String) (defaults to: nil)

    This is the ID of the session that will be used for the chat. Mutually exclusive with previousChatId.

  • input (String, Array<Vapi::Chats::CreateChatDtoInputItem>)

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

  • stream (Boolean) (defaults to: nil)

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

  • previous_chat_id (String) (defaults to: nil)

    This is the ID of the chat that will be used as context for the new chat. The messages from the previous chat will be used as context. Mutually exclusive with sessionId.

  • request_options (Vapi::RequestOptions) (defaults to: nil)

Returns:



337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
# File 'lib/vapi_server_sdk/chats/client.rb', line 337

def create(input:, assistant_id: nil, assistant: nil, assistant_overrides: nil, name: nil, session_id: nil,
           stream: nil, previous_chat_id: nil, request_options: nil)
  response = @request_client.conn.post do |req|
    req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
    req.headers["Authorization"] = request_options.token unless request_options&.token.nil?
    req.headers = {
  **(req.headers || {}),
  **@request_client.get_headers,
  **(request_options&.additional_headers || {})
    }.compact
    unless request_options.nil? || request_options&.additional_query_parameters.nil?
      req.params = { **(request_options&.additional_query_parameters || {}) }.compact
    end
    req.body = {
      **(request_options&.additional_body_parameters || {}),
      assistantId: assistant_id,
      assistant: assistant,
      assistantOverrides: assistant_overrides,
      name: name,
      sessionId: session_id,
      input: input,
      stream: stream,
      previousChatId: previous_chat_id
    }.compact
    req.url "#{@request_client.get_url(request_options: request_options)}/chat"
  end
  Vapi::Chats::ChatsCreateResponse.from_json(json_object: response.body)
end

#create_response(input:, assistant_id: nil, assistant: nil, assistant_overrides: nil, name: nil, session_id: nil, stream: nil, previous_chat_id: nil, request_options: nil) ⇒ Vapi::ResponseObject, ...

Parameters:

  • assistant_id (String) (defaults to: nil)

    This is the assistant that will be used for the chat. To use an existing assistant, use ‘assistantId` instead.

  • assistant (Hash) (defaults to: nil)

    This is the assistant that will be used for the chat. To use an existing assistant, use ‘assistantId` instead.Request of type Vapi::CreateAssistantDto, as a Hash

    * :transcriber (Hash)
    * :model (Hash)
    * :voice (Hash)
    * :first_message (String)
    * :first_message_interruptions_enabled (Boolean)
    * :first_message_mode (Vapi::CreateAssistantDtoFirstMessageMode)
    * :voicemail_detection (Hash)
    * :client_messages (Array<Vapi::CreateAssistantDtoClientMessagesItem>)
    * :server_messages (Array<Vapi::CreateAssistantDtoServerMessagesItem>)
    * :silence_timeout_seconds (Float)
    * :max_duration_seconds (Float)
    * :background_sound (Hash)
    * :background_denoising_enabled (Boolean)
    * :model_output_in_messages_enabled (Boolean)
    * :transport_configurations (Array<Vapi::TransportConfigurationTwilio>)
    * :observability_plan (Hash)
      * :provider (String)
      * :tags (Array<String>)
      * :metadata (Hash{String => Object})
    * :credentials (Array<Vapi::CreateAssistantDtoCredentialsItem>)
    * :hooks (Array<Vapi::CreateAssistantDtoHooksItem>)
    * :name (String)
    * :voicemail_message (String)
    * :end_call_message (String)
    * :end_call_phrases (Array<String>)
    * :compliance_plan (Hash)
      * :hipaa_enabled (Boolean)
      * :pci_enabled (Boolean)
    * :metadata (Hash{String => Object})
    * :background_speech_denoising_plan (Hash)
      * :smart_denoising_plan (Hash)
        * :enabled (Boolean)
      * :fourier_denoising_plan (Hash)
        * :enabled (Boolean)
        * :media_detection_enabled (Boolean)
        * :static_threshold (Float)
        * :baseline_offset_db (Float)
        * :window_size_ms (Float)
        * :baseline_percentile (Float)
    * :analysis_plan (Hash)
      * :min_messages_threshold (Float)
      * :summary_plan (Hash)
        * :messages (Array<Hash{String => Object}>)
        * :enabled (Boolean)
        * :timeout_seconds (Float)
      * :structured_data_plan (Hash)
        * :messages (Array<Hash{String => Object}>)
        * :enabled (Boolean)
        * :schema (Hash)
          * :type (Vapi::JsonSchemaType)
          * :items (Hash{String => Object})
          * :properties (Hash{String => Object})
          * :description (String)
          * :pattern (String)
          * :format (Vapi::JsonSchemaFormat)
          * :required (Array<String>)
          * :enum (Array<String>)
          * :title (String)
        * :timeout_seconds (Float)
      * :structured_data_multi_plan (Array<Vapi::StructuredDataMultiPlan>)
      * :success_evaluation_plan (Hash)
        * :rubric (Vapi::SuccessEvaluationPlanRubric)
        * :messages (Array<Hash{String => Object}>)
        * :enabled (Boolean)
        * :timeout_seconds (Float)
    * :artifact_plan (Hash)
      * :recording_enabled (Boolean)
      * :recording_format (Vapi::ArtifactPlanRecordingFormat)
      * :video_recording_enabled (Boolean)
      * :pcap_enabled (Boolean)
      * :pcap_s_3_path_prefix (String)
      * :transcript_plan (Hash)
        * :enabled (Boolean)
        * :assistant_name (String)
        * :user_name (String)
      * :recording_path (String)
    * :message_plan (Hash)
      * :idle_messages (Array<String>)
      * :idle_message_max_spoken_count (Float)
      * :idle_message_reset_count_on_user_speech_enabled (Boolean)
      * :idle_timeout_seconds (Float)
      * :silence_timeout_message (String)
    * :start_speaking_plan (Hash)
      * :wait_seconds (Float)
      * :smart_endpointing_enabled (Hash)
      * :smart_endpointing_plan (Hash)
      * :custom_endpointing_rules (Array<Vapi::StartSpeakingPlanCustomEndpointingRulesItem>)
      * :transcription_endpointing_plan (Hash)
        * :on_punctuation_seconds (Float)
        * :on_no_punctuation_seconds (Float)
        * :on_number_seconds (Float)
    * :stop_speaking_plan (Hash)
      * :num_words (Float)
      * :voice_seconds (Float)
      * :backoff_seconds (Float)
      * :acknowledgement_phrases (Array<String>)
      * :interruption_phrases (Array<String>)
    * :monitor_plan (Hash)
      * :listen_enabled (Boolean)
      * :listen_authentication_enabled (Boolean)
      * :control_enabled (Boolean)
      * :control_authentication_enabled (Boolean)
    * :credential_ids (Array<String>)
    * :server (Hash)
      * :timeout_seconds (Float)
      * :url (String)
      * :headers (Hash{String => Object})
      * :backoff_plan (Hash)
        * :type (Hash{String => Object})
        * :max_retries (Float)
        * :base_delay_seconds (Float)
    * :keypad_input_plan (Hash)
      * :enabled (Boolean)
      * :timeout_seconds (Float)
      * :delimiters (Vapi::KeypadInputPlanDelimiters)
    
  • assistant_overrides (Hash) (defaults to: nil)

    These are the variable values that will be used to replace template variables in the assistant messages. Only variable substitution is supported in chat contexts - other assistant properties cannot be overridden.Request of type Vapi::AssistantOverrides, as a Hash

    * :transcriber (Hash)
    * :model (Hash)
    * :voice (Hash)
    * :first_message (String)
    * :first_message_interruptions_enabled (Boolean)
    * :first_message_mode (Vapi::AssistantOverridesFirstMessageMode)
    * :voicemail_detection (Hash)
    * :client_messages (Array<Vapi::AssistantOverridesClientMessagesItem>)
    * :server_messages (Array<Vapi::AssistantOverridesServerMessagesItem>)
    * :silence_timeout_seconds (Float)
    * :max_duration_seconds (Float)
    * :background_sound (Hash)
    * :background_denoising_enabled (Boolean)
    * :model_output_in_messages_enabled (Boolean)
    * :transport_configurations (Array<Vapi::TransportConfigurationTwilio>)
    * :observability_plan (Hash)
      * :provider (String)
      * :tags (Array<String>)
      * :metadata (Hash{String => Object})
    * :credentials (Array<Vapi::AssistantOverridesCredentialsItem>)
    * :hooks (Array<Vapi::AssistantOverridesHooksItem>)
    * :variable_values (Hash{String => Object})
    * :name (String)
    * :voicemail_message (String)
    * :end_call_message (String)
    * :end_call_phrases (Array<String>)
    * :compliance_plan (Hash)
      * :hipaa_enabled (Boolean)
      * :pci_enabled (Boolean)
    * :metadata (Hash{String => Object})
    * :background_speech_denoising_plan (Hash)
      * :smart_denoising_plan (Hash)
        * :enabled (Boolean)
      * :fourier_denoising_plan (Hash)
        * :enabled (Boolean)
        * :media_detection_enabled (Boolean)
        * :static_threshold (Float)
        * :baseline_offset_db (Float)
        * :window_size_ms (Float)
        * :baseline_percentile (Float)
    * :analysis_plan (Hash)
      * :min_messages_threshold (Float)
      * :summary_plan (Hash)
        * :messages (Array<Hash{String => Object}>)
        * :enabled (Boolean)
        * :timeout_seconds (Float)
      * :structured_data_plan (Hash)
        * :messages (Array<Hash{String => Object}>)
        * :enabled (Boolean)
        * :schema (Hash)
          * :type (Vapi::JsonSchemaType)
          * :items (Hash{String => Object})
          * :properties (Hash{String => Object})
          * :description (String)
          * :pattern (String)
          * :format (Vapi::JsonSchemaFormat)
          * :required (Array<String>)
          * :enum (Array<String>)
          * :title (String)
        * :timeout_seconds (Float)
      * :structured_data_multi_plan (Array<Vapi::StructuredDataMultiPlan>)
      * :success_evaluation_plan (Hash)
        * :rubric (Vapi::SuccessEvaluationPlanRubric)
        * :messages (Array<Hash{String => Object}>)
        * :enabled (Boolean)
        * :timeout_seconds (Float)
    * :artifact_plan (Hash)
      * :recording_enabled (Boolean)
      * :recording_format (Vapi::ArtifactPlanRecordingFormat)
      * :video_recording_enabled (Boolean)
      * :pcap_enabled (Boolean)
      * :pcap_s_3_path_prefix (String)
      * :transcript_plan (Hash)
        * :enabled (Boolean)
        * :assistant_name (String)
        * :user_name (String)
      * :recording_path (String)
    * :message_plan (Hash)
      * :idle_messages (Array<String>)
      * :idle_message_max_spoken_count (Float)
      * :idle_message_reset_count_on_user_speech_enabled (Boolean)
      * :idle_timeout_seconds (Float)
      * :silence_timeout_message (String)
    * :start_speaking_plan (Hash)
      * :wait_seconds (Float)
      * :smart_endpointing_enabled (Hash)
      * :smart_endpointing_plan (Hash)
      * :custom_endpointing_rules (Array<Vapi::StartSpeakingPlanCustomEndpointingRulesItem>)
      * :transcription_endpointing_plan (Hash)
        * :on_punctuation_seconds (Float)
        * :on_no_punctuation_seconds (Float)
        * :on_number_seconds (Float)
    * :stop_speaking_plan (Hash)
      * :num_words (Float)
      * :voice_seconds (Float)
      * :backoff_seconds (Float)
      * :acknowledgement_phrases (Array<String>)
      * :interruption_phrases (Array<String>)
    * :monitor_plan (Hash)
      * :listen_enabled (Boolean)
      * :listen_authentication_enabled (Boolean)
      * :control_enabled (Boolean)
      * :control_authentication_enabled (Boolean)
    * :credential_ids (Array<String>)
    * :server (Hash)
      * :timeout_seconds (Float)
      * :url (String)
      * :headers (Hash{String => Object})
      * :backoff_plan (Hash)
        * :type (Hash{String => Object})
        * :max_retries (Float)
        * :base_delay_seconds (Float)
    * :keypad_input_plan (Hash)
      * :enabled (Boolean)
      * :timeout_seconds (Float)
      * :delimiters (Vapi::KeypadInputPlanDelimiters)
    
  • name (String) (defaults to: nil)

    This is the name of the chat. This is just for your own reference.

  • session_id (String) (defaults to: nil)

    This is the ID of the session that will be used for the chat. Mutually exclusive with previousChatId.

  • input (String, Array<Vapi::Chats::OpenAiResponsesRequestInputItem>)

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

  • stream (Boolean) (defaults to: nil)

    Whether to stream the response or not.

  • previous_chat_id (String) (defaults to: nil)

    This is the ID of the chat that will be used as context for the new chat. The messages from the previous chat will be used as context. Mutually exclusive with sessionId.

  • request_options (Vapi::RequestOptions) (defaults to: nil)

Returns:



663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
# File 'lib/vapi_server_sdk/chats/client.rb', line 663

def create_response(input:, assistant_id: nil, assistant: nil, assistant_overrides: nil, name: nil,
                    session_id: nil, stream: nil, previous_chat_id: nil, request_options: nil)
  response = @request_client.conn.post do |req|
    req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
    req.headers["Authorization"] = request_options.token unless request_options&.token.nil?
    req.headers = {
  **(req.headers || {}),
  **@request_client.get_headers,
  **(request_options&.additional_headers || {})
    }.compact
    unless request_options.nil? || request_options&.additional_query_parameters.nil?
      req.params = { **(request_options&.additional_query_parameters || {}) }.compact
    end
    req.body = {
      **(request_options&.additional_body_parameters || {}),
      assistantId: assistant_id,
      assistant: assistant,
      assistantOverrides: assistant_overrides,
      name: name,
      sessionId: session_id,
      input: input,
      stream: stream,
      previousChatId: previous_chat_id
    }.compact
    req.url "#{@request_client.get_url(request_options: request_options)}/chat/responses"
  end
  Vapi::Chats::ChatsCreateResponseResponse.from_json(json_object: response.body)
end

#delete(id:, request_options: nil) ⇒ Vapi::Chat

Parameters:

Returns:



392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
# File 'lib/vapi_server_sdk/chats/client.rb', line 392

def delete(id:, request_options: nil)
  response = @request_client.conn.delete do |req|
    req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
    req.headers["Authorization"] = request_options.token unless request_options&.token.nil?
    req.headers = {
  **(req.headers || {}),
  **@request_client.get_headers,
  **(request_options&.additional_headers || {})
    }.compact
    unless request_options.nil? || request_options&.additional_query_parameters.nil?
      req.params = { **(request_options&.additional_query_parameters || {}) }.compact
    end
    unless request_options.nil? || request_options&.additional_body_parameters.nil?
      req.body = { **(request_options&.additional_body_parameters || {}) }.compact
    end
    req.url "#{@request_client.get_url(request_options: request_options)}/chat/#{id}"
  end
  Vapi::Chat.from_json(json_object: response.body)
end

#get(id:, request_options: nil) ⇒ Vapi::Chat

Parameters:

Returns:



369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
# File 'lib/vapi_server_sdk/chats/client.rb', line 369

def get(id:, request_options: nil)
  response = @request_client.conn.get do |req|
    req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
    req.headers["Authorization"] = request_options.token unless request_options&.token.nil?
    req.headers = {
  **(req.headers || {}),
  **@request_client.get_headers,
  **(request_options&.additional_headers || {})
    }.compact
    unless request_options.nil? || request_options&.additional_query_parameters.nil?
      req.params = { **(request_options&.additional_query_parameters || {}) }.compact
    end
    unless request_options.nil? || request_options&.additional_body_parameters.nil?
      req.body = { **(request_options&.additional_body_parameters || {}) }.compact
    end
    req.url "#{@request_client.get_url(request_options: request_options)}/chat/#{id}"
  end
  Vapi::Chat.from_json(json_object: response.body)
end

#list(assistant_id: nil, workflow_id: nil, session_id: nil, page: nil, sort_order: nil, limit: nil, created_at_gt: nil, created_at_lt: nil, created_at_ge: nil, created_at_le: nil, updated_at_gt: nil, updated_at_lt: nil, updated_at_ge: nil, updated_at_le: nil, request_options: nil) ⇒ Vapi::ChatPaginatedResponse

Parameters:

  • assistant_id (String) (defaults to: nil)

    This is the unique identifier for the assistant that will be used for the chat.

  • workflow_id (String) (defaults to: nil)

    This is the unique identifier for the workflow that will be used for the chat.

  • session_id (String) (defaults to: nil)

    This is the unique identifier for the session that will be used for the chat.

  • page (Float) (defaults to: nil)

    This is the page number to return. Defaults to 1.

  • sort_order (Vapi::Chats::ChatsListRequestSortOrder) (defaults to: nil)

    This is the sort order for pagination. Defaults to ‘DESC’.

  • limit (Float) (defaults to: nil)

    This is the maximum number of items to return. Defaults to 100.

  • created_at_gt (DateTime) (defaults to: nil)

    This will return items where the createdAt is greater than the specified value.

  • created_at_lt (DateTime) (defaults to: nil)

    This will return items where the createdAt is less than the specified value.

  • created_at_ge (DateTime) (defaults to: nil)

    This will return items where the createdAt is greater than or equal to the specified value.

  • created_at_le (DateTime) (defaults to: nil)

    This will return items where the createdAt is less than or equal to the specified value.

  • updated_at_gt (DateTime) (defaults to: nil)

    This will return items where the updatedAt is greater than the specified value.

  • updated_at_lt (DateTime) (defaults to: nil)

    This will return items where the updatedAt is less than the specified value.

  • updated_at_ge (DateTime) (defaults to: nil)

    This will return items where the updatedAt is greater than or equal to the specified value.

  • updated_at_le (DateTime) (defaults to: nil)

    This will return items where the updatedAt is less than or equal to the specified value.

  • request_options (Vapi::RequestOptions) (defaults to: nil)

Returns:



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/vapi_server_sdk/chats/client.rb', line 47

def list(assistant_id: nil, workflow_id: nil, session_id: nil, page: nil, sort_order: nil, limit: nil,
         created_at_gt: nil, created_at_lt: nil, created_at_ge: nil, created_at_le: nil, updated_at_gt: nil, updated_at_lt: nil, updated_at_ge: nil, updated_at_le: nil, request_options: nil)
  response = @request_client.conn.get do |req|
    req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
    req.headers["Authorization"] = request_options.token unless request_options&.token.nil?
    req.headers = {
  **(req.headers || {}),
  **@request_client.get_headers,
  **(request_options&.additional_headers || {})
    }.compact
    req.params = {
      **(request_options&.additional_query_parameters || {}),
      "assistantId": assistant_id,
      "workflowId": workflow_id,
      "sessionId": session_id,
      "page": page,
      "sortOrder": sort_order,
      "limit": limit,
      "createdAtGt": created_at_gt,
      "createdAtLt": created_at_lt,
      "createdAtGe": created_at_ge,
      "createdAtLe": created_at_le,
      "updatedAtGt": updated_at_gt,
      "updatedAtLt": updated_at_lt,
      "updatedAtGe": updated_at_ge,
      "updatedAtLe": updated_at_le
    }.compact
    unless request_options.nil? || request_options&.additional_body_parameters.nil?
      req.body = { **(request_options&.additional_body_parameters || {}) }.compact
    end
    req.url "#{@request_client.get_url(request_options: request_options)}/chat"
  end
  Vapi::ChatPaginatedResponse.from_json(json_object: response.body)
end