@apotech-os/support-kit 6.3.0 → 7.0.1
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.
- package/README.md +63 -0
- package/dist/{chunk-CQJJZA4F.js → chunk-QCRCRNYE.js} +36 -6
- package/dist/chunk-QCRCRNYE.js.map +1 -0
- package/dist/index.cjs +742 -32
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +51 -5
- package/dist/index.d.ts +51 -5
- package/dist/index.js +707 -32
- package/dist/index.js.map +1 -1
- package/dist/ui/index.cjs +223 -7
- package/dist/ui/index.cjs.map +1 -1
- package/dist/ui/index.js +207 -5
- package/dist/ui/index.js.map +1 -1
- package/package.json +5 -5
- package/dist/chunk-CQJJZA4F.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -28,6 +28,17 @@ function requiresFollowup(verdict) {
|
|
|
28
28
|
return verdict === "send_and_escalate";
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
+
// src/domain/origin.ts
|
|
32
|
+
var DECISION_ORIGINS = ["triage", "followup"];
|
|
33
|
+
var DEFAULT_DECISION_ORIGIN = "triage";
|
|
34
|
+
var ORIGIN_DESCRIPTION = "Which pass wrote this row: 'triage' (the cron's first pass) or 'followup' (a reply to a subsequent customer message, spec-gorgias-followup-webhook-v1 \xA77.2).";
|
|
35
|
+
function isDecisionOrigin(value) {
|
|
36
|
+
return typeof value === "string" && DECISION_ORIGINS.includes(value);
|
|
37
|
+
}
|
|
38
|
+
function toDecisionOrigin(value) {
|
|
39
|
+
return isDecisionOrigin(value) ? value : DEFAULT_DECISION_ORIGIN;
|
|
40
|
+
}
|
|
41
|
+
|
|
31
42
|
// src/graph/state.ts
|
|
32
43
|
var OUTCOMES = [
|
|
33
44
|
"sent",
|
|
@@ -1346,6 +1357,8 @@ var CATEGORY_FIELD_DESCRIPTION_UID = "fa2aeb51-47b0-4c26-845a-0b9f543f0c89";
|
|
|
1346
1357
|
var CATEGORY_FIELD_EXAMPLES_UID = "39e52ad6-34b1-4151-a70b-7f996648b9b0";
|
|
1347
1358
|
var CATEGORY_FIELD_FAST_RESPONSE_ENABLED_UID = "4fa75e78-b826-4741-9612-b6cf28bde9f9";
|
|
1348
1359
|
var CATEGORY_FIELD_AUTO_REPLY_ENABLED_UID = "c6822551-821f-4255-b220-be40c9b56052";
|
|
1360
|
+
var CATEGORY_FIELD_FOLLOWUP_FAST_RESPONSE_ENABLED_UID = "6ea5d15b-166e-4c29-8555-844bd7f6193e";
|
|
1361
|
+
var CATEGORY_FIELD_FOLLOWUP_AUTO_REPLY_ENABLED_UID = "81804963-6ffb-486c-a663-6287353adff5";
|
|
1349
1362
|
var CATEGORY_INDEX_TAG_NAME_UID = "5463dac5-715d-4545-ad75-905477d868eb";
|
|
1350
1363
|
var CATEGORY_INDEX_NAME_UID = "2eda6e49-387a-4e08-94a8-06250652692d";
|
|
1351
1364
|
var CATEGORY_INDEX_ORDER_UID = "bf4b1f9c-2dc8-4480-8fcb-dba789e8fe62";
|
|
@@ -1379,6 +1392,7 @@ var TRIAGE_DECISION_FIELD_ERROR_UID = "b271362b-a1b3-4110-a197-0b7a2ec6b152";
|
|
|
1379
1392
|
var TRIAGE_DECISION_FIELD_RUN_ID_UID = "a1e244d6-8f4f-4cd5-8794-14f6e419b64e";
|
|
1380
1393
|
var TRIAGE_DECISION_FIELD_SUBJECT_RENAMED_UID = "449f1960-be88-4e42-96ee-43cd90f36f4c";
|
|
1381
1394
|
var TRIAGE_DECISION_FIELD_TICKET_URL_UID = "727a775a-ea93-460f-9d08-16b05424c453";
|
|
1395
|
+
var TRIAGE_DECISION_FIELD_ORIGIN_UID = "8bde8d93-7d06-4cb5-8a88-2d6db562af05";
|
|
1382
1396
|
var TRIAGE_DECISION_INDEX_TICKET_ID_UID = "20433066-e029-4faf-8033-c205cf5de0fb";
|
|
1383
1397
|
var TRIAGE_DECISION_INDEX_DECIDED_AT_UID = "94040f6d-1d55-498f-8db8-abe5aed17c0a";
|
|
1384
1398
|
var TRIAGE_DECISION_INDEX_ESCALATED_UID = "1c0ac4c3-9a48-4858-bbbf-0c689bbb5be5";
|
|
@@ -1411,6 +1425,7 @@ var GENERATED_RESPONSE_FIELD_GENERATED_MESSAGE_COUNT_UID = "33a282d3-7a1c-45a3-9
|
|
|
1411
1425
|
var GENERATED_RESPONSE_FIELD_GENERATED_LAST_MESSAGE_AT_UID = "94c4594f-4ad0-4e3b-8a0b-76402b437434";
|
|
1412
1426
|
var GENERATED_RESPONSE_FIELD_SENDING_AT_UID = "2ae9634b-79bb-42d2-a949-8b0f1ac9c763";
|
|
1413
1427
|
var GENERATED_RESPONSE_FIELD_OUTCOME_UID = "8834b334-8f91-46f7-9bb9-96b69092d0ae";
|
|
1428
|
+
var GENERATED_RESPONSE_FIELD_ORIGIN_UID = "e75034d3-ee7f-40e7-b4fe-8be7b4322bdc";
|
|
1414
1429
|
var GENERATED_RESPONSE_INDEX_TICKET_ID_UID = "a4534d26-8f43-4510-9c03-0b28c3d3f8e2";
|
|
1415
1430
|
var GENERATED_RESPONSE_INDEX_OPEN_TICKET_KEY_UID = "3d430166-07a2-43c2-911b-89ec25d13f64";
|
|
1416
1431
|
var GENERATED_RESPONSE_INDEX_STATUS_UID = "f5c4e5d4-0810-424d-8a14-617e9555a7f3";
|
|
@@ -1559,6 +1574,24 @@ function buildCategoryRecord(slug) {
|
|
|
1559
1574
|
label: "Auto-reply enabled",
|
|
1560
1575
|
isNullable: false,
|
|
1561
1576
|
defaultValue: false
|
|
1577
|
+
},
|
|
1578
|
+
{
|
|
1579
|
+
universalIdentifier: CATEGORY_FIELD_FOLLOWUP_FAST_RESPONSE_ENABLED_UID,
|
|
1580
|
+
name: "followupFastResponseEnabled",
|
|
1581
|
+
type: appKit.FieldType.BOOLEAN,
|
|
1582
|
+
label: "Follow-up fast response enabled",
|
|
1583
|
+
description: "Draft a reply to the FOLLOWING customer messages of an already-handled ticket (spec-gorgias-followup-webhook-v1 \xA77.1). Independent of `fastResponseEnabled`: a category may answer the first message without following the thread, and the reverse.",
|
|
1584
|
+
isNullable: false,
|
|
1585
|
+
defaultValue: false
|
|
1586
|
+
},
|
|
1587
|
+
{
|
|
1588
|
+
universalIdentifier: CATEGORY_FIELD_FOLLOWUP_AUTO_REPLY_ENABLED_UID,
|
|
1589
|
+
name: "followupAutoReplyEnabled",
|
|
1590
|
+
type: appKit.FieldType.BOOLEAN,
|
|
1591
|
+
label: "Follow-up auto-reply enabled",
|
|
1592
|
+
description: "Those follow-up drafts may be sent automatically (\xA77.1). Implies `followupFastResponseEnabled`, exactly as `autoReplyEnabled` implies `fastResponseEnabled`.",
|
|
1593
|
+
isNullable: false,
|
|
1594
|
+
defaultValue: false
|
|
1562
1595
|
}
|
|
1563
1596
|
],
|
|
1564
1597
|
indexes: [
|
|
@@ -1745,7 +1778,8 @@ function buildTriageDecisionRecord(slug) {
|
|
|
1745
1778
|
name: "confidence",
|
|
1746
1779
|
type: appKit.FieldType.SELECT,
|
|
1747
1780
|
label: "Confidence",
|
|
1748
|
-
|
|
1781
|
+
description: "How confident the classifier was. NULL on a follow-up pass (spec-gorgias-followup-webhook-v1 \xA77.2): no classifier runs there \u2014 the category is inherited from the tag the first pass applied \u2014 so there is no confidence to state, and inventing one would be a stored lie. Readers that need a value derive 'low' (process-response.ts's classificationFromDecision).",
|
|
1782
|
+
isNullable: true,
|
|
1749
1783
|
options: [...CONFIDENCE_OPTIONS]
|
|
1750
1784
|
},
|
|
1751
1785
|
{
|
|
@@ -1817,6 +1851,15 @@ function buildTriageDecisionRecord(slug) {
|
|
|
1817
1851
|
label: "Subject renamed",
|
|
1818
1852
|
isNullable: false,
|
|
1819
1853
|
defaultValue: false
|
|
1854
|
+
},
|
|
1855
|
+
{
|
|
1856
|
+
universalIdentifier: TRIAGE_DECISION_FIELD_ORIGIN_UID,
|
|
1857
|
+
name: "origin",
|
|
1858
|
+
type: appKit.FieldType.TEXT,
|
|
1859
|
+
label: "Origin",
|
|
1860
|
+
description: ORIGIN_DESCRIPTION,
|
|
1861
|
+
isNullable: false,
|
|
1862
|
+
defaultValue: DEFAULT_DECISION_ORIGIN
|
|
1820
1863
|
}
|
|
1821
1864
|
],
|
|
1822
1865
|
indexes: [
|
|
@@ -2073,6 +2116,15 @@ function buildGeneratedResponseRecord(slug) {
|
|
|
2073
2116
|
label: "Sending at",
|
|
2074
2117
|
description: "When status became 'sending' \u2014 the sweep's staleness clock (\xA73.5).",
|
|
2075
2118
|
isNullable: true
|
|
2119
|
+
},
|
|
2120
|
+
{
|
|
2121
|
+
universalIdentifier: GENERATED_RESPONSE_FIELD_ORIGIN_UID,
|
|
2122
|
+
name: "origin",
|
|
2123
|
+
type: appKit.FieldType.TEXT,
|
|
2124
|
+
label: "Origin",
|
|
2125
|
+
description: ORIGIN_DESCRIPTION,
|
|
2126
|
+
isNullable: false,
|
|
2127
|
+
defaultValue: DEFAULT_DECISION_ORIGIN
|
|
2076
2128
|
}
|
|
2077
2129
|
],
|
|
2078
2130
|
indexes: [
|
|
@@ -2504,6 +2556,17 @@ var SUPPORT_KIT_SETTINGS_FIELDS = [
|
|
|
2504
2556
|
{ key: "autoRepliedTag", type: "string", label: "Auto-replied tag", default: "wai/auto-replied" },
|
|
2505
2557
|
{ key: "needsReviewTag", type: "string", label: "Review-before-send tag", default: "wai/escalated" },
|
|
2506
2558
|
{ key: "followupTag", type: "string", label: "Followup tag", default: "wai/human-required" },
|
|
2559
|
+
// Follow-up webhook (spec-gorgias-followup-webhook-v1 D2)
|
|
2560
|
+
// The tag a ticket must ALREADY carry for this app to answer a SUBSEQUENT
|
|
2561
|
+
// customer message on it. Deliberately empty by default, twice over:
|
|
2562
|
+
// - two support apps installed on ONE Gorgias account each receive every
|
|
2563
|
+
// `ticket-message-created` event, so a shared default would make a
|
|
2564
|
+
// freshly-installed app answer the other audience's tickets. Two apps of
|
|
2565
|
+
// the same account MUST configure distinct values;
|
|
2566
|
+
// - empty therefore means "process no follow-up message at all", which is
|
|
2567
|
+
// both the fail-closed default and the feature's kill switch.
|
|
2568
|
+
// Not named `followupTag`: that key is taken (`wai/human-required`).
|
|
2569
|
+
{ key: "webhookScopeTag", type: "string", label: "Webhook scope tag", default: "" },
|
|
2507
2570
|
// Sending
|
|
2508
2571
|
{ key: "autoSendEnabled", type: "boolean", label: "Auto-send enabled", default: false },
|
|
2509
2572
|
{ key: "senderEmail", type: "string", label: "Sender email", default: "" },
|
|
@@ -3179,9 +3242,6 @@ function parseApprovalKey(key) {
|
|
|
3179
3242
|
const id = key.slice(PREFIX.length);
|
|
3180
3243
|
return id.length > 0 ? id : null;
|
|
3181
3244
|
}
|
|
3182
|
-
function buildInboxKey(generatedResponseId, suffix) {
|
|
3183
|
-
return suffix ? `${PREFIX}${generatedResponseId}:${suffix}` : `${PREFIX}${generatedResponseId}`;
|
|
3184
|
-
}
|
|
3185
3245
|
|
|
3186
3246
|
// src/functions/traced-input.ts
|
|
3187
3247
|
var TRACED_INPUT_MAX_CHARS = 4e3;
|
|
@@ -3222,7 +3282,9 @@ function toCategory(record) {
|
|
|
3222
3282
|
description: data.description ?? null,
|
|
3223
3283
|
examples: data.examples ?? null,
|
|
3224
3284
|
autoReplyEnabled: data.autoReplyEnabled ?? false,
|
|
3225
|
-
fastResponseEnabled: data.fastResponseEnabled ?? false
|
|
3285
|
+
fastResponseEnabled: data.fastResponseEnabled ?? false,
|
|
3286
|
+
followupFastResponseEnabled: data.followupFastResponseEnabled ?? false,
|
|
3287
|
+
followupAutoReplyEnabled: data.followupAutoReplyEnabled ?? false
|
|
3226
3288
|
};
|
|
3227
3289
|
}
|
|
3228
3290
|
function toCategoryGroup(record) {
|
|
@@ -3271,7 +3333,8 @@ function toGeneratedResponse(record) {
|
|
|
3271
3333
|
autoSendDecision: data.autoSendDecision ?? null,
|
|
3272
3334
|
sentAt: data.sentAt ?? null,
|
|
3273
3335
|
sentMessageId: data.sentMessageId ?? null,
|
|
3274
|
-
error: data.error ?? null
|
|
3336
|
+
error: data.error ?? null,
|
|
3337
|
+
origin: toDecisionOrigin(data.origin)
|
|
3275
3338
|
};
|
|
3276
3339
|
}
|
|
3277
3340
|
async function listCategories(api) {
|
|
@@ -3331,6 +3394,14 @@ function buildPromptsTable(config, draft2, nodes) {
|
|
|
3331
3394
|
}
|
|
3332
3395
|
|
|
3333
3396
|
// src/functions/process-response.ts
|
|
3397
|
+
function autoReplyEnabledFor(origin, category) {
|
|
3398
|
+
if (!category) return false;
|
|
3399
|
+
return origin === "followup" ? category.followupAutoReplyEnabled : category.autoReplyEnabled;
|
|
3400
|
+
}
|
|
3401
|
+
function applyFollowupSendPolicy(profile, origin) {
|
|
3402
|
+
if (origin !== "followup") return profile;
|
|
3403
|
+
return { ...profile, autoSend: { ...profile.autoSend, requireHighTriage: false } };
|
|
3404
|
+
}
|
|
3334
3405
|
function classificationFromDecision(decision) {
|
|
3335
3406
|
const data = decision.data;
|
|
3336
3407
|
return {
|
|
@@ -3395,9 +3466,13 @@ async function respondToPendingResponse(ctx, config, recordId) {
|
|
|
3395
3466
|
const escalated = decision.data.escalated === true;
|
|
3396
3467
|
const categoryRecord = await getOptional(ctx, "category", data.categoryId ?? null);
|
|
3397
3468
|
const category = categoryRecord ? toCategory(categoryRecord) : null;
|
|
3469
|
+
const origin = toDecisionOrigin(data.origin);
|
|
3398
3470
|
const agentRecord2 = data.agentId ? await getOptional(ctx, "agent", data.agentId) : null;
|
|
3399
3471
|
const agent = agentRecord2 ? toAgent(agentRecord2) : await resolveDraftAgent(ctx.api, null);
|
|
3400
|
-
const profile =
|
|
3472
|
+
const profile = applyFollowupSendPolicy(
|
|
3473
|
+
settingsToProfile(settings, buildPromptsTable(config, draftPromptRefFor(agent, config), settings.nodes)),
|
|
3474
|
+
origin
|
|
3475
|
+
);
|
|
3401
3476
|
const dryRun = settings.dryRun === true;
|
|
3402
3477
|
const trace = { sessionId: ticketId, tags: [`app:${config.slug}`] };
|
|
3403
3478
|
const ports = dryRun ? withRecordingWritePorts(buildTicketPorts(ctx, trace), ctx.api) : buildTicketPorts(ctx, trace);
|
|
@@ -3428,7 +3503,7 @@ async function respondToPendingResponse(ctx, config, recordId) {
|
|
|
3428
3503
|
ports,
|
|
3429
3504
|
toolContext: createNoToolContext(),
|
|
3430
3505
|
budget,
|
|
3431
|
-
category: { autoReplyEnabled: category
|
|
3506
|
+
category: { autoReplyEnabled: autoReplyEnabledFor(origin, category), minConfidence: null },
|
|
3432
3507
|
categories: [],
|
|
3433
3508
|
log: (msg) => ctx.logger.debug(msg),
|
|
3434
3509
|
send: dryRun ? { mode: "none" } : { mode: "claimed", claim: seam.claim, commit: seam.commit },
|
|
@@ -3467,18 +3542,9 @@ async function respondToPendingResponse(ctx, config, recordId) {
|
|
|
3467
3542
|
case "guardrail_hold":
|
|
3468
3543
|
await finalizeNonSent(ctx, recordId, ticketId, "ready", draftExtra);
|
|
3469
3544
|
return;
|
|
3470
|
-
case "needs_human":
|
|
3471
|
-
|
|
3472
|
-
if (persisted) {
|
|
3473
|
-
await ctx.api.inbox.raise({
|
|
3474
|
-
key: buildInboxKey(recordId),
|
|
3475
|
-
severity: "warning",
|
|
3476
|
-
title: `R\xE9ponse g\xE9n\xE9r\xE9e \xE0 revoir \u2014 ticket ${ticketId}`,
|
|
3477
|
-
entityRef: { appSlug: config.slug, objectKey: "generated-response", id: recordId }
|
|
3478
|
-
});
|
|
3479
|
-
}
|
|
3545
|
+
case "needs_human":
|
|
3546
|
+
await finalizeNonSent(ctx, recordId, ticketId, "ready", draftExtra);
|
|
3480
3547
|
return;
|
|
3481
|
-
}
|
|
3482
3548
|
case "awaiting_approval": {
|
|
3483
3549
|
const persisted = await finalizeNonSent(ctx, recordId, ticketId, "ready", draftExtra);
|
|
3484
3550
|
if (persisted && !dryRun) {
|
|
@@ -3680,13 +3746,15 @@ async function writeErrorDecision(ctx, ref, message, deps) {
|
|
|
3680
3746
|
}
|
|
3681
3747
|
}
|
|
3682
3748
|
async function escalateTicket(ctx, ref, deps) {
|
|
3683
|
-
|
|
3749
|
+
await flagEscalation(ctx, ref, deps.profile.audit.escalationTag, deps.ports);
|
|
3750
|
+
}
|
|
3751
|
+
async function flagEscalation(ctx, ref, tag, ports) {
|
|
3684
3752
|
if (!tag) {
|
|
3685
|
-
ctx.logger.warn(`triage-tick: ticket ${ref.id}
|
|
3753
|
+
ctx.logger.warn(`triage-tick: ticket ${ref.id} is escalated but escalationTag is not configured \u2014 no tag applied`);
|
|
3686
3754
|
return;
|
|
3687
3755
|
}
|
|
3688
3756
|
try {
|
|
3689
|
-
await
|
|
3757
|
+
await ports.state.flag(ref, tag);
|
|
3690
3758
|
} catch (flagErr) {
|
|
3691
3759
|
ctx.logger.error(`triage-tick: failed to escalate ticket ${ref.id} \u2014 it is NOT tagged for a human`, {
|
|
3692
3760
|
error: flagErr instanceof Error ? flagErr.message : String(flagErr)
|
|
@@ -3737,9 +3805,11 @@ async function processOneTicket(ctx, ref, deps) {
|
|
|
3737
3805
|
escalated: state.escalated,
|
|
3738
3806
|
status: "ok",
|
|
3739
3807
|
runId,
|
|
3740
|
-
subjectRenamed
|
|
3808
|
+
subjectRenamed,
|
|
3809
|
+
origin: "triage"
|
|
3741
3810
|
});
|
|
3742
3811
|
await ports.state.record(ref, classification, profile.audit);
|
|
3812
|
+
if (state.escalated) await flagEscalation(ctx, ref, profile.audit.escalationTag, ports);
|
|
3743
3813
|
if (!isEligibleForGeneratedResponse(profile, classification, state.escalated, category)) return;
|
|
3744
3814
|
const draftAgent = await resolveDraftAgent(ctx.api, category?.agentId ?? null);
|
|
3745
3815
|
const conversation = state.conversation;
|
|
@@ -3763,7 +3833,8 @@ async function processOneTicket(ctx, ref, deps) {
|
|
|
3763
3833
|
guardrailHits: [],
|
|
3764
3834
|
servedTo: [],
|
|
3765
3835
|
servedCount: 0,
|
|
3766
|
-
followupRequired: false
|
|
3836
|
+
followupRequired: false,
|
|
3837
|
+
origin: "triage"
|
|
3767
3838
|
});
|
|
3768
3839
|
} catch (err) {
|
|
3769
3840
|
if (err instanceof appKit.AppApiError && err.status === 409) {
|
|
@@ -3848,12 +3919,6 @@ async function sweepStalledSending(ctx, now, escalationTag, statePort) {
|
|
|
3848
3919
|
if (!reclaimed) continue;
|
|
3849
3920
|
const ref = { id: ticketId, channel: "gorgias" };
|
|
3850
3921
|
await statePort.flag(ref, escalationTag);
|
|
3851
|
-
await ctx.api.inbox.raise({
|
|
3852
|
-
key: buildInboxKey(row.id, "stalled-send"),
|
|
3853
|
-
severity: "warning",
|
|
3854
|
-
title: `Envoi bloqu\xE9 d\xE9tect\xE9 \u2014 ticket ${ticketId}`,
|
|
3855
|
-
body: 'La r\xE9ponse est rest\xE9e en statut "sending" plus de 30 minutes et a \xE9t\xE9 replac\xE9e en attente humaine.'
|
|
3856
|
-
});
|
|
3857
3922
|
}
|
|
3858
3923
|
}
|
|
3859
3924
|
async function sweepStalledPending(ctx, now) {
|
|
@@ -4049,6 +4114,8 @@ var CREATE_SHARED_PROMPT_VERSION_INPUT_NAME_UID = "1039e196-cf6e-438e-8ec9-7ab42
|
|
|
4049
4114
|
var CREATE_SHARED_PROMPT_VERSION_INPUT_CONTENT_UID = "10ffe3e1-972e-43b4-bb45-343c4664464f";
|
|
4050
4115
|
var SYNC_AGENT_PROMPT_SNAPSHOT_INPUT_PROMPT_NAME_UID = "2f5d6cbb-1c69-4a76-9d8f-1a3f0a4e57c2";
|
|
4051
4116
|
var INVALIDATE_RESPONSE_INPUT_GENERATED_RESPONSE_ID_UID = "9748baf5-97be-4a22-940d-46ef2f16a175";
|
|
4117
|
+
var TEST_GORGIAS_WEBHOOK_INPUT_TICKET_ID_UID = "2cfcbfc1-77f1-4081-8fba-5f3a51c29e62";
|
|
4118
|
+
var TEST_GORGIAS_WEBHOOK_INPUT_MODE_UID = "e75c5ec9-1205-492f-87df-a84ec12753f8";
|
|
4052
4119
|
|
|
4053
4120
|
// src/functions/run-triage-now.ts
|
|
4054
4121
|
var TRIAGE_RUN_REQUESTED_EVENT = "triage.run.requested";
|
|
@@ -5769,6 +5836,605 @@ function nonEmptyString(value) {
|
|
|
5769
5836
|
return typeof value === "string" && value.length > 0 ? value : null;
|
|
5770
5837
|
}
|
|
5771
5838
|
|
|
5839
|
+
// src/functions/followup-gates.ts
|
|
5840
|
+
var LABELS = {
|
|
5841
|
+
G1: "Identifiant de ticket",
|
|
5842
|
+
G2: "Tag de p\xE9rim\xE8tre configur\xE9",
|
|
5843
|
+
G5: "Tag de p\xE9rim\xE8tre pr\xE9sent sur le ticket",
|
|
5844
|
+
G6: "Aucune reprise humaine",
|
|
5845
|
+
G7: "Cat\xE9gorie r\xE9solue et opt\xE9e",
|
|
5846
|
+
G8: "Nouveau message client"
|
|
5847
|
+
};
|
|
5848
|
+
function humanTakeoverTags(settings) {
|
|
5849
|
+
const configured = [settings.escalationTag, settings.needsReviewTag, settings.followupTag].map((tag) => tag.trim()).filter((tag) => tag !== "");
|
|
5850
|
+
return [...new Set(configured)];
|
|
5851
|
+
}
|
|
5852
|
+
function evaluateTicketIdGate(ticketId) {
|
|
5853
|
+
return ticketId === null ? stopped("G1", "Aucun identifiant de ticket exploitable (il doit \xEAtre une suite de chiffres).") : passed("G1", `Ticket ${ticketId}.`);
|
|
5854
|
+
}
|
|
5855
|
+
function evaluateScopeGate(settings) {
|
|
5856
|
+
return settings.webhookScopeTag.trim() === "" ? stopped("G2", "Le r\xE9glage \xAB Tag de p\xE9rim\xE8tre webhook \xBB est vide : aucun message suivant n\u2019est trait\xE9.") : passed("G2", `P\xE9rim\xE8tre : \xAB ${settings.webhookScopeTag} \xBB.`);
|
|
5857
|
+
}
|
|
5858
|
+
function skippedFollowupGates(gates) {
|
|
5859
|
+
return gates.map((gate) => ({
|
|
5860
|
+
gate,
|
|
5861
|
+
label: LABELS[gate],
|
|
5862
|
+
status: "skipped",
|
|
5863
|
+
detail: "Non \xE9valu\xE9 : un gate pr\xE9c\xE9dent a arr\xEAt\xE9 le traitement."
|
|
5864
|
+
}));
|
|
5865
|
+
}
|
|
5866
|
+
var FRESH_READ_GATES = ["G5", "G6", "G7", "G8"];
|
|
5867
|
+
var ALL_FOLLOWUP_GATES = ["G1", "G2", ...FRESH_READ_GATES];
|
|
5868
|
+
function evaluateTicketGates(input) {
|
|
5869
|
+
const { settings, tags, categories, conversation, anchor } = input;
|
|
5870
|
+
const trace = newTrace(FRESH_READ_GATES);
|
|
5871
|
+
trace.record(scopeTagOnTicket(settings, tags));
|
|
5872
|
+
trace.record(noHumanTakeover(settings, tags));
|
|
5873
|
+
const match = trace.record(categoryGate(categories, tags));
|
|
5874
|
+
if (match) trace.category = match;
|
|
5875
|
+
trace.record(newCustomerMessage(conversation, anchor));
|
|
5876
|
+
return trace.done();
|
|
5877
|
+
}
|
|
5878
|
+
function evaluatePayloadGates(input) {
|
|
5879
|
+
const { settings, body, categories, anchor } = input;
|
|
5880
|
+
const trace = newTrace(FRESH_READ_GATES);
|
|
5881
|
+
const tags = body.tags;
|
|
5882
|
+
if (tags === null) {
|
|
5883
|
+
const detail = "Les tags du ticket n\u2019ont pas pu \xEAtre lus dans la charge utile \u2014 la lecture fra\xEEche tranchera.";
|
|
5884
|
+
trace.record(muted("G5", detail));
|
|
5885
|
+
trace.record(muted("G6", detail));
|
|
5886
|
+
trace.record(muted("G7", detail));
|
|
5887
|
+
} else {
|
|
5888
|
+
trace.record(scopeTagOnTicket(settings, tags));
|
|
5889
|
+
trace.record(noHumanTakeover(settings, tags));
|
|
5890
|
+
trace.record(singleCategoryMatch(categories, tags));
|
|
5891
|
+
}
|
|
5892
|
+
trace.record(payloadNewCustomerMessage(body, anchor));
|
|
5893
|
+
return trace.done();
|
|
5894
|
+
}
|
|
5895
|
+
function scopeTagOnTicket(settings, tags) {
|
|
5896
|
+
const scopeTag = settings.webhookScopeTag.trim();
|
|
5897
|
+
return tags.includes(scopeTag) ? passed("G5", `Le ticket porte \xAB ${scopeTag} \xBB.`) : stopped("G5", `Le ticket ne porte pas le tag de p\xE9rim\xE8tre \xAB ${scopeTag} \xBB : il n\u2019appartient pas \xE0 cette app.`);
|
|
5898
|
+
}
|
|
5899
|
+
function noHumanTakeover(settings, tags) {
|
|
5900
|
+
const present = humanTakeoverTags(settings).filter((tag) => tags.includes(tag));
|
|
5901
|
+
return present.length === 0 ? passed("G6", "Aucun tag de reprise humaine sur le ticket.") : stopped("G6", `Un humain a repris le fil (tag ${present.join(", ")}) : aucune r\xE9ponse automatique.`);
|
|
5902
|
+
}
|
|
5903
|
+
function categoryGate(categories, tags) {
|
|
5904
|
+
const single = singleCategoryMatch(categories, tags);
|
|
5905
|
+
if (single.status === "stopped") return single;
|
|
5906
|
+
const category = matchingCategories(categories, tags)[0];
|
|
5907
|
+
if (!category.followupFastResponseEnabled) {
|
|
5908
|
+
return stopped("G7", `La cat\xE9gorie \xAB ${category.name} \xBB n\u2019a pas activ\xE9 les r\xE9ponses aux messages suivants.`);
|
|
5909
|
+
}
|
|
5910
|
+
if (!category.agentId) {
|
|
5911
|
+
return stopped("G7", `La cat\xE9gorie \xAB ${category.name} \xBB n\u2019a aucun agent : personne pour r\xE9diger.`);
|
|
5912
|
+
}
|
|
5913
|
+
return { ...passed("G7", `Cat\xE9gorie \xAB ${category.name} \xBB (tag \xAB ${category.tagName} \xBB).`), category };
|
|
5914
|
+
}
|
|
5915
|
+
function singleCategoryMatch(categories, tags) {
|
|
5916
|
+
const matches = matchingCategories(categories, tags);
|
|
5917
|
+
if (matches.length === 1) return passed("G7", `Cat\xE9gorie \xAB ${matches[0].name} \xBB.`);
|
|
5918
|
+
return matches.length === 0 ? stopped("G7", "Aucune cat\xE9gorie ne correspond \xE0 un tag du ticket : la d\xE9cision de triage est illisible.") : stopped(
|
|
5919
|
+
"G7",
|
|
5920
|
+
`${matches.length} cat\xE9gories correspondent aux tags du ticket (${matches.map((c) => c.tagName).join(", ")}) : d\xE9cision ambigu\xEB.`
|
|
5921
|
+
);
|
|
5922
|
+
}
|
|
5923
|
+
function matchingCategories(categories, tags) {
|
|
5924
|
+
return categories.filter((category) => tags.includes(category.tagName));
|
|
5925
|
+
}
|
|
5926
|
+
function newCustomerMessage(conversation, anchor) {
|
|
5927
|
+
if (conversation.isClosed) return stopped("G8", "Le ticket est ferm\xE9.");
|
|
5928
|
+
const last = conversation.messages[conversation.messages.length - 1];
|
|
5929
|
+
if (!last) return stopped("G8", "La conversation extraite est vide.");
|
|
5930
|
+
if (!isCustomerTurnWithWords(last)) {
|
|
5931
|
+
return stopped("G8", "Le dernier message du fil n\u2019est pas un message client porteur de mots (agent, note interne, ou pi\xE8ce jointe seule).");
|
|
5932
|
+
}
|
|
5933
|
+
if (anchor === null) return passed("G8", "Le dernier message est du client ; aucune r\xE9ponse ant\xE9rieure, donc aucune ancre \xE0 battre.");
|
|
5934
|
+
const lastAt = conversation.lastMessageAt;
|
|
5935
|
+
if (!lastAt) return stopped("G8", "Le dernier message ne porte aucun horodatage : impossible de prouver qu\u2019il est post\xE9rieur \xE0 la derni\xE8re r\xE9ponse.");
|
|
5936
|
+
return lastAt.getTime() > anchor.getTime() ? passed("G8", `Message client du ${lastAt.toISOString()}, post\xE9rieur \xE0 la derni\xE8re r\xE9ponse.`) : stopped("G8", `Le dernier message (${lastAt.toISOString()}) n\u2019est pas post\xE9rieur \xE0 la derni\xE8re r\xE9ponse (${anchor.toISOString()}) : relivraison ou \xE9v\xE9nement en retard.`);
|
|
5937
|
+
}
|
|
5938
|
+
function payloadNewCustomerMessage(body, anchor) {
|
|
5939
|
+
if (body.isClosed === true) return stopped("G8", "La charge utile annonce un ticket ferm\xE9.");
|
|
5940
|
+
if (body.lastMessageFromAgent === true) return stopped("G8", "La charge utile annonce un dernier message d\u2019agent.");
|
|
5941
|
+
if (body.lastMessagePublic === false) return stopped("G8", "La charge utile annonce une note interne en dernier message.");
|
|
5942
|
+
if (anchor !== null && body.lastMessageAt !== null && body.lastMessageAt.getTime() <= anchor.getTime()) {
|
|
5943
|
+
return stopped("G8", `La charge utile annonce un dernier message (${body.lastMessageAt.toISOString()}) ant\xE9rieur ou \xE9gal \xE0 la derni\xE8re r\xE9ponse : relivraison.`);
|
|
5944
|
+
}
|
|
5945
|
+
if (body.isClosed === null && body.lastMessageFromAgent === null && body.lastMessagePublic === null && body.lastMessageAt === null) {
|
|
5946
|
+
return muted("G8", "Aucun champ exploitable dans la charge utile \u2014 la lecture fra\xEEche tranchera.");
|
|
5947
|
+
}
|
|
5948
|
+
return passed("G8", "Rien dans la charge utile ne permet d\u2019\xE9carter le ticket.");
|
|
5949
|
+
}
|
|
5950
|
+
function passed(gate, detail) {
|
|
5951
|
+
return { gate, label: LABELS[gate], status: "passed", detail };
|
|
5952
|
+
}
|
|
5953
|
+
function stopped(gate, detail) {
|
|
5954
|
+
return { gate, label: LABELS[gate], status: "stopped", detail };
|
|
5955
|
+
}
|
|
5956
|
+
function muted(gate, detail) {
|
|
5957
|
+
return { gate, label: LABELS[gate], status: "muted", detail };
|
|
5958
|
+
}
|
|
5959
|
+
function newTrace(gates) {
|
|
5960
|
+
const results = [];
|
|
5961
|
+
let stop2 = null;
|
|
5962
|
+
return {
|
|
5963
|
+
category: null,
|
|
5964
|
+
/** Records `result` unless the run already stopped; returns the category it resolved, if any. */
|
|
5965
|
+
record(result) {
|
|
5966
|
+
if (stop2) return null;
|
|
5967
|
+
results.push({ gate: result.gate, label: result.label, status: result.status, detail: result.detail });
|
|
5968
|
+
if (result.status === "stopped") stop2 = result;
|
|
5969
|
+
return result.category ?? null;
|
|
5970
|
+
},
|
|
5971
|
+
done() {
|
|
5972
|
+
const evaluated = new Set(results.map((result) => result.gate));
|
|
5973
|
+
for (const gate of gates) {
|
|
5974
|
+
if (!evaluated.has(gate)) {
|
|
5975
|
+
results.push({ gate, label: LABELS[gate], status: "skipped", detail: "Non \xE9valu\xE9 : un gate pr\xE9c\xE9dent a arr\xEAt\xE9 le traitement." });
|
|
5976
|
+
}
|
|
5977
|
+
}
|
|
5978
|
+
return { results, stop: stop2, category: stop2 ? null : this.category };
|
|
5979
|
+
}
|
|
5980
|
+
};
|
|
5981
|
+
}
|
|
5982
|
+
|
|
5983
|
+
// src/functions/webhook-body.ts
|
|
5984
|
+
var EMPTY_BODY = {
|
|
5985
|
+
ticketId: null,
|
|
5986
|
+
channel: null,
|
|
5987
|
+
lastMessageAt: null,
|
|
5988
|
+
isClosed: null,
|
|
5989
|
+
tags: null,
|
|
5990
|
+
lastMessageFromAgent: null,
|
|
5991
|
+
lastMessagePublic: null
|
|
5992
|
+
};
|
|
5993
|
+
var NUMERIC = /^\d+$/;
|
|
5994
|
+
var TRUE_TOKENS = /* @__PURE__ */ new Set(["true", "1", "yes", "on"]);
|
|
5995
|
+
var FALSE_TOKENS = /* @__PURE__ */ new Set(["false", "0", "no", "off"]);
|
|
5996
|
+
function parseFollowupWebhookBody(raw) {
|
|
5997
|
+
const body = toRecord(raw);
|
|
5998
|
+
if (!body) return { ...EMPTY_BODY };
|
|
5999
|
+
return {
|
|
6000
|
+
ticketId: parseTicketId(body.ticket_id),
|
|
6001
|
+
channel: parseText(body.channel),
|
|
6002
|
+
lastMessageAt: parseDate(body.last_message_datetime),
|
|
6003
|
+
isClosed: parseClosed(body.status),
|
|
6004
|
+
tags: parseTags(body.tags),
|
|
6005
|
+
lastMessageFromAgent: parseLaxBoolean(body.last_message_from_agent),
|
|
6006
|
+
lastMessagePublic: parseLaxBoolean(body.last_message_public)
|
|
6007
|
+
};
|
|
6008
|
+
}
|
|
6009
|
+
function toRecord(raw) {
|
|
6010
|
+
if (isPlainObject(raw)) return raw;
|
|
6011
|
+
if (typeof raw !== "string" || raw.trim() === "") return null;
|
|
6012
|
+
const asJson = tryJson(raw);
|
|
6013
|
+
if (isPlainObject(asJson)) return asJson;
|
|
6014
|
+
return parseFormEncoded(raw);
|
|
6015
|
+
}
|
|
6016
|
+
function parseFormEncoded(raw) {
|
|
6017
|
+
if (!raw.includes("=")) return null;
|
|
6018
|
+
const params = new URLSearchParams(raw);
|
|
6019
|
+
const entries = [...params.entries()];
|
|
6020
|
+
return entries.length > 0 ? Object.fromEntries(entries) : null;
|
|
6021
|
+
}
|
|
6022
|
+
function tryJson(raw) {
|
|
6023
|
+
try {
|
|
6024
|
+
return JSON.parse(raw);
|
|
6025
|
+
} catch {
|
|
6026
|
+
return void 0;
|
|
6027
|
+
}
|
|
6028
|
+
}
|
|
6029
|
+
function isPlainObject(value) {
|
|
6030
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
6031
|
+
}
|
|
6032
|
+
function parseTicketId(raw) {
|
|
6033
|
+
if (typeof raw === "number") return Number.isSafeInteger(raw) && raw >= 0 ? String(raw) : null;
|
|
6034
|
+
return typeof raw === "string" && NUMERIC.test(raw) ? raw : null;
|
|
6035
|
+
}
|
|
6036
|
+
function parseText(raw) {
|
|
6037
|
+
if (typeof raw !== "string") return null;
|
|
6038
|
+
const trimmed = raw.trim();
|
|
6039
|
+
return trimmed === "" ? null : trimmed;
|
|
6040
|
+
}
|
|
6041
|
+
function parseDate(raw) {
|
|
6042
|
+
if (typeof raw !== "string") return null;
|
|
6043
|
+
const at = new Date(raw.trim());
|
|
6044
|
+
return Number.isNaN(at.getTime()) ? null : at;
|
|
6045
|
+
}
|
|
6046
|
+
function parseClosed(raw) {
|
|
6047
|
+
const text = parseText(raw);
|
|
6048
|
+
if (text === null) return null;
|
|
6049
|
+
if (text.toLowerCase() === "closed") return true;
|
|
6050
|
+
return text.startsWith("{{") ? null : false;
|
|
6051
|
+
}
|
|
6052
|
+
function parseLaxBoolean(raw) {
|
|
6053
|
+
if (typeof raw === "boolean") return raw;
|
|
6054
|
+
if (typeof raw === "number") {
|
|
6055
|
+
if (raw === 1) return true;
|
|
6056
|
+
if (raw === 0) return false;
|
|
6057
|
+
return null;
|
|
6058
|
+
}
|
|
6059
|
+
const text = parseText(raw)?.toLowerCase();
|
|
6060
|
+
if (text === void 0 || text === null) return null;
|
|
6061
|
+
if (TRUE_TOKENS.has(text)) return true;
|
|
6062
|
+
if (FALSE_TOKENS.has(text)) return false;
|
|
6063
|
+
return null;
|
|
6064
|
+
}
|
|
6065
|
+
function parseTags(raw) {
|
|
6066
|
+
const list = Array.isArray(raw) ? raw : arrayFromJson(raw);
|
|
6067
|
+
if (list === null || list.length === 0) return null;
|
|
6068
|
+
const names = [];
|
|
6069
|
+
for (const entry of list) {
|
|
6070
|
+
const name = tagNameOf(entry);
|
|
6071
|
+
if (name === null) return null;
|
|
6072
|
+
names.push(name);
|
|
6073
|
+
}
|
|
6074
|
+
return names;
|
|
6075
|
+
}
|
|
6076
|
+
function arrayFromJson(raw) {
|
|
6077
|
+
if (typeof raw !== "string") return null;
|
|
6078
|
+
const parsed = tryJson(raw);
|
|
6079
|
+
return Array.isArray(parsed) ? parsed : null;
|
|
6080
|
+
}
|
|
6081
|
+
function tagNameOf(entry) {
|
|
6082
|
+
if (typeof entry === "string") return parseText(entry);
|
|
6083
|
+
if (isPlainObject(entry)) return parseText(entry.name);
|
|
6084
|
+
return null;
|
|
6085
|
+
}
|
|
6086
|
+
|
|
6087
|
+
// src/functions/gorgias-webhook.ts
|
|
6088
|
+
var FOLLOWUP_RUN_REQUESTED_EVENT = "followup.run.requested";
|
|
6089
|
+
var FOLLOWUP_RUN_KIND = "gorgias-webhook";
|
|
6090
|
+
function buildGorgiasWebhookFunctionDef(config) {
|
|
6091
|
+
return {
|
|
6092
|
+
universalIdentifier: identifierFor(config, "gorgias-webhook"),
|
|
6093
|
+
name: "gorgias-webhook",
|
|
6094
|
+
trigger: { type: "httpRoute", path: "/gorgias/webhook", method: "POST", auth: "apiKey" }
|
|
6095
|
+
};
|
|
6096
|
+
}
|
|
6097
|
+
function buildGorgiasFollowupRunFunctionDef(config) {
|
|
6098
|
+
return {
|
|
6099
|
+
universalIdentifier: identifierFor(config, "gorgias-followup-run"),
|
|
6100
|
+
name: "gorgias-followup-run",
|
|
6101
|
+
trigger: { type: "event", name: FOLLOWUP_RUN_REQUESTED_EVENT }
|
|
6102
|
+
};
|
|
6103
|
+
}
|
|
6104
|
+
function createGorgiasWebhookHandler(config) {
|
|
6105
|
+
return (ctx, payload) => executeFollowupRun(
|
|
6106
|
+
ctx,
|
|
6107
|
+
config,
|
|
6108
|
+
payload?.body,
|
|
6109
|
+
null
|
|
6110
|
+
);
|
|
6111
|
+
}
|
|
6112
|
+
function createGorgiasFollowupRunHandler(config) {
|
|
6113
|
+
return (ctx, payload) => {
|
|
6114
|
+
const event = payload ?? {};
|
|
6115
|
+
return executeFollowupRun(ctx, config, event.body, event.runId ?? null);
|
|
6116
|
+
};
|
|
6117
|
+
}
|
|
6118
|
+
async function executeFollowupRun(ctx, config, rawBody, existingRunId) {
|
|
6119
|
+
const run = { id: existingRunId };
|
|
6120
|
+
try {
|
|
6121
|
+
const result = await runFollowupPass(ctx, config, rawBody, run);
|
|
6122
|
+
if (run.id) await ctx.api.runs.succeed(run.id, { ...result });
|
|
6123
|
+
} catch (err) {
|
|
6124
|
+
if (run.id) await ctx.api.runs.fail(run.id, { message: err instanceof Error ? err.message : String(err) });
|
|
6125
|
+
throw err;
|
|
6126
|
+
}
|
|
6127
|
+
}
|
|
6128
|
+
async function runFollowupPass(ctx, config, rawBody, run) {
|
|
6129
|
+
const body = parseFollowupWebhookBody(rawBody);
|
|
6130
|
+
const ticketIdGate = evaluateTicketIdGate(body.ticketId);
|
|
6131
|
+
if (!body.ticketId) return stop(ctx, null, ticketIdGate.gate, ticketIdGate.detail);
|
|
6132
|
+
const ticketId = body.ticketId;
|
|
6133
|
+
const settings = await ctx.api.settings.get();
|
|
6134
|
+
const issues = validateSettings(settings);
|
|
6135
|
+
if (issues.length > 0) {
|
|
6136
|
+
return stop(ctx, ticketId, "settings", `r\xE9glages invalides : ${issues.map((issue) => issue.message).join(" ")}`);
|
|
6137
|
+
}
|
|
6138
|
+
const scope = evaluateScopeGate(settings);
|
|
6139
|
+
if (scope.status === "stopped") return stopAt(ctx, ticketId, scope);
|
|
6140
|
+
const { anchor, hasOpenResponse } = await readFollowupAnchor(ctx, ticketId);
|
|
6141
|
+
const categories = await listCategories(ctx.api);
|
|
6142
|
+
const preGates = evaluatePayloadGates({ settings, body, categories, anchor });
|
|
6143
|
+
if (preGates.stop) return stopAt(ctx, ticketId, preGates.stop, "pr\xE9-gate");
|
|
6144
|
+
const ref = { id: ticketId, channel: "gorgias" };
|
|
6145
|
+
const ticket = await ctx.api.integrations.run("gorgias", "getTicketWithContext", { ticketId });
|
|
6146
|
+
const raw = ticket?.ticket ?? {};
|
|
6147
|
+
const conversation = toConversation(ref, raw, ticket?.context ?? { messages: [], customerContext: null });
|
|
6148
|
+
const gates = evaluateTicketGates({ settings, tags: ticketTagNames(raw), categories, conversation, anchor });
|
|
6149
|
+
if (gates.stop || !gates.category) {
|
|
6150
|
+
return stopAt(ctx, ticketId, gates.stop ?? unresolvedCategory());
|
|
6151
|
+
}
|
|
6152
|
+
const category = gates.category;
|
|
6153
|
+
if (hasOpenResponse) return stop(ctx, ticketId, "G9", "une r\xE9ponse est d\xE9j\xE0 ouverte sur ce ticket");
|
|
6154
|
+
run.id ??= (await ctx.api.runs.start({
|
|
6155
|
+
kind: FOLLOWUP_RUN_KIND,
|
|
6156
|
+
message: `Message suivant \u2014 ticket ${ticketId}`,
|
|
6157
|
+
metadata: { ticketId, categoryTag: category.tagName, channel: body.channel }
|
|
6158
|
+
})).id;
|
|
6159
|
+
const created = await openFollowupResponse(ctx, { ticketId, category, conversation, settings, runId: run.id });
|
|
6160
|
+
if (!created) return stop(ctx, ticketId, "G9", "une autre ex\xE9cution a ouvert la r\xE9ponse en premier");
|
|
6161
|
+
await respondToPendingResponse(ctx, config, created.id);
|
|
6162
|
+
return { ticketId, stoppedAt: null, reason: `r\xE9ponse de suite g\xE9n\xE9r\xE9e (cat\xE9gorie \xAB ${category.name} \xBB)` };
|
|
6163
|
+
}
|
|
6164
|
+
async function readFollowupAnchor(ctx, ticketId) {
|
|
6165
|
+
const page = await ctx.api.list("generated-response", { filter: { ticketId }, limit: ANCHOR_LOOKUP_LIMIT });
|
|
6166
|
+
let anchor = null;
|
|
6167
|
+
let hasOpenResponse = false;
|
|
6168
|
+
for (const item of page.items) {
|
|
6169
|
+
const data = item.data;
|
|
6170
|
+
if (data.openTicketKey === ticketId) hasOpenResponse = true;
|
|
6171
|
+
for (const raw of [data.generatedLastMessageAt, data.sentAt]) {
|
|
6172
|
+
const at = toDate2(raw);
|
|
6173
|
+
if (at && (!anchor || at > anchor)) anchor = at;
|
|
6174
|
+
}
|
|
6175
|
+
}
|
|
6176
|
+
return { anchor, hasOpenResponse };
|
|
6177
|
+
}
|
|
6178
|
+
var ANCHOR_LOOKUP_LIMIT = 100;
|
|
6179
|
+
function toDate2(raw) {
|
|
6180
|
+
if (raw instanceof Date) return Number.isNaN(raw.getTime()) ? null : raw;
|
|
6181
|
+
if (typeof raw !== "string") return null;
|
|
6182
|
+
const at = new Date(raw);
|
|
6183
|
+
return Number.isNaN(at.getTime()) ? null : at;
|
|
6184
|
+
}
|
|
6185
|
+
function ticketTagNames(raw) {
|
|
6186
|
+
const tags = raw.tags;
|
|
6187
|
+
if (!Array.isArray(tags)) return [];
|
|
6188
|
+
const names = [];
|
|
6189
|
+
for (const entry of tags) {
|
|
6190
|
+
if (typeof entry === "string" && entry !== "") {
|
|
6191
|
+
names.push(entry);
|
|
6192
|
+
continue;
|
|
6193
|
+
}
|
|
6194
|
+
if (typeof entry === "object" && entry !== null) {
|
|
6195
|
+
const name = entry.name;
|
|
6196
|
+
if (typeof name === "string" && name !== "") names.push(name);
|
|
6197
|
+
}
|
|
6198
|
+
}
|
|
6199
|
+
return names;
|
|
6200
|
+
}
|
|
6201
|
+
async function openFollowupResponse(ctx, input) {
|
|
6202
|
+
const { ticketId, category, conversation, settings, runId } = input;
|
|
6203
|
+
const decision = await ctx.api.create("triage-decision", {
|
|
6204
|
+
ticketId,
|
|
6205
|
+
// Not resolved: `getTicketUrlBase` is a SECOND Gorgias call and this
|
|
6206
|
+
// function runs once per message of the whole account. The field is
|
|
6207
|
+
// documented nullable for exactly this kind of row.
|
|
6208
|
+
ticketUrl: null,
|
|
6209
|
+
decidedAt: /* @__PURE__ */ new Date(),
|
|
6210
|
+
categoryId: category.id,
|
|
6211
|
+
tag: category.tagName,
|
|
6212
|
+
// §7.2 — NULL, and it is the honest value: no classifier ran on this pass
|
|
6213
|
+
// (D3 — the category is inherited from the tag the first pass applied), so
|
|
6214
|
+
// there is no confidence to state. The column was widened to allow it
|
|
6215
|
+
// (`records/triage-decision.ts`); a reader that needs a value still derives
|
|
6216
|
+
// `'low'` (`process-response.ts`'s `classificationFromDecision`).
|
|
6217
|
+
//
|
|
6218
|
+
// That derived `'low'` no longer holds the reply back: a follow-up pass is
|
|
6219
|
+
// governed by the evaluation of its own draft, not by a triage confidence
|
|
6220
|
+
// that does not exist — see `applyFollowupSendPolicy` in
|
|
6221
|
+
// `process-response.ts` for the decision and what it replaces.
|
|
6222
|
+
confidence: null,
|
|
6223
|
+
reasoning: `Message suivant \u2014 cat\xE9gorie r\xE9solue par le tag ${category.tagName}`,
|
|
6224
|
+
// The customer has just written, so the thread is by definition not over;
|
|
6225
|
+
// and the escalation decision belongs to the first pass, which this one
|
|
6226
|
+
// deliberately does not replay (D5).
|
|
6227
|
+
conversationOver: false,
|
|
6228
|
+
escalated: false,
|
|
6229
|
+
status: "ok",
|
|
6230
|
+
runId,
|
|
6231
|
+
subjectRenamed: false,
|
|
6232
|
+
origin: "followup"
|
|
6233
|
+
});
|
|
6234
|
+
const agent = await resolveDraftAgent(ctx.api, category.agentId);
|
|
6235
|
+
const generatedAt = /* @__PURE__ */ new Date();
|
|
6236
|
+
try {
|
|
6237
|
+
return await ctx.api.create("generated-response", {
|
|
6238
|
+
ticketId,
|
|
6239
|
+
openTicketKey: openTicketKeyFor("pending", ticketId),
|
|
6240
|
+
status: "pending",
|
|
6241
|
+
triageDecisionId: decision.id,
|
|
6242
|
+
categoryId: category.id,
|
|
6243
|
+
agentId: agent?.id ?? null,
|
|
6244
|
+
channel: conversation.sourceChannel === "whatsapp" ? "whatsapp" : "email",
|
|
6245
|
+
generatedAt,
|
|
6246
|
+
expiresAt: new Date(generatedAt.getTime() + settings.responseTtlMinutes * 6e4),
|
|
6247
|
+
sources: [],
|
|
6248
|
+
tracedInput: [],
|
|
6249
|
+
guardrailHits: [],
|
|
6250
|
+
servedTo: [],
|
|
6251
|
+
servedCount: 0,
|
|
6252
|
+
followupRequired: false,
|
|
6253
|
+
origin: "followup"
|
|
6254
|
+
});
|
|
6255
|
+
} catch (err) {
|
|
6256
|
+
if (err instanceof appKit.AppApiError && err.status === 409) return null;
|
|
6257
|
+
throw err;
|
|
6258
|
+
}
|
|
6259
|
+
}
|
|
6260
|
+
function unresolvedCategory() {
|
|
6261
|
+
return {
|
|
6262
|
+
gate: "G7",
|
|
6263
|
+
label: "Cat\xE9gorie r\xE9solue et opt\xE9e",
|
|
6264
|
+
status: "stopped",
|
|
6265
|
+
detail: "Aucune cat\xE9gorie r\xE9solue."
|
|
6266
|
+
};
|
|
6267
|
+
}
|
|
6268
|
+
function stopAt(ctx, ticketId, result, kind = "gate") {
|
|
6269
|
+
return stop(ctx, ticketId, `${result.gate}${kind === "gate" ? "" : ` (${kind})`}`, result.detail);
|
|
6270
|
+
}
|
|
6271
|
+
function stop(ctx, ticketId, gate, reason) {
|
|
6272
|
+
ctx.logger.info(`gorgias-webhook: stop at ${gate} for ticket ${ticketId ?? "?"} \u2014 ${reason}`);
|
|
6273
|
+
return { ticketId, stoppedAt: gate, reason };
|
|
6274
|
+
}
|
|
6275
|
+
|
|
6276
|
+
// src/functions/setup-gorgias-webhook.ts
|
|
6277
|
+
var GORGIAS_CALLBACK_APP_KEY_VARIABLE = "GORGIAS_CALLBACK_APP_KEY";
|
|
6278
|
+
var APP_API_KEY_PREFIX = "wopilo_app_";
|
|
6279
|
+
var FOLLOWUP_WEBHOOK_FORM = {
|
|
6280
|
+
ticket_id: "{{ticket.id}}",
|
|
6281
|
+
channel: "{{ticket.channel}}",
|
|
6282
|
+
last_message_datetime: "{{ticket.last_message_datetime}}",
|
|
6283
|
+
status: "{{ticket.status}}",
|
|
6284
|
+
tags: "{{ticket.tags}}",
|
|
6285
|
+
last_message_from_agent: "{{ticket.messages[-1].from_agent}}",
|
|
6286
|
+
last_message_public: "{{ticket.messages[-1].public}}"
|
|
6287
|
+
};
|
|
6288
|
+
var FOLLOWUP_WEBHOOK_TRIGGERS = { "ticket-message-created": true };
|
|
6289
|
+
function followupIntegrationName(slug) {
|
|
6290
|
+
return `Wopilo \u2014 R\xE9ponses aux messages suivants (${slug})`;
|
|
6291
|
+
}
|
|
6292
|
+
function buildSetupGorgiasWebhookFunctionDef(config) {
|
|
6293
|
+
return {
|
|
6294
|
+
universalIdentifier: identifierFor(config, "setup-gorgias-webhook"),
|
|
6295
|
+
name: "setup-gorgias-webhook",
|
|
6296
|
+
trigger: { type: "uiInvoke", minRole: "ADMIN", timeoutMs: 2e4 }
|
|
6297
|
+
};
|
|
6298
|
+
}
|
|
6299
|
+
function createSetupGorgiasWebhookHandler(config) {
|
|
6300
|
+
return (ctx) => setupGorgiasWebhookHandler(ctx, config);
|
|
6301
|
+
}
|
|
6302
|
+
async function setupGorgiasWebhookHandler(ctx, config) {
|
|
6303
|
+
const key = readCallbackKey(ctx);
|
|
6304
|
+
const name = followupIntegrationName(config.slug);
|
|
6305
|
+
const url = `${publicOrigin(ctx)}/api/s/${config.slug}/gorgias/webhook`;
|
|
6306
|
+
const result = await ctx.api.integrations.run("gorgias", "upsertHttpIntegration", {
|
|
6307
|
+
name,
|
|
6308
|
+
description: "Rappelle Wopilo \xE0 chaque nouveau message de ticket, pour r\xE9pondre aux messages suivants.",
|
|
6309
|
+
url,
|
|
6310
|
+
method: "POST",
|
|
6311
|
+
headers: { Authorization: `Bearer ${key}` },
|
|
6312
|
+
form: FOLLOWUP_WEBHOOK_FORM,
|
|
6313
|
+
triggers: FOLLOWUP_WEBHOOK_TRIGGERS
|
|
6314
|
+
});
|
|
6315
|
+
ctx.logger.info(`setup-gorgias-webhook: int\xE9gration \xAB ${name} \xBB pos\xE9e sur ${url}`);
|
|
6316
|
+
return {
|
|
6317
|
+
integrationId: String(result?.id ?? ""),
|
|
6318
|
+
created: result?.created === true,
|
|
6319
|
+
name,
|
|
6320
|
+
url
|
|
6321
|
+
};
|
|
6322
|
+
}
|
|
6323
|
+
function readCallbackKey(ctx) {
|
|
6324
|
+
const raw = ctx.variables[GORGIAS_CALLBACK_APP_KEY_VARIABLE];
|
|
6325
|
+
const key = typeof raw === "string" ? raw.trim() : "";
|
|
6326
|
+
if (!key) {
|
|
6327
|
+
throw new ctx.NonRetriableError(
|
|
6328
|
+
`La variable serveur ${GORGIAS_CALLBACK_APP_KEY_VARIABLE} n'est pas renseign\xE9e : Gorgias n'aurait aucun moyen de s'authentifier aupr\xE8s de cette app.`
|
|
6329
|
+
);
|
|
6330
|
+
}
|
|
6331
|
+
if (!key.startsWith(APP_API_KEY_PREFIX)) {
|
|
6332
|
+
throw new ctx.NonRetriableError(
|
|
6333
|
+
`La variable serveur ${GORGIAS_CALLBACK_APP_KEY_VARIABLE} ne contient pas une cl\xE9 d'application : elle doit commencer par \xAB ${APP_API_KEY_PREFIX} \xBB.`
|
|
6334
|
+
);
|
|
6335
|
+
}
|
|
6336
|
+
return key;
|
|
6337
|
+
}
|
|
6338
|
+
function publicOrigin(ctx) {
|
|
6339
|
+
const base = process.env.PUBLIC_BASE_URL?.trim().replace(/\/+$/, "");
|
|
6340
|
+
if (!base) {
|
|
6341
|
+
throw new ctx.NonRetriableError(
|
|
6342
|
+
"La variable d'instance PUBLIC_BASE_URL n'est pas d\xE9finie : impossible de construire une URL de rappel que Gorgias puisse joindre."
|
|
6343
|
+
);
|
|
6344
|
+
}
|
|
6345
|
+
return base;
|
|
6346
|
+
}
|
|
6347
|
+
function buildTestGorgiasWebhookFunctionDef(config) {
|
|
6348
|
+
return {
|
|
6349
|
+
universalIdentifier: identifierFor(config, "test-gorgias-webhook"),
|
|
6350
|
+
name: "test-gorgias-webhook",
|
|
6351
|
+
trigger: { type: "uiInvoke", minRole: "ADMIN", timeoutMs: 2e4 },
|
|
6352
|
+
input: [
|
|
6353
|
+
{
|
|
6354
|
+
universalIdentifier: TEST_GORGIAS_WEBHOOK_INPUT_TICKET_ID_UID,
|
|
6355
|
+
name: "ticketId",
|
|
6356
|
+
type: appKit.FieldType.TEXT,
|
|
6357
|
+
label: "Ticket id",
|
|
6358
|
+
description: "Identifiant Gorgias du ticket \xE0 tester.",
|
|
6359
|
+
isNullable: true
|
|
6360
|
+
},
|
|
6361
|
+
{
|
|
6362
|
+
universalIdentifier: TEST_GORGIAS_WEBHOOK_INPUT_MODE_UID,
|
|
6363
|
+
name: "mode",
|
|
6364
|
+
type: appKit.FieldType.TEXT,
|
|
6365
|
+
label: "Mode",
|
|
6366
|
+
description: "'diagnostic' (d\xE9faut) \xE9value les gates sans aucun effet de bord ; 'run' d\xE9clenche le vrai traitement, envoi compris si la cat\xE9gorie est en auto.",
|
|
6367
|
+
isNullable: true
|
|
6368
|
+
}
|
|
6369
|
+
]
|
|
6370
|
+
};
|
|
6371
|
+
}
|
|
6372
|
+
function createTestGorgiasWebhookHandler(_config) {
|
|
6373
|
+
return (ctx, input) => testGorgiasWebhookHandler(ctx, input ?? {});
|
|
6374
|
+
}
|
|
6375
|
+
var NUMERIC2 = /^\d+$/;
|
|
6376
|
+
async function testGorgiasWebhookHandler(ctx, input) {
|
|
6377
|
+
const ticketId = typeof input.ticketId === "string" && NUMERIC2.test(input.ticketId.trim()) ? input.ticketId.trim() : null;
|
|
6378
|
+
const mode = input.mode === "run" ? "run" : "diagnostic";
|
|
6379
|
+
if (mode === "run") {
|
|
6380
|
+
if (!ticketId) throw new ctx.NonRetriableError("L'identifiant du ticket doit \xEAtre une suite de chiffres.");
|
|
6381
|
+
return triggerRealRun(ctx, ticketId);
|
|
6382
|
+
}
|
|
6383
|
+
return diagnose(ctx, ticketId);
|
|
6384
|
+
}
|
|
6385
|
+
async function diagnose(ctx, ticketId) {
|
|
6386
|
+
const gates = [];
|
|
6387
|
+
const ticketIdGate = evaluateTicketIdGate(ticketId);
|
|
6388
|
+
gates.push(ticketIdGate);
|
|
6389
|
+
if (!ticketId) return finish3(gates, "");
|
|
6390
|
+
const settings = await ctx.api.settings.get();
|
|
6391
|
+
const issues = validateSettings(settings);
|
|
6392
|
+
if (issues.length > 0) {
|
|
6393
|
+
throw new ctx.NonRetriableError(`R\xE9glages invalides : ${issues.map((issue) => issue.message).join(" ")}`);
|
|
6394
|
+
}
|
|
6395
|
+
const scope = evaluateScopeGate(settings);
|
|
6396
|
+
gates.push(scope);
|
|
6397
|
+
if (scope.status === "stopped") return finish3(gates, ticketId);
|
|
6398
|
+
const { anchor } = await readFollowupAnchor(ctx, ticketId);
|
|
6399
|
+
const categories = await listCategories(ctx.api);
|
|
6400
|
+
const ref = { id: ticketId, channel: "gorgias" };
|
|
6401
|
+
const ticket = await ctx.api.integrations.run("gorgias", "getTicketWithContext", { ticketId });
|
|
6402
|
+
const raw = ticket?.ticket ?? {};
|
|
6403
|
+
const conversation = toConversation(ref, raw, ticket?.context ?? { messages: [], customerContext: null });
|
|
6404
|
+
const trace = evaluateTicketGates({ settings, tags: ticketTagNames(raw), categories, conversation, anchor });
|
|
6405
|
+
gates.push(...trace.results);
|
|
6406
|
+
return finish3(gates, ticketId);
|
|
6407
|
+
}
|
|
6408
|
+
function finish3(gates, ticketId) {
|
|
6409
|
+
const evaluated = new Set(gates.map((gate) => gate.gate));
|
|
6410
|
+
const missing = ALL_FOLLOWUP_GATES.filter((gate) => !evaluated.has(gate));
|
|
6411
|
+
const full = [...gates, ...skippedFollowupGates(missing)];
|
|
6412
|
+
return {
|
|
6413
|
+
mode: "diagnostic",
|
|
6414
|
+
ticketId,
|
|
6415
|
+
stoppedAt: full.find((gate) => gate.status === "stopped")?.gate ?? null,
|
|
6416
|
+
gates: full
|
|
6417
|
+
};
|
|
6418
|
+
}
|
|
6419
|
+
async function triggerRealRun(ctx, ticketId) {
|
|
6420
|
+
const run = await ctx.api.runs.start({
|
|
6421
|
+
kind: FOLLOWUP_RUN_KIND,
|
|
6422
|
+
message: `Test webhook \u2014 ticket ${ticketId}`,
|
|
6423
|
+
metadata: { ticketId, triggeredFrom: "test-gorgias-webhook" }
|
|
6424
|
+
});
|
|
6425
|
+
try {
|
|
6426
|
+
await ctx.api.events.send(FOLLOWUP_RUN_REQUESTED_EVENT, {
|
|
6427
|
+
_key: run.id,
|
|
6428
|
+
runId: run.id,
|
|
6429
|
+
body: { ticket_id: ticketId }
|
|
6430
|
+
});
|
|
6431
|
+
} catch (err) {
|
|
6432
|
+
await ctx.api.runs.fail(run.id, { message: err instanceof Error ? err.message : String(err) });
|
|
6433
|
+
throw err;
|
|
6434
|
+
}
|
|
6435
|
+
return { mode: "run", ticketId, runId: run.id };
|
|
6436
|
+
}
|
|
6437
|
+
|
|
5772
6438
|
// src/pages/manifest.ts
|
|
5773
6439
|
function pageIdentifierFor(config, key) {
|
|
5774
6440
|
const id = config.identifiers[key];
|
|
@@ -5792,12 +6458,28 @@ var SUPPORT_KIT_GORGIAS_SCOPES = [
|
|
|
5792
6458
|
"read_tickets",
|
|
5793
6459
|
"read_views",
|
|
5794
6460
|
"write_tags",
|
|
5795
|
-
"write_tickets"
|
|
6461
|
+
"write_tickets",
|
|
6462
|
+
// What `upsertHttpIntegration` demands (its own `scopes`, in
|
|
6463
|
+
// `packages/gorgias-client/src/sidebar-widget.ts`). The name says "widgets"
|
|
6464
|
+
// because that action's sibling posts one; this kit posts no widget, only
|
|
6465
|
+
// the HTTP integration the same scope governs. Requesting it makes the
|
|
6466
|
+
// consent modal state, honestly, that the app may write an integration on
|
|
6467
|
+
// the account.
|
|
6468
|
+
"write_widgets"
|
|
6469
|
+
];
|
|
6470
|
+
var SUPPORT_KIT_SERVER_VARIABLES = [
|
|
6471
|
+
{
|
|
6472
|
+
universalIdentifier: "4dd02108-ba4c-441e-9ea3-ec86f8bf3a1f",
|
|
6473
|
+
name: GORGIAS_CALLBACK_APP_KEY_VARIABLE,
|
|
6474
|
+
description: "Cl\xE9 d'application (wopilo_app_\u2026) que Gorgias pr\xE9sente en rappelant la route des messages suivants. Saisie par app ; elle porte le r\xF4le manifeste complet de l'app (voir docs/app-platform/gorgias-callback-authentication.md \xA75).",
|
|
6475
|
+
type: "STRING",
|
|
6476
|
+
isRequired: false
|
|
6477
|
+
}
|
|
5796
6478
|
];
|
|
5797
6479
|
var SUPPORT_KIT_INTEGRATIONS = [
|
|
5798
6480
|
{ provider: "gorgias", scopes: [...SUPPORT_KIT_GORGIAS_SCOPES] }
|
|
5799
6481
|
];
|
|
5800
|
-
var SUPPORT_KIT_EMITS = [TRIAGE_RUN_REQUESTED_EVENT];
|
|
6482
|
+
var SUPPORT_KIT_EMITS = [TRIAGE_RUN_REQUESTED_EVENT, FOLLOWUP_RUN_REQUESTED_EVENT];
|
|
5801
6483
|
var FUNCTION_ASSEMBLY = [
|
|
5802
6484
|
{ key: "triage-tick", build: buildTriageTickFunctionDef, createHandler: createTriageTickHandler },
|
|
5803
6485
|
{ key: "sweep", build: buildSweepFunctionDef, createHandler: () => createSweepHandler() },
|
|
@@ -5892,6 +6574,27 @@ var FUNCTION_ASSEMBLY = [
|
|
|
5892
6574
|
key: "ext-response-comparison",
|
|
5893
6575
|
build: buildExtResponseComparisonFunctionDef,
|
|
5894
6576
|
createHandler: () => createExtResponseComparisonHandler()
|
|
6577
|
+
},
|
|
6578
|
+
// spec-gorgias-followup-webhook-v1 §5 — the push half.
|
|
6579
|
+
{
|
|
6580
|
+
key: "gorgias-webhook",
|
|
6581
|
+
build: buildGorgiasWebhookFunctionDef,
|
|
6582
|
+
createHandler: createGorgiasWebhookHandler
|
|
6583
|
+
},
|
|
6584
|
+
{
|
|
6585
|
+
key: "gorgias-followup-run",
|
|
6586
|
+
build: buildGorgiasFollowupRunFunctionDef,
|
|
6587
|
+
createHandler: createGorgiasFollowupRunHandler
|
|
6588
|
+
},
|
|
6589
|
+
{
|
|
6590
|
+
key: "setup-gorgias-webhook",
|
|
6591
|
+
build: buildSetupGorgiasWebhookFunctionDef,
|
|
6592
|
+
createHandler: createSetupGorgiasWebhookHandler
|
|
6593
|
+
},
|
|
6594
|
+
{
|
|
6595
|
+
key: "test-gorgias-webhook",
|
|
6596
|
+
build: buildTestGorgiasWebhookFunctionDef,
|
|
6597
|
+
createHandler: createTestGorgiasWebhookHandler
|
|
5895
6598
|
}
|
|
5896
6599
|
];
|
|
5897
6600
|
function buildPromptsAllowlist() {
|
|
@@ -6004,6 +6707,7 @@ function buildSupportPipeline(config) {
|
|
|
6004
6707
|
navigation: buildNavigation(config),
|
|
6005
6708
|
settingsPage: buildSettingsPage(config),
|
|
6006
6709
|
integrations: SUPPORT_KIT_INTEGRATIONS,
|
|
6710
|
+
serverVariables: SUPPORT_KIT_SERVER_VARIABLES,
|
|
6007
6711
|
emits: SUPPORT_KIT_EMITS,
|
|
6008
6712
|
defaultRole: "NO_ACCESS",
|
|
6009
6713
|
handlers,
|
|
@@ -6017,8 +6721,10 @@ exports.AGENT_STATUSES = AGENT_STATUSES;
|
|
|
6017
6721
|
exports.AGENT_TOOLS = AGENT_TOOLS;
|
|
6018
6722
|
exports.ATTACHMENT_MARKER_ONLY = ATTACHMENT_MARKER_ONLY;
|
|
6019
6723
|
exports.CANDIDATE_MIN_LENGTH = CANDIDATE_MIN_LENGTH;
|
|
6724
|
+
exports.DECISION_ORIGINS = DECISION_ORIGINS;
|
|
6020
6725
|
exports.DEFAULT_CHANNEL_PROMPT_EMAIL = DEFAULT_CHANNEL_PROMPT_EMAIL;
|
|
6021
6726
|
exports.DEFAULT_CHANNEL_PROMPT_WHATSAPP = DEFAULT_CHANNEL_PROMPT_WHATSAPP;
|
|
6727
|
+
exports.DEFAULT_DECISION_ORIGIN = DEFAULT_DECISION_ORIGIN;
|
|
6022
6728
|
exports.DEFAULT_LLM_PROVIDER = DEFAULT_LLM_PROVIDER;
|
|
6023
6729
|
exports.DEFAULT_PROFILE_KEY = DEFAULT_PROFILE_KEY;
|
|
6024
6730
|
exports.DEFAULT_WHATSAPP_MODE = DEFAULT_WHATSAPP_MODE;
|
|
@@ -6027,6 +6733,7 @@ exports.GENERATED_RESPONSE_STATUSES = GENERATED_RESPONSE_STATUSES;
|
|
|
6027
6733
|
exports.InvalidStatusTransitionError = InvalidStatusTransitionError;
|
|
6028
6734
|
exports.MissingPromptError = MissingPromptError;
|
|
6029
6735
|
exports.NODE_NAMES = NODE_NAMES;
|
|
6736
|
+
exports.ORIGIN_DESCRIPTION = ORIGIN_DESCRIPTION;
|
|
6030
6737
|
exports.OUTCOMES = OUTCOMES;
|
|
6031
6738
|
exports.PROMPT_SLOTS = PROMPT_SLOTS;
|
|
6032
6739
|
exports.REASONING_MAX_LEN = REASONING_MAX_LEN;
|
|
@@ -6059,6 +6766,8 @@ exports.initialState = initialState;
|
|
|
6059
6766
|
exports.isAutoSendEligible = isAutoSendEligible;
|
|
6060
6767
|
exports.isAutomatedSenderEmail = isAutomatedSenderEmail;
|
|
6061
6768
|
exports.isAutomatedSenderTicket = isAutomatedSenderTicket;
|
|
6769
|
+
exports.isCustomerTurnWithWords = isCustomerTurnWithWords;
|
|
6770
|
+
exports.isDecisionOrigin = isDecisionOrigin;
|
|
6062
6771
|
exports.isEvaluationVerdict = isEvaluationVerdict;
|
|
6063
6772
|
exports.isGeneratedResponseStatus = isGeneratedResponseStatus;
|
|
6064
6773
|
exports.isJudgemeConversation = isJudgemeConversation;
|
|
@@ -6084,6 +6793,7 @@ exports.runTicket = runTicket;
|
|
|
6084
6793
|
exports.settingsToProfile = settingsToProfile;
|
|
6085
6794
|
exports.stopOptOut = stopOptOut;
|
|
6086
6795
|
exports.targetRefFor = targetRefFor;
|
|
6796
|
+
exports.toDecisionOrigin = toDecisionOrigin;
|
|
6087
6797
|
exports.validateSettings = validateSettings;
|
|
6088
6798
|
exports.verifyReply = verifyReply;
|
|
6089
6799
|
exports.whatsappModeFromLegacyBoolean = whatsappModeFromLegacyBoolean;
|