@livechat/developer-studio-api 5.11.2 → 5.12.0

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.
@@ -3199,6 +3199,14 @@ var slackApi = {
3199
3199
  }
3200
3200
  };
3201
3201
 
3202
+ // src/apis/integrations/text/ai-agent/contracts.ts
3203
+ var RegenerateIntentRejectionError = class extends ApiErrorBase {
3204
+ constructor() {
3205
+ super(...arguments);
3206
+ this.name = "text";
3207
+ }
3208
+ };
3209
+
3202
3210
  // src/apis/integrations/text/ai-agent/api.ts
3203
3211
  var textAiAgentApi = {
3204
3212
  generateResponses(payload, authorization) {
@@ -3212,6 +3220,40 @@ var textAiAgentApi = {
3212
3220
  );
3213
3221
  return response;
3214
3222
  });
3223
+ },
3224
+ regenerateIntent(payload, authorization) {
3225
+ return __async(this, null, function* () {
3226
+ const getRejection = (error) => {
3227
+ var _a;
3228
+ const isTextApiError = error instanceof TextApiError;
3229
+ if (!isTextApiError) {
3230
+ return void 0;
3231
+ }
3232
+ const data = error.data;
3233
+ const { message, suggestion } = (_a = data == null ? void 0 : data.innerError) != null ? _a : {};
3234
+ if (typeof message === "string" && typeof suggestion === "string") {
3235
+ return { message, suggestion };
3236
+ }
3237
+ return void 0;
3238
+ };
3239
+ return textClientInstance.post(
3240
+ "/nlp-gateway/v2/agents/skills/regenerate-intent",
3241
+ payload,
3242
+ getTextClientConfig(__spreadProps(__spreadValues({}, authorization), {
3243
+ ensureAuthorizationToken: true
3244
+ }))
3245
+ ).then(({ data }) => data).catch((error) => {
3246
+ const rejection = getRejection(error);
3247
+ if (rejection) {
3248
+ throw new RegenerateIntentRejectionError(
3249
+ rejection.message,
3250
+ rejection,
3251
+ error.code
3252
+ );
3253
+ }
3254
+ throw error;
3255
+ });
3256
+ });
3215
3257
  }
3216
3258
  };
3217
3259
 
@@ -9283,7 +9325,7 @@ var textHelpDeskEventsZods = {
9283
9325
  ticketMessageAdded: z13.discriminatedUnion("version", [
9284
9326
  z13.object({
9285
9327
  name: z13.literal("ticket_message_added" /* TicketMessageAdded */),
9286
- version: z13.undefined()
9328
+ version: z13.literal("v0").optional()
9287
9329
  }).extend(baseFiltersZod.shape),
9288
9330
  z13.object({
9289
9331
  name: z13.literal("ticket_message_added" /* TicketMessageAdded */),
@@ -9354,6 +9396,7 @@ var TextLivechatEventNames = /* @__PURE__ */ ((TextLivechatEventNames2) => {
9354
9396
  TextLivechatEventNames2["CustomerLeftChat"] = "customer_left_chat";
9355
9397
  TextLivechatEventNames2["ChatIdle"] = "chat_idle";
9356
9398
  TextLivechatEventNames2["ProductCardEvent"] = "product_card_event";
9399
+ TextLivechatEventNames2["RichMessagePostback"] = "rich_message_postback";
9357
9400
  TextLivechatEventNames2["FormFilled"] = "form_filled";
9358
9401
  TextLivechatEventNames2["CustomFormFilled"] = "custom_form_filled";
9359
9402
  return TextLivechatEventNames2;
@@ -9369,42 +9412,49 @@ var TextLivechatProductCardEventType = /* @__PURE__ */ ((TextLivechatProductCard
9369
9412
  TextLivechatProductCardEventType2["AddToCart"] = "add_to_cart";
9370
9413
  return TextLivechatProductCardEventType2;
9371
9414
  })(TextLivechatProductCardEventType || {});
9415
+ var livechatChatContext = z14.object({
9416
+ chat_id: z14.string().min(1).optional(),
9417
+ thread_id: z14.string().min(1).optional()
9418
+ });
9419
+ var livechatEventContext = z14.object({
9420
+ event_id: z14.string().min(1).optional()
9421
+ });
9372
9422
  var textLivechatEventsZods = {
9373
9423
  provider: z14.literal("text-livechat" /* LiveChat */),
9374
9424
  eventName: z14.nativeEnum(TextLivechatEventNames),
9375
9425
  events: {
9376
- chatStarted: integrationEventBase.extend({
9426
+ chatStarted: integrationEventBase.extend(livechatChatContext.shape).extend({
9377
9427
  name: z14.literal("chat_started" /* ChatStarted */),
9378
9428
  targetAgentId: z14.string().optional()
9379
9429
  }),
9380
- chatEnded: integrationEventBase.extend({
9430
+ chatEnded: integrationEventBase.extend(livechatChatContext.shape).extend({
9381
9431
  name: z14.literal("chat_ended" /* ChatEnded */)
9382
9432
  }),
9383
- chatTransferred: integrationEventBase.extend({
9433
+ chatTransferred: integrationEventBase.extend(livechatChatContext.shape).extend({
9384
9434
  name: z14.literal("chat_transferred" /* ChatTransferred */),
9385
9435
  targetGroups: z14.array(z14.number()).optional(),
9386
9436
  targetAgents: z14.array(z14.string()).optional()
9387
9437
  }),
9388
- chatTagged: integrationEventBase.extend({
9438
+ chatTagged: integrationEventBase.extend(livechatChatContext.shape).extend({
9389
9439
  name: z14.literal("chat_tagged" /* ChatTagged */),
9390
9440
  tag: z14.string().optional()
9391
9441
  }),
9392
- chatRated: integrationEventBase.extend({
9442
+ chatRated: integrationEventBase.extend(livechatEventContext.shape).extend(livechatChatContext.shape).extend({
9393
9443
  name: z14.literal("chat_rated" /* ChatRated */),
9394
9444
  rating: z14.enum(["good", "bad", "all"]).optional()
9395
9445
  }),
9396
- chatCommented: integrationEventBase.extend({
9446
+ chatCommented: integrationEventBase.extend(livechatEventContext.shape).extend(livechatChatContext.shape).extend({
9397
9447
  name: z14.literal("chat_commented" /* ChatCommented */)
9398
9448
  }),
9399
9449
  chatMessage: z14.discriminatedUnion("version", [
9400
- z14.object({
9450
+ integrationEventBase.extend(livechatEventContext.shape).extend(livechatChatContext.shape).extend({
9401
9451
  name: z14.literal("chat_message" /* ChatMessage */),
9402
- version: z14.undefined(),
9452
+ version: z14.literal("v0").optional(),
9403
9453
  filter: z14.string().optional(),
9404
9454
  caseInsensitive: z14.boolean().optional(),
9405
9455
  matchWholeWords: z14.boolean().optional()
9406
9456
  }),
9407
- z14.object({
9457
+ integrationEventBase.extend(livechatEventContext.shape).extend(livechatChatContext.shape).extend({
9408
9458
  name: z14.literal("chat_message" /* ChatMessage */),
9409
9459
  version: z14.enum(["v1", "v2"]),
9410
9460
  filters: z14.array(z14.string()),
@@ -9412,31 +9462,42 @@ var textLivechatEventsZods = {
9412
9462
  matchWholeWords: z14.boolean().optional()
9413
9463
  })
9414
9464
  ]),
9415
- userAddedToChat: integrationEventBase.extend({
9465
+ userAddedToChat: integrationEventBase.extend(livechatChatContext.shape).extend({
9416
9466
  name: z14.literal("user_added_to_chat" /* UserAddedToChat */),
9417
9467
  userType: z14.enum(["agent", "customer"]).optional(),
9418
9468
  targetAgentId: z14.string().optional()
9419
9469
  }),
9420
- userRemovedFromChat: integrationEventBase.extend({
9470
+ userRemovedFromChat: integrationEventBase.extend(livechatChatContext.shape).extend({
9421
9471
  name: z14.literal("user_removed_from_chat" /* UserRemovedFromChat */)
9422
9472
  }),
9423
- customerLeftChat: integrationEventBase.extend({
9473
+ customerLeftChat: integrationEventBase.extend(livechatEventContext.shape).extend(livechatChatContext.shape).extend({
9424
9474
  name: z14.literal("customer_left_chat" /* CustomerLeftChat */),
9425
9475
  reasons: z14.array(z14.nativeEnum(CustomerLeftChatReason)).optional()
9426
9476
  }),
9427
- chatIdle: integrationEventBase.extend({
9477
+ chatIdle: integrationEventBase.extend(livechatEventContext.shape).extend(livechatChatContext.shape).extend({
9428
9478
  name: z14.literal("chat_idle" /* ChatIdle */)
9429
9479
  }),
9430
- productCardEvent: integrationEventBase.extend({
9480
+ productCardEvent: integrationEventBase.extend(livechatEventContext.shape).extend(livechatChatContext.shape).extend({
9431
9481
  name: z14.literal("product_card_event" /* ProductCardEvent */),
9432
9482
  type: z14.nativeEnum(TextLivechatProductCardEventType),
9433
9483
  product_id: z14.string().optional()
9434
9484
  }),
9435
- formFilled: integrationEventBase.extend({
9485
+ richMessagePostback: integrationEventBase.extend(livechatEventContext.shape).extend(livechatChatContext.shape).extend({
9486
+ name: z14.literal("rich_message_postback" /* RichMessagePostback */),
9487
+ postbacks: z14.union([
9488
+ z14.array(z14.string().min(1)),
9489
+ z14.record(z14.string().min(1), z14.string().min(1))
9490
+ ]).refine((input) => {
9491
+ const ids = Array.isArray(input) ? input : Object.values(input);
9492
+ return ids.length > 0 && new Set(ids).size === ids.length;
9493
+ }, "Postbacks must be nonempty and IDs must be unique"),
9494
+ user_ids: z14.array(z14.string().min(1)).min(1).optional()
9495
+ }),
9496
+ formFilled: integrationEventBase.extend(livechatEventContext.shape).extend(livechatChatContext.shape).extend({
9436
9497
  name: z14.literal("form_filled" /* FormFilled */),
9437
9498
  form_id: z14.string().optional()
9438
9499
  }),
9439
- customFormFilled: integrationEventBase.extend({
9500
+ customFormFilled: integrationEventBase.extend(livechatEventContext.shape).extend(livechatChatContext.shape).extend({
9440
9501
  name: z14.literal("custom_form_filled" /* CustomFormFilled */),
9441
9502
  form_id: z14.string().optional()
9442
9503
  })
@@ -9455,6 +9516,7 @@ var textLivechatEventsZods = {
9455
9516
  this.events.customerLeftChat,
9456
9517
  this.events.chatIdle,
9457
9518
  this.events.productCardEvent,
9519
+ this.events.richMessagePostback,
9458
9520
  this.events.formFilled,
9459
9521
  this.events.customFormFilled
9460
9522
  ]);
@@ -9867,6 +9929,8 @@ export {
9867
9929
  TextLivechatEventNames,
9868
9930
  CustomerLeftChatReason,
9869
9931
  TextLivechatProductCardEventType,
9932
+ livechatChatContext,
9933
+ livechatEventContext,
9870
9934
  textLivechatEventsZods,
9871
9935
  textEventsZods,
9872
9936
  integrationEventsZods,
@@ -9929,6 +9993,7 @@ export {
9929
9993
  textClientInstance,
9930
9994
  getTextClientConfig,
9931
9995
  initTextClient,
9996
+ RegenerateIntentRejectionError,
9932
9997
  TextBillingApiError,
9933
9998
  UnauthorizeTextBillingApiError,
9934
9999
  textBillingClientInstance,