Class: Vapi::CampaignsClient

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(request_client:) ⇒ Vapi::CampaignsClient

Parameters:



20
21
22
# File 'lib/vapi_server_sdk/campaigns/client.rb', line 20

def initialize(request_client:)
  @request_client = request_client
end

Instance Attribute Details

#request_clientVapi::RequestClient (readonly)

Returns:



16
17
18
# File 'lib/vapi_server_sdk/campaigns/client.rb', line 16

def request_client
  @request_client
end

Instance Method Details

#campaign_controller_create(name:, phone_number_id:, customers:, assistant_id: nil, workflow_id: nil, schedule_plan: nil, request_options: nil) ⇒ Vapi::Campaign

Parameters:

  • name (String)

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

  • assistant_id (String) (defaults to: nil)

    This is the assistant ID that will be used for the campaign calls. Note: Either assistantId or workflowId can be used, but not both.

  • workflow_id (String) (defaults to: nil)

    This is the workflow ID that will be used for the campaign calls. Note: Either assistantId or workflowId can be used, but not both.

  • phone_number_id (String)

    This is the phone number ID that will be used for the campaign calls.

  • schedule_plan (Hash) (defaults to: nil)

    This is the schedule plan for the campaign.Request of type Vapi::SchedulePlan, as a Hash

    • :earliest_at (DateTime)

    • :latest_at (DateTime)

  • customers (Array<Hash>)

    These are the customers that will be called in the campaign.Request of type Array<Vapi::CreateCustomerDto>, as a Hash

    • :number_e_164_check_enabled (Boolean)

    • :extension (String)

    • :assistant_overrides (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=> Object)

      • :credentials (Array<Vapi::AssistantOverridesCredentialsItem>)

      • :hooks (Array<Vapi::AssistantOverridesHooksItem>)

      • :variable_values (Hash=> 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=> 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=> Object>)

          • :enabled (Boolean)

          • :timeout_seconds (Float)

        • :structured_data_plan (Hash)

          • :messages (Array<Hash=> Object>)

          • :enabled (Boolean)

          • :schema (Hash)

            • :type (Vapi::JsonSchemaType)

            • :items (Hash=> Object)

            • :properties (Hash=> 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=> 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=> Object)

        • :backoff_plan (Hash)

          • :type (Hash=> Object)

          • :max_retries (Float)

          • :base_delay_seconds (Float)

      • :keypad_input_plan (Hash)

        • :enabled (Boolean)

        • :timeout_seconds (Float)

        • :delimiters (Vapi::KeypadInputPlanDelimiters)

    • :number (String)

    • :sip_uri (String)

    • :name (String)

    • :email (String)

    • :external_id (String)

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

Returns:



213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
# File 'lib/vapi_server_sdk/campaigns/client.rb', line 213

def campaign_controller_create(name:, phone_number_id:, customers:, assistant_id: nil, workflow_id: nil,
                               schedule_plan: 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 || {}),
      name: name,
      assistantId: assistant_id,
      workflowId: workflow_id,
      phoneNumberId: phone_number_id,
      schedulePlan: schedule_plan,
      customers: customers
    }.compact
    req.url "#{@request_client.get_url(request_options: request_options)}/campaign"
  end
  Vapi::Campaign.from_json(json_object: response.body)
end

#campaign_controller_find_all(id: nil, status: 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::CampaignPaginatedResponse

Parameters:

  • id (String) (defaults to: nil)
  • status (Vapi::Campaigns::CampaignControllerFindAllRequestStatus) (defaults to: nil)
  • page (Float) (defaults to: nil)

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

  • sort_order (Vapi::Campaigns::CampaignControllerFindAllRequestSortOrder) (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:



43
44
45
46
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
# File 'lib/vapi_server_sdk/campaigns/client.rb', line 43

def campaign_controller_find_all(id: nil, status: 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 || {}),
      "id": id,
      "status": status,
      "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)}/campaign"
  end
  Vapi::CampaignPaginatedResponse.from_json(json_object: response.body)
end

#campaign_controller_find_one(id:, request_options: nil) ⇒ Vapi::Campaign

Parameters:

Returns:



243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
# File 'lib/vapi_server_sdk/campaigns/client.rb', line 243

def campaign_controller_find_one(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)}/campaign/#{id}"
  end
  Vapi::Campaign.from_json(json_object: response.body)
end

#campaign_controller_remove(id:, request_options: nil) ⇒ Vapi::Campaign

Parameters:

Returns:



266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
# File 'lib/vapi_server_sdk/campaigns/client.rb', line 266

def campaign_controller_remove(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)}/campaign/#{id}"
  end
  Vapi::Campaign.from_json(json_object: response.body)
end

#campaign_controller_update(id:, name: nil, assistant_id: nil, workflow_id: nil, phone_number_id: nil, schedule_plan: nil, request_options: nil) ⇒ Vapi::Campaign

Parameters:

  • id (String)
  • name (String) (defaults to: nil)

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

  • assistant_id (String) (defaults to: nil)

    This is the assistant ID that will be used for the campaign calls. Can only be updated if campaign is not in progress or has ended.

  • workflow_id (String) (defaults to: nil)

    This is the workflow ID that will be used for the campaign calls. Can only be updated if campaign is not in progress or has ended.

  • phone_number_id (String) (defaults to: nil)

    This is the phone number ID that will be used for the campaign calls. Can only be updated if campaign is not in progress or has ended.

  • schedule_plan (Hash) (defaults to: nil)

    This is the schedule plan for the campaign. Can only be updated if campaign is not in progress or has ended.Request of type Vapi::SchedulePlan, as a Hash

    * :earliest_at (DateTime)
    * :latest_at (DateTime)
    
  • request_options (Vapi::RequestOptions) (defaults to: nil)

Returns:



300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
# File 'lib/vapi_server_sdk/campaigns/client.rb', line 300

def campaign_controller_update(id:, name: nil, assistant_id: nil, workflow_id: nil, phone_number_id: nil,
                               schedule_plan: nil, request_options: nil)
  response = @request_client.conn.patch 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 || {}),
      "status": "ended",
      name: name,
      assistantId: assistant_id,
      workflowId: workflow_id,
      phoneNumberId: phone_number_id,
      schedulePlan: schedule_plan
    }.compact
    req.url "#{@request_client.get_url(request_options: request_options)}/campaign/#{id}"
  end
  Vapi::Campaign.from_json(json_object: response.body)
end