@apotech-os/support-kit 7.0.1 → 8.0.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.
- package/README.md +19 -16
- package/dist/{chunk-QCRCRNYE.js → chunk-2UHFKGMI.js} +22 -3
- package/dist/chunk-2UHFKGMI.js.map +1 -0
- package/dist/index.cjs +79 -141
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +81 -143
- package/dist/index.js.map +1 -1
- package/dist/ui/index.cjs +203 -143
- package/dist/ui/index.cjs.map +1 -1
- package/dist/ui/index.js +186 -145
- package/dist/ui/index.js.map +1 -1
- package/package.json +11 -11
- package/dist/chunk-QCRCRNYE.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -3438,7 +3438,7 @@ async function finalizeNonSent(ctx, id, ticketId, toStatus, extra) {
|
|
|
3438
3438
|
throw err;
|
|
3439
3439
|
}
|
|
3440
3440
|
}
|
|
3441
|
-
async function respondToPendingResponse(ctx, config, recordId) {
|
|
3441
|
+
async function respondToPendingResponse(ctx, config, recordId, options = {}) {
|
|
3442
3442
|
const record = await getOptional(ctx, "generated-response", recordId);
|
|
3443
3443
|
if (!record) {
|
|
3444
3444
|
ctx.logger.info(`respond: generated-response ${recordId} no longer exists, skipping`);
|
|
@@ -3473,7 +3473,8 @@ async function respondToPendingResponse(ctx, config, recordId) {
|
|
|
3473
3473
|
settingsToProfile(settings, buildPromptsTable(config, draftPromptRefFor(agent, config), settings.nodes)),
|
|
3474
3474
|
origin
|
|
3475
3475
|
);
|
|
3476
|
-
const
|
|
3476
|
+
const testRun = options.testRun === true;
|
|
3477
|
+
const dryRun = settings.dryRun === true || testRun;
|
|
3477
3478
|
const trace = { sessionId: ticketId, tags: [`app:${config.slug}`] };
|
|
3478
3479
|
const ports = dryRun ? withRecordingWritePorts(buildTicketPorts(ctx, trace), ctx.api) : buildTicketPorts(ctx, trace);
|
|
3479
3480
|
const { clock } = ports;
|
|
@@ -3527,26 +3528,30 @@ async function respondToPendingResponse(ctx, config, recordId) {
|
|
|
3527
3528
|
// sent reply and a held one are read by the same timeline.
|
|
3528
3529
|
tracedInput: toTracedInput(result.draft?.messages ?? []),
|
|
3529
3530
|
verdict: result.verdict ?? null,
|
|
3530
|
-
|
|
3531
|
-
|
|
3531
|
+
// Omitted on a test run — see `RespondOptions.testRun`, consequence THREE.
|
|
3532
|
+
...testRun ? {} : {
|
|
3533
|
+
generatedMessageCount: conversationSnapshot.messageCount,
|
|
3534
|
+
generatedLastMessageAt: conversationSnapshot.lastMessageAt
|
|
3535
|
+
},
|
|
3532
3536
|
...attributionFields(result.draft?.attribution)
|
|
3533
3537
|
};
|
|
3538
|
+
const restingStatus = testRun ? "invalidated" : "ready";
|
|
3534
3539
|
switch (result.outcome) {
|
|
3535
3540
|
case "sent":
|
|
3536
3541
|
if (dryRun) {
|
|
3537
|
-
await finalizeNonSent(ctx, recordId, ticketId,
|
|
3542
|
+
await finalizeNonSent(ctx, recordId, ticketId, restingStatus, draftExtra);
|
|
3538
3543
|
return;
|
|
3539
3544
|
}
|
|
3540
3545
|
return;
|
|
3541
3546
|
case "ready":
|
|
3542
3547
|
case "guardrail_hold":
|
|
3543
|
-
await finalizeNonSent(ctx, recordId, ticketId,
|
|
3548
|
+
await finalizeNonSent(ctx, recordId, ticketId, restingStatus, draftExtra);
|
|
3544
3549
|
return;
|
|
3545
3550
|
case "needs_human":
|
|
3546
|
-
await finalizeNonSent(ctx, recordId, ticketId,
|
|
3551
|
+
await finalizeNonSent(ctx, recordId, ticketId, restingStatus, draftExtra);
|
|
3547
3552
|
return;
|
|
3548
3553
|
case "awaiting_approval": {
|
|
3549
|
-
const persisted = await finalizeNonSent(ctx, recordId, ticketId,
|
|
3554
|
+
const persisted = await finalizeNonSent(ctx, recordId, ticketId, restingStatus, draftExtra);
|
|
3550
3555
|
if (persisted && !dryRun) {
|
|
3551
3556
|
await ctx.api.approvals.request({
|
|
3552
3557
|
key: buildApprovalKey(recordId),
|
|
@@ -5866,11 +5871,11 @@ function skippedFollowupGates(gates) {
|
|
|
5866
5871
|
var FRESH_READ_GATES = ["G5", "G6", "G7", "G8"];
|
|
5867
5872
|
var ALL_FOLLOWUP_GATES = ["G1", "G2", ...FRESH_READ_GATES];
|
|
5868
5873
|
function evaluateTicketGates(input) {
|
|
5869
|
-
const { settings, tags, categories, conversation, anchor } = input;
|
|
5874
|
+
const { settings, tags, categories, conversation, anchor, ignoreCategoryOptIn = false } = input;
|
|
5870
5875
|
const trace = newTrace(FRESH_READ_GATES);
|
|
5871
5876
|
trace.record(scopeTagOnTicket(settings, tags));
|
|
5872
5877
|
trace.record(noHumanTakeover(settings, tags));
|
|
5873
|
-
const match = trace.record(categoryGate(categories, tags));
|
|
5878
|
+
const match = trace.record(categoryGate(categories, tags, ignoreCategoryOptIn));
|
|
5874
5879
|
if (match) trace.category = match;
|
|
5875
5880
|
trace.record(newCustomerMessage(conversation, anchor));
|
|
5876
5881
|
return trace.done();
|
|
@@ -5887,7 +5892,7 @@ function evaluatePayloadGates(input) {
|
|
|
5887
5892
|
} else {
|
|
5888
5893
|
trace.record(scopeTagOnTicket(settings, tags));
|
|
5889
5894
|
trace.record(noHumanTakeover(settings, tags));
|
|
5890
|
-
trace.record(
|
|
5895
|
+
trace.record(anyCategoryMatch(categories, tags));
|
|
5891
5896
|
}
|
|
5892
5897
|
trace.record(payloadNewCustomerMessage(body, anchor));
|
|
5893
5898
|
return trace.done();
|
|
@@ -5900,25 +5905,37 @@ function noHumanTakeover(settings, tags) {
|
|
|
5900
5905
|
const present = humanTakeoverTags(settings).filter((tag) => tags.includes(tag));
|
|
5901
5906
|
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
5907
|
}
|
|
5903
|
-
function categoryGate(categories, tags) {
|
|
5904
|
-
const
|
|
5905
|
-
if (
|
|
5906
|
-
const
|
|
5907
|
-
if (
|
|
5908
|
-
|
|
5909
|
-
}
|
|
5910
|
-
|
|
5911
|
-
|
|
5908
|
+
function categoryGate(categories, tags, ignoreOptIn) {
|
|
5909
|
+
const matches = matchingCategories(categories, tags);
|
|
5910
|
+
if (matches.length === 0) return noMatchingCategory();
|
|
5911
|
+
const eligible = matches.filter((category2) => (ignoreOptIn || category2.followupFastResponseEnabled) && category2.agentId).sort((a, b) => a.order - b.order || a.id.localeCompare(b.id));
|
|
5912
|
+
if (eligible.length === 0) return noEligibleCategory(matches, ignoreOptIn);
|
|
5913
|
+
const category = eligible[0];
|
|
5914
|
+
const detail = matches.length === 1 ? `Cat\xE9gorie \xAB ${category.name} \xBB (tag \xAB ${category.tagName} \xBB).` : `Cat\xE9gorie \xAB ${category.name} \xBB (tag \xAB ${category.tagName} \xBB), retenue parmi ${matches.length} cat\xE9gories correspondantes (${tagList(matches)}).`;
|
|
5915
|
+
return { ...passed("G7", detail), category };
|
|
5916
|
+
}
|
|
5917
|
+
function noEligibleCategory(matches, ignoreOptIn) {
|
|
5918
|
+
if (ignoreOptIn) {
|
|
5919
|
+
return matches.length > 1 ? stopped("G7", `Aucune des ${matches.length} cat\xE9gories correspondantes (${tagList(matches)}) n\u2019a d\u2019agent : personne pour r\xE9diger.`) : stopped("G7", `La cat\xE9gorie \xAB ${matches[0].name} \xBB n\u2019a aucun agent : personne pour r\xE9diger.`);
|
|
5920
|
+
}
|
|
5921
|
+
if (matches.length > 1) {
|
|
5922
|
+
return stopped(
|
|
5923
|
+
"G7",
|
|
5924
|
+
`Aucune des ${matches.length} cat\xE9gories correspondantes (${tagList(matches)}) n\u2019a activ\xE9 les r\xE9ponses aux messages suivants avec un agent pour r\xE9diger.`
|
|
5925
|
+
);
|
|
5912
5926
|
}
|
|
5913
|
-
|
|
5927
|
+
const category = matches[0];
|
|
5928
|
+
return category.followupFastResponseEnabled ? stopped("G7", `La cat\xE9gorie \xAB ${category.name} \xBB n\u2019a aucun agent : personne pour r\xE9diger.`) : stopped("G7", `La cat\xE9gorie \xAB ${category.name} \xBB n\u2019a pas activ\xE9 les r\xE9ponses aux messages suivants.`);
|
|
5914
5929
|
}
|
|
5915
|
-
function
|
|
5930
|
+
function tagList(categories) {
|
|
5931
|
+
return categories.map((category) => category.tagName).join(", ");
|
|
5932
|
+
}
|
|
5933
|
+
function anyCategoryMatch(categories, tags) {
|
|
5916
5934
|
const matches = matchingCategories(categories, tags);
|
|
5917
|
-
|
|
5918
|
-
|
|
5919
|
-
|
|
5920
|
-
|
|
5921
|
-
);
|
|
5935
|
+
return matches.length === 0 ? noMatchingCategory() : passed("G7", `Cat\xE9gorie \xAB ${matches[0].name} \xBB.`);
|
|
5936
|
+
}
|
|
5937
|
+
function noMatchingCategory() {
|
|
5938
|
+
return stopped("G7", "Aucune cat\xE9gorie ne correspond \xE0 un tag du ticket : la d\xE9cision de triage est illisible.");
|
|
5922
5939
|
}
|
|
5923
5940
|
function matchingCategories(categories, tags) {
|
|
5924
5941
|
return categories.filter((category) => tags.includes(category.tagName));
|
|
@@ -6112,20 +6129,22 @@ function createGorgiasWebhookHandler(config) {
|
|
|
6112
6129
|
function createGorgiasFollowupRunHandler(config) {
|
|
6113
6130
|
return (ctx, payload) => {
|
|
6114
6131
|
const event = payload ?? {};
|
|
6115
|
-
return executeFollowupRun(ctx, config, event.body, event.runId ?? null
|
|
6132
|
+
return executeFollowupRun(ctx, config, event.body, event.runId ?? null, {
|
|
6133
|
+
generateOnly: event.generateOnly === true
|
|
6134
|
+
});
|
|
6116
6135
|
};
|
|
6117
6136
|
}
|
|
6118
|
-
async function executeFollowupRun(ctx, config, rawBody, existingRunId) {
|
|
6137
|
+
async function executeFollowupRun(ctx, config, rawBody, existingRunId, options = {}) {
|
|
6119
6138
|
const run = { id: existingRunId };
|
|
6120
6139
|
try {
|
|
6121
|
-
const result = await runFollowupPass(ctx, config, rawBody, run);
|
|
6140
|
+
const result = await runFollowupPass(ctx, config, rawBody, run, options.generateOnly === true);
|
|
6122
6141
|
if (run.id) await ctx.api.runs.succeed(run.id, { ...result });
|
|
6123
6142
|
} catch (err) {
|
|
6124
6143
|
if (run.id) await ctx.api.runs.fail(run.id, { message: err instanceof Error ? err.message : String(err) });
|
|
6125
6144
|
throw err;
|
|
6126
6145
|
}
|
|
6127
6146
|
}
|
|
6128
|
-
async function runFollowupPass(ctx, config, rawBody, run) {
|
|
6147
|
+
async function runFollowupPass(ctx, config, rawBody, run, generateOnly) {
|
|
6129
6148
|
const body = parseFollowupWebhookBody(rawBody);
|
|
6130
6149
|
const ticketIdGate = evaluateTicketIdGate(body.ticketId);
|
|
6131
6150
|
if (!body.ticketId) return stop(ctx, null, ticketIdGate.gate, ticketIdGate.detail);
|
|
@@ -6145,7 +6164,14 @@ async function runFollowupPass(ctx, config, rawBody, run) {
|
|
|
6145
6164
|
const ticket = await ctx.api.integrations.run("gorgias", "getTicketWithContext", { ticketId });
|
|
6146
6165
|
const raw = ticket?.ticket ?? {};
|
|
6147
6166
|
const conversation = toConversation(ref, raw, ticket?.context ?? { messages: [], customerContext: null });
|
|
6148
|
-
const gates = evaluateTicketGates({
|
|
6167
|
+
const gates = evaluateTicketGates({
|
|
6168
|
+
settings,
|
|
6169
|
+
tags: ticketTagNames(raw),
|
|
6170
|
+
categories,
|
|
6171
|
+
conversation,
|
|
6172
|
+
anchor,
|
|
6173
|
+
ignoreCategoryOptIn: generateOnly
|
|
6174
|
+
});
|
|
6149
6175
|
if (gates.stop || !gates.category) {
|
|
6150
6176
|
return stopAt(ctx, ticketId, gates.stop ?? unresolvedCategory());
|
|
6151
6177
|
}
|
|
@@ -6154,12 +6180,16 @@ async function runFollowupPass(ctx, config, rawBody, run) {
|
|
|
6154
6180
|
run.id ??= (await ctx.api.runs.start({
|
|
6155
6181
|
kind: FOLLOWUP_RUN_KIND,
|
|
6156
6182
|
message: `Message suivant \u2014 ticket ${ticketId}`,
|
|
6157
|
-
metadata: { ticketId, categoryTag: category.tagName, channel: body.channel }
|
|
6183
|
+
metadata: { ticketId, categoryTag: category.tagName, channel: body.channel, generateOnly }
|
|
6158
6184
|
})).id;
|
|
6159
6185
|
const created = await openFollowupResponse(ctx, { ticketId, category, conversation, settings, runId: run.id });
|
|
6160
6186
|
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 {
|
|
6187
|
+
await respondToPendingResponse(ctx, config, created.id, { testRun: generateOnly });
|
|
6188
|
+
return {
|
|
6189
|
+
ticketId,
|
|
6190
|
+
stoppedAt: null,
|
|
6191
|
+
reason: generateOnly ? `r\xE9ponse de suite g\xE9n\xE9r\xE9e sans envoi (cat\xE9gorie \xAB ${category.name} \xBB)` : `r\xE9ponse de suite g\xE9n\xE9r\xE9e (cat\xE9gorie \xAB ${category.name} \xBB)`
|
|
6192
|
+
};
|
|
6163
6193
|
}
|
|
6164
6194
|
async function readFollowupAnchor(ctx, ticketId) {
|
|
6165
6195
|
const page = await ctx.api.list("generated-response", { filter: { ticketId }, limit: ANCHOR_LOOKUP_LIMIT });
|
|
@@ -6272,78 +6302,6 @@ function stop(ctx, ticketId, gate, reason) {
|
|
|
6272
6302
|
ctx.logger.info(`gorgias-webhook: stop at ${gate} for ticket ${ticketId ?? "?"} \u2014 ${reason}`);
|
|
6273
6303
|
return { ticketId, stoppedAt: gate, reason };
|
|
6274
6304
|
}
|
|
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
6305
|
function buildTestGorgiasWebhookFunctionDef(config) {
|
|
6348
6306
|
return {
|
|
6349
6307
|
universalIdentifier: identifierFor(config, "test-gorgias-webhook"),
|
|
@@ -6363,7 +6321,7 @@ function buildTestGorgiasWebhookFunctionDef(config) {
|
|
|
6363
6321
|
name: "mode",
|
|
6364
6322
|
type: appKit.FieldType.TEXT,
|
|
6365
6323
|
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.",
|
|
6324
|
+
description: "'diagnostic' (d\xE9faut) \xE9value les gates sans aucun effet de bord ; 'generate' g\xE9n\xE8re la r\xE9ponse sans jamais l'envoyer, m\xEAme si la cat\xE9gorie n'a pas opt\xE9 ; 'run' d\xE9clenche le vrai traitement, envoi compris si la cat\xE9gorie est en auto.",
|
|
6367
6325
|
isNullable: true
|
|
6368
6326
|
}
|
|
6369
6327
|
]
|
|
@@ -6375,12 +6333,10 @@ function createTestGorgiasWebhookHandler(_config) {
|
|
|
6375
6333
|
var NUMERIC2 = /^\d+$/;
|
|
6376
6334
|
async function testGorgiasWebhookHandler(ctx, input) {
|
|
6377
6335
|
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 === "
|
|
6380
|
-
|
|
6381
|
-
|
|
6382
|
-
}
|
|
6383
|
-
return diagnose(ctx, ticketId);
|
|
6336
|
+
const mode = input.mode === "run" ? "run" : input.mode === "generate" ? "generate" : "diagnostic";
|
|
6337
|
+
if (mode === "diagnostic") return diagnose(ctx, ticketId);
|
|
6338
|
+
if (!ticketId) throw new ctx.NonRetriableError("L'identifiant du ticket doit \xEAtre une suite de chiffres.");
|
|
6339
|
+
return triggerRun(ctx, ticketId, mode);
|
|
6384
6340
|
}
|
|
6385
6341
|
async function diagnose(ctx, ticketId) {
|
|
6386
6342
|
const gates = [];
|
|
@@ -6416,23 +6372,25 @@ function finish3(gates, ticketId) {
|
|
|
6416
6372
|
gates: full
|
|
6417
6373
|
};
|
|
6418
6374
|
}
|
|
6419
|
-
async function
|
|
6375
|
+
async function triggerRun(ctx, ticketId, mode) {
|
|
6376
|
+
const generateOnly = mode === "generate";
|
|
6420
6377
|
const run = await ctx.api.runs.start({
|
|
6421
6378
|
kind: FOLLOWUP_RUN_KIND,
|
|
6422
|
-
message: `Test webhook \u2014 ticket ${ticketId}`,
|
|
6423
|
-
metadata: { ticketId, triggeredFrom: "test-gorgias-webhook" }
|
|
6379
|
+
message: generateOnly ? `Test webhook sans envoi \u2014 ticket ${ticketId}` : `Test webhook \u2014 ticket ${ticketId}`,
|
|
6380
|
+
metadata: { ticketId, triggeredFrom: "test-gorgias-webhook", generateOnly }
|
|
6424
6381
|
});
|
|
6425
6382
|
try {
|
|
6426
6383
|
await ctx.api.events.send(FOLLOWUP_RUN_REQUESTED_EVENT, {
|
|
6427
6384
|
_key: run.id,
|
|
6428
6385
|
runId: run.id,
|
|
6429
|
-
body: { ticket_id: ticketId }
|
|
6386
|
+
body: { ticket_id: ticketId },
|
|
6387
|
+
generateOnly
|
|
6430
6388
|
});
|
|
6431
6389
|
} catch (err) {
|
|
6432
6390
|
await ctx.api.runs.fail(run.id, { message: err instanceof Error ? err.message : String(err) });
|
|
6433
6391
|
throw err;
|
|
6434
6392
|
}
|
|
6435
|
-
return { mode
|
|
6393
|
+
return { mode, ticketId, runId: run.id };
|
|
6436
6394
|
}
|
|
6437
6395
|
|
|
6438
6396
|
// src/pages/manifest.ts
|
|
@@ -6458,24 +6416,9 @@ var SUPPORT_KIT_GORGIAS_SCOPES = [
|
|
|
6458
6416
|
"read_tickets",
|
|
6459
6417
|
"read_views",
|
|
6460
6418
|
"write_tags",
|
|
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
|
-
}
|
|
6419
|
+
"write_tickets"
|
|
6478
6420
|
];
|
|
6421
|
+
var SUPPORT_KIT_SERVER_VARIABLES = [];
|
|
6479
6422
|
var SUPPORT_KIT_INTEGRATIONS = [
|
|
6480
6423
|
{ provider: "gorgias", scopes: [...SUPPORT_KIT_GORGIAS_SCOPES] }
|
|
6481
6424
|
];
|
|
@@ -6586,11 +6529,6 @@ var FUNCTION_ASSEMBLY = [
|
|
|
6586
6529
|
build: buildGorgiasFollowupRunFunctionDef,
|
|
6587
6530
|
createHandler: createGorgiasFollowupRunHandler
|
|
6588
6531
|
},
|
|
6589
|
-
{
|
|
6590
|
-
key: "setup-gorgias-webhook",
|
|
6591
|
-
build: buildSetupGorgiasWebhookFunctionDef,
|
|
6592
|
-
createHandler: createSetupGorgiasWebhookHandler
|
|
6593
|
-
},
|
|
6594
6532
|
{
|
|
6595
6533
|
key: "test-gorgias-webhook",
|
|
6596
6534
|
build: buildTestGorgiasWebhookFunctionDef,
|