@opens/gateways 1.16.19 → 1.16.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -337,11 +337,21 @@ interface QueueRule extends Rule {
337
337
  flow?: Rule[];
338
338
  }
339
339
  /** Known rule action values used by the Chat Config API. */
340
- type RuleAction = 'queue' | 'interactiveMessage' | 'message' | 'automaticMessage' | 'callOnQueue' | 'ura' | 'webhook' | 'questionnaire' | 'flow' | 'csat';
340
+ type RuleAction = 'queue' | 'interactiveMessage' | 'message' | 'automaticMessage' | 'automatic-message' | 'callOnQueue' | 'ura' | 'webhook' | 'questionnaire' | 'flow' | 'csat';
341
341
  /** Archive filter for listing rules. Matches `GET /rules/paginated` query validation. */
342
342
  type RuleArchiveStatus = 'archived' | 'unarchived' | 'all';
343
343
  /** Associations that can be eager-loaded when listing paginated rules. */
344
344
  type RuleAssociation = 'flow';
345
+ /** HTTP method used by webhook and questionnaire outbound requests. */
346
+ type RuleHttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | string;
347
+ /** Interactive presentation for URA rules (`settings.interactiveType`). */
348
+ type RuleInteractiveType = 'button' | 'list';
349
+ /** Validation action taken after a questionnaire answer is validated. */
350
+ type RuleQuestionnaireValidationAction = 'nextQuestion' | 'sendToRule' | 'terminateChat' | 'nextFlow' | 'addAutoTags' | string;
351
+ /** Built-in regex validation kinds for questionnaire questions. */
352
+ type RuleQuestionnaireValidationRegexType = 'email' | 'cpf' | 'lettersOnly' | 'numbersOnly' | 'customExpression' | '' | string;
353
+ /** Question input type for questionnaire questions. */
354
+ type RuleQuestionnaireQuestionType = 'interactive_menu' | string;
345
355
  /** Request query parameters for listing root rules. */
346
356
  type GetRootRulesRequest = {
347
357
  companyId: string;
@@ -374,35 +384,157 @@ type GetRulesCountRequest = {
374
384
  action?: RuleAction[];
375
385
  archiveStatus?: RuleArchiveStatus;
376
386
  };
387
+ /**
388
+ * Request query parameters for fetching a rule by id (`GET /rules/:id`).
389
+ * When `rootOnly` is omitted the API defaults to `true` (no recursive flow tree).
390
+ * Pass `rootOnly: false` to expand nested `flow` via `buildRuleTree`.
391
+ */
392
+ type GetRuleByIdRequest = {
393
+ rootOnly?: boolean;
394
+ includeFlow?: boolean;
395
+ collapseDistinctId?: boolean;
396
+ distinctId?: boolean | string;
397
+ expand?: RuleAssociation[];
398
+ };
377
399
  /** Automatic message payload stored on a rule. */
378
400
  interface RuleAutomaticMessage {
379
401
  messageBody: string;
380
- caption: string | null;
381
- messageType: string;
402
+ caption?: string | null;
403
+ messageType?: string;
404
+ }
405
+ /** Call-on-queue payload stored on a rule. */
406
+ interface RuleCallOnQueue {
407
+ id: string;
408
+ attendanceGroupId?: string;
409
+ voiceTimeout?: number;
410
+ minutesToExpire?: number;
411
+ callToActionMessage?: string;
412
+ }
413
+ /** Custom HTTP header used by webhook requests. */
414
+ interface RuleWebhookHeader {
415
+ key: string;
416
+ value: string;
417
+ }
418
+ /** Mapping from a webhook JSON response path into a context key. */
419
+ interface RuleWebhookResponseMapping {
420
+ replaceValue: string;
421
+ jsonPath: string;
422
+ newJsonKey: string;
423
+ }
424
+ /** Webhook configuration stored on a rule. */
425
+ interface RuleWebhook {
426
+ customHeaders: RuleWebhookHeader[];
427
+ webhookMethodType: RuleHttpMethod;
428
+ webhookEndpoint: string;
429
+ webhookResponseMappings: RuleWebhookResponseMapping[];
430
+ }
431
+ /** Interactive option used by questionnaire `interactive_menu` questions. */
432
+ interface RuleQuestionnaireInteractiveOption {
433
+ id: string;
434
+ text: string;
435
+ }
436
+ /** Single question inside a questionnaire rule. */
437
+ interface RuleQuestionnaireQuestion {
438
+ questionText: string;
439
+ isResponsePrivateEnabled?: boolean;
440
+ isEnabledCustomDebounce?: boolean;
441
+ customDebounceSeconds?: number;
442
+ hasValidation?: boolean;
443
+ isUsingCustomValidation?: boolean;
444
+ customValidationUrl?: string;
445
+ customValidationMethod?: string;
446
+ validationRegexType?: RuleQuestionnaireValidationRegexType;
447
+ validationRegexPattern?: string;
448
+ maxValidationAttempts?: number;
449
+ onValidationFailureReply?: string;
450
+ onValidationSuccessAction?: RuleQuestionnaireValidationAction;
451
+ onValidationSuccessActionTarget?: string;
452
+ onValidationFailureAction?: RuleQuestionnaireValidationAction;
453
+ onValidationFailureActionTarget?: string;
454
+ onValidationFailureMessage?: string;
455
+ onValidationSuccessAutoTagIds?: number[];
456
+ onValidationFailureAutoTagIds?: number[];
457
+ questionType?: RuleQuestionnaireQuestionType;
458
+ interactiveOptions?: RuleQuestionnaireInteractiveOption[];
459
+ }
460
+ /** HTTP header sent with the questionnaire outbound request. */
461
+ interface RuleQuestionnaireHeader {
462
+ id?: number;
463
+ key: string;
464
+ value: string;
465
+ }
466
+ /** Body/query field sent with the questionnaire outbound request. */
467
+ interface RuleQuestionnaireBodyField {
468
+ id?: number;
469
+ key: string;
470
+ value: string;
471
+ isFilledByAnswer?: boolean;
472
+ answerIndex?: number | null;
473
+ }
474
+ /**
475
+ * Questionnaire configuration stored on a rule.
476
+ * The API may return `null`, a full object, or an empty object `{}`.
477
+ */
478
+ interface RuleQuestionnaire {
479
+ questions?: RuleQuestionnaireQuestion[];
480
+ questionHeaders?: RuleQuestionnaireHeader[];
481
+ questionBodyFields?: RuleQuestionnaireBodyField[];
482
+ questionEndpoint?: string;
483
+ questionMethodType?: RuleHttpMethod | '';
484
+ }
485
+ /** Text-response behavior for Meta flow rules (`settings.flow.textResponse`). */
486
+ interface RuleFlowTextResponse {
487
+ behavior: 'require_flow' | 'redirect_rule';
488
+ sendReminder?: boolean;
489
+ reminderMessage?: string;
490
+ targetRuleId?: string;
491
+ }
492
+ /** Meta interactive flow configuration (`settings.flow`). */
493
+ interface RuleFlowSettings {
494
+ configId: string;
495
+ metaFlowId: string;
496
+ flowAction: 'navigate' | 'data_exchange';
497
+ flowCta: string;
498
+ flowBody: string;
499
+ webhookUrl?: string;
500
+ firstScreen?: string;
501
+ flowHeader?: string;
502
+ flowFooter?: string;
503
+ contextKey?: string;
504
+ textResponse?: RuleFlowTextResponse;
505
+ }
506
+ /**
507
+ * Rule settings JSON.
508
+ * Common keys: `interactiveType` (URA) and `flow` (action `flow`).
509
+ */
510
+ interface RuleSettings {
511
+ interactiveType?: RuleInteractiveType;
512
+ flow?: RuleFlowSettings;
513
+ [key: string]: unknown;
382
514
  }
383
515
  /** Rule entity returned by the Chat Config API. */
384
516
  interface Rule {
385
517
  id: string;
386
518
  companyId: string;
387
519
  name: string;
388
- action: string;
520
+ action: RuleAction | string;
389
521
  message: string | null;
390
522
  automaticMessage: RuleAutomaticMessage | null;
391
- callOnQueue: Record<string, unknown> | null;
523
+ callOnQueue: RuleCallOnQueue | null;
392
524
  uraDescription: string | null;
393
525
  interactiveMessageId: string | null;
394
526
  configId: string | null;
395
527
  queueId: string | null;
396
528
  redirectQueue: string | null;
397
529
  redirectRuleId: string | null;
398
- questionnaire: Record<string, unknown> | null;
399
- webhook: Record<string, unknown> | null;
530
+ questionnaire: RuleQuestionnaire | null;
531
+ webhook: RuleWebhook | null;
400
532
  isRoot: boolean;
401
533
  redirectDefault: boolean;
402
534
  redirectTimeout: number;
403
535
  delay: number | null;
404
536
  disableTyping: boolean;
405
- settings: Record<string, unknown> | null;
537
+ settings: RuleSettings | null;
406
538
  archivedAt: string | null;
407
539
  autoTagEnabled: boolean;
408
540
  autoTagIds: number[];
@@ -410,6 +542,8 @@ interface Rule {
410
542
  updatedAt: string;
411
543
  flow?: Rule[];
412
544
  }
545
+ /** Response returned by `GET /rules/:id`. */
546
+ type RuleResponse = Rule;
413
547
  /** Response returned by the Chat Config API when listing paginated rules. */
414
548
  type RulesResponse = {
415
549
  data: Rule[];
@@ -421,4 +555,4 @@ type RulesCountResponse = {
421
555
  /** Response returned by the Chat Config API when listing root rules. */
422
556
  type RootRulesResponse = RulesResponse;
423
557
 
424
- export type { Config, ConfigListByProviderResponse, ConfigProvider, DistributionType, FindOrCreateQueueRuleRequest, GetConfigsByProviderParams, GetMemberQueuesRequest, GetProviderConfigurationsParams, GetProviderDisplayInfoParams, GetRootRulesRequest, GetRulesCountRequest, GetRulesRequest, GetServiceGroupsParams, MetaTemplateButton, MetaTemplateConfigResponse, MetaTemplateConfigsResponse, Provider, ProviderConfiguration, ProviderConfigurationsResponse, ProviderDisplayInfoResponse, ProviderListResponse, ProviderName, Queue, QueueListResponse, QueueMember, QueueRule, RootRulesResponse, Rule, RuleAction, RuleArchiveStatus, RuleAssociation, RuleAutomaticMessage, RulesCountResponse, RulesResponse, ServiceGroup, ServiceGroupsResponse, WhatsAppProviderSettings, WidgetProviderSettings };
558
+ export type { Config, ConfigListByProviderResponse, ConfigProvider, DistributionType, FindOrCreateQueueRuleRequest, GetConfigsByProviderParams, GetMemberQueuesRequest, GetProviderConfigurationsParams, GetProviderDisplayInfoParams, GetRootRulesRequest, GetRuleByIdRequest, GetRulesCountRequest, GetRulesRequest, GetServiceGroupsParams, MetaTemplateButton, MetaTemplateConfigResponse, MetaTemplateConfigsResponse, Provider, ProviderConfiguration, ProviderConfigurationsResponse, ProviderDisplayInfoResponse, ProviderListResponse, ProviderName, Queue, QueueListResponse, QueueMember, QueueRule, RootRulesResponse, Rule, RuleAction, RuleArchiveStatus, RuleAssociation, RuleAutomaticMessage, RuleCallOnQueue, RuleFlowSettings, RuleFlowTextResponse, RuleHttpMethod, RuleInteractiveType, RuleQuestionnaire, RuleQuestionnaireBodyField, RuleQuestionnaireHeader, RuleQuestionnaireInteractiveOption, RuleQuestionnaireQuestion, RuleQuestionnaireQuestionType, RuleQuestionnaireValidationAction, RuleQuestionnaireValidationRegexType, RuleResponse, RuleSettings, RuleWebhook, RuleWebhookHeader, RuleWebhookResponseMapping, RulesCountResponse, RulesResponse, ServiceGroup, ServiceGroupsResponse, WhatsAppProviderSettings, WidgetProviderSettings };
@@ -337,11 +337,21 @@ interface QueueRule extends Rule {
337
337
  flow?: Rule[];
338
338
  }
339
339
  /** Known rule action values used by the Chat Config API. */
340
- type RuleAction = 'queue' | 'interactiveMessage' | 'message' | 'automaticMessage' | 'callOnQueue' | 'ura' | 'webhook' | 'questionnaire' | 'flow' | 'csat';
340
+ type RuleAction = 'queue' | 'interactiveMessage' | 'message' | 'automaticMessage' | 'automatic-message' | 'callOnQueue' | 'ura' | 'webhook' | 'questionnaire' | 'flow' | 'csat';
341
341
  /** Archive filter for listing rules. Matches `GET /rules/paginated` query validation. */
342
342
  type RuleArchiveStatus = 'archived' | 'unarchived' | 'all';
343
343
  /** Associations that can be eager-loaded when listing paginated rules. */
344
344
  type RuleAssociation = 'flow';
345
+ /** HTTP method used by webhook and questionnaire outbound requests. */
346
+ type RuleHttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | string;
347
+ /** Interactive presentation for URA rules (`settings.interactiveType`). */
348
+ type RuleInteractiveType = 'button' | 'list';
349
+ /** Validation action taken after a questionnaire answer is validated. */
350
+ type RuleQuestionnaireValidationAction = 'nextQuestion' | 'sendToRule' | 'terminateChat' | 'nextFlow' | 'addAutoTags' | string;
351
+ /** Built-in regex validation kinds for questionnaire questions. */
352
+ type RuleQuestionnaireValidationRegexType = 'email' | 'cpf' | 'lettersOnly' | 'numbersOnly' | 'customExpression' | '' | string;
353
+ /** Question input type for questionnaire questions. */
354
+ type RuleQuestionnaireQuestionType = 'interactive_menu' | string;
345
355
  /** Request query parameters for listing root rules. */
346
356
  type GetRootRulesRequest = {
347
357
  companyId: string;
@@ -374,35 +384,157 @@ type GetRulesCountRequest = {
374
384
  action?: RuleAction[];
375
385
  archiveStatus?: RuleArchiveStatus;
376
386
  };
387
+ /**
388
+ * Request query parameters for fetching a rule by id (`GET /rules/:id`).
389
+ * When `rootOnly` is omitted the API defaults to `true` (no recursive flow tree).
390
+ * Pass `rootOnly: false` to expand nested `flow` via `buildRuleTree`.
391
+ */
392
+ type GetRuleByIdRequest = {
393
+ rootOnly?: boolean;
394
+ includeFlow?: boolean;
395
+ collapseDistinctId?: boolean;
396
+ distinctId?: boolean | string;
397
+ expand?: RuleAssociation[];
398
+ };
377
399
  /** Automatic message payload stored on a rule. */
378
400
  interface RuleAutomaticMessage {
379
401
  messageBody: string;
380
- caption: string | null;
381
- messageType: string;
402
+ caption?: string | null;
403
+ messageType?: string;
404
+ }
405
+ /** Call-on-queue payload stored on a rule. */
406
+ interface RuleCallOnQueue {
407
+ id: string;
408
+ attendanceGroupId?: string;
409
+ voiceTimeout?: number;
410
+ minutesToExpire?: number;
411
+ callToActionMessage?: string;
412
+ }
413
+ /** Custom HTTP header used by webhook requests. */
414
+ interface RuleWebhookHeader {
415
+ key: string;
416
+ value: string;
417
+ }
418
+ /** Mapping from a webhook JSON response path into a context key. */
419
+ interface RuleWebhookResponseMapping {
420
+ replaceValue: string;
421
+ jsonPath: string;
422
+ newJsonKey: string;
423
+ }
424
+ /** Webhook configuration stored on a rule. */
425
+ interface RuleWebhook {
426
+ customHeaders: RuleWebhookHeader[];
427
+ webhookMethodType: RuleHttpMethod;
428
+ webhookEndpoint: string;
429
+ webhookResponseMappings: RuleWebhookResponseMapping[];
430
+ }
431
+ /** Interactive option used by questionnaire `interactive_menu` questions. */
432
+ interface RuleQuestionnaireInteractiveOption {
433
+ id: string;
434
+ text: string;
435
+ }
436
+ /** Single question inside a questionnaire rule. */
437
+ interface RuleQuestionnaireQuestion {
438
+ questionText: string;
439
+ isResponsePrivateEnabled?: boolean;
440
+ isEnabledCustomDebounce?: boolean;
441
+ customDebounceSeconds?: number;
442
+ hasValidation?: boolean;
443
+ isUsingCustomValidation?: boolean;
444
+ customValidationUrl?: string;
445
+ customValidationMethod?: string;
446
+ validationRegexType?: RuleQuestionnaireValidationRegexType;
447
+ validationRegexPattern?: string;
448
+ maxValidationAttempts?: number;
449
+ onValidationFailureReply?: string;
450
+ onValidationSuccessAction?: RuleQuestionnaireValidationAction;
451
+ onValidationSuccessActionTarget?: string;
452
+ onValidationFailureAction?: RuleQuestionnaireValidationAction;
453
+ onValidationFailureActionTarget?: string;
454
+ onValidationFailureMessage?: string;
455
+ onValidationSuccessAutoTagIds?: number[];
456
+ onValidationFailureAutoTagIds?: number[];
457
+ questionType?: RuleQuestionnaireQuestionType;
458
+ interactiveOptions?: RuleQuestionnaireInteractiveOption[];
459
+ }
460
+ /** HTTP header sent with the questionnaire outbound request. */
461
+ interface RuleQuestionnaireHeader {
462
+ id?: number;
463
+ key: string;
464
+ value: string;
465
+ }
466
+ /** Body/query field sent with the questionnaire outbound request. */
467
+ interface RuleQuestionnaireBodyField {
468
+ id?: number;
469
+ key: string;
470
+ value: string;
471
+ isFilledByAnswer?: boolean;
472
+ answerIndex?: number | null;
473
+ }
474
+ /**
475
+ * Questionnaire configuration stored on a rule.
476
+ * The API may return `null`, a full object, or an empty object `{}`.
477
+ */
478
+ interface RuleQuestionnaire {
479
+ questions?: RuleQuestionnaireQuestion[];
480
+ questionHeaders?: RuleQuestionnaireHeader[];
481
+ questionBodyFields?: RuleQuestionnaireBodyField[];
482
+ questionEndpoint?: string;
483
+ questionMethodType?: RuleHttpMethod | '';
484
+ }
485
+ /** Text-response behavior for Meta flow rules (`settings.flow.textResponse`). */
486
+ interface RuleFlowTextResponse {
487
+ behavior: 'require_flow' | 'redirect_rule';
488
+ sendReminder?: boolean;
489
+ reminderMessage?: string;
490
+ targetRuleId?: string;
491
+ }
492
+ /** Meta interactive flow configuration (`settings.flow`). */
493
+ interface RuleFlowSettings {
494
+ configId: string;
495
+ metaFlowId: string;
496
+ flowAction: 'navigate' | 'data_exchange';
497
+ flowCta: string;
498
+ flowBody: string;
499
+ webhookUrl?: string;
500
+ firstScreen?: string;
501
+ flowHeader?: string;
502
+ flowFooter?: string;
503
+ contextKey?: string;
504
+ textResponse?: RuleFlowTextResponse;
505
+ }
506
+ /**
507
+ * Rule settings JSON.
508
+ * Common keys: `interactiveType` (URA) and `flow` (action `flow`).
509
+ */
510
+ interface RuleSettings {
511
+ interactiveType?: RuleInteractiveType;
512
+ flow?: RuleFlowSettings;
513
+ [key: string]: unknown;
382
514
  }
383
515
  /** Rule entity returned by the Chat Config API. */
384
516
  interface Rule {
385
517
  id: string;
386
518
  companyId: string;
387
519
  name: string;
388
- action: string;
520
+ action: RuleAction | string;
389
521
  message: string | null;
390
522
  automaticMessage: RuleAutomaticMessage | null;
391
- callOnQueue: Record<string, unknown> | null;
523
+ callOnQueue: RuleCallOnQueue | null;
392
524
  uraDescription: string | null;
393
525
  interactiveMessageId: string | null;
394
526
  configId: string | null;
395
527
  queueId: string | null;
396
528
  redirectQueue: string | null;
397
529
  redirectRuleId: string | null;
398
- questionnaire: Record<string, unknown> | null;
399
- webhook: Record<string, unknown> | null;
530
+ questionnaire: RuleQuestionnaire | null;
531
+ webhook: RuleWebhook | null;
400
532
  isRoot: boolean;
401
533
  redirectDefault: boolean;
402
534
  redirectTimeout: number;
403
535
  delay: number | null;
404
536
  disableTyping: boolean;
405
- settings: Record<string, unknown> | null;
537
+ settings: RuleSettings | null;
406
538
  archivedAt: string | null;
407
539
  autoTagEnabled: boolean;
408
540
  autoTagIds: number[];
@@ -410,6 +542,8 @@ interface Rule {
410
542
  updatedAt: string;
411
543
  flow?: Rule[];
412
544
  }
545
+ /** Response returned by `GET /rules/:id`. */
546
+ type RuleResponse = Rule;
413
547
  /** Response returned by the Chat Config API when listing paginated rules. */
414
548
  type RulesResponse = {
415
549
  data: Rule[];
@@ -421,4 +555,4 @@ type RulesCountResponse = {
421
555
  /** Response returned by the Chat Config API when listing root rules. */
422
556
  type RootRulesResponse = RulesResponse;
423
557
 
424
- export type { Config, ConfigListByProviderResponse, ConfigProvider, DistributionType, FindOrCreateQueueRuleRequest, GetConfigsByProviderParams, GetMemberQueuesRequest, GetProviderConfigurationsParams, GetProviderDisplayInfoParams, GetRootRulesRequest, GetRulesCountRequest, GetRulesRequest, GetServiceGroupsParams, MetaTemplateButton, MetaTemplateConfigResponse, MetaTemplateConfigsResponse, Provider, ProviderConfiguration, ProviderConfigurationsResponse, ProviderDisplayInfoResponse, ProviderListResponse, ProviderName, Queue, QueueListResponse, QueueMember, QueueRule, RootRulesResponse, Rule, RuleAction, RuleArchiveStatus, RuleAssociation, RuleAutomaticMessage, RulesCountResponse, RulesResponse, ServiceGroup, ServiceGroupsResponse, WhatsAppProviderSettings, WidgetProviderSettings };
558
+ export type { Config, ConfigListByProviderResponse, ConfigProvider, DistributionType, FindOrCreateQueueRuleRequest, GetConfigsByProviderParams, GetMemberQueuesRequest, GetProviderConfigurationsParams, GetProviderDisplayInfoParams, GetRootRulesRequest, GetRuleByIdRequest, GetRulesCountRequest, GetRulesRequest, GetServiceGroupsParams, MetaTemplateButton, MetaTemplateConfigResponse, MetaTemplateConfigsResponse, Provider, ProviderConfiguration, ProviderConfigurationsResponse, ProviderDisplayInfoResponse, ProviderListResponse, ProviderName, Queue, QueueListResponse, QueueMember, QueueRule, RootRulesResponse, Rule, RuleAction, RuleArchiveStatus, RuleAssociation, RuleAutomaticMessage, RuleCallOnQueue, RuleFlowSettings, RuleFlowTextResponse, RuleHttpMethod, RuleInteractiveType, RuleQuestionnaire, RuleQuestionnaireBodyField, RuleQuestionnaireHeader, RuleQuestionnaireInteractiveOption, RuleQuestionnaireQuestion, RuleQuestionnaireQuestionType, RuleQuestionnaireValidationAction, RuleQuestionnaireValidationRegexType, RuleResponse, RuleSettings, RuleWebhook, RuleWebhookHeader, RuleWebhookResponseMapping, RulesCountResponse, RulesResponse, ServiceGroup, ServiceGroupsResponse, WhatsAppProviderSettings, WidgetProviderSettings };