@velaro/cli 1.4.196 → 1.4.197
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/bin/velaro.js
CHANGED
|
@@ -64,7 +64,6 @@ import { moshkyWriteAccessCommand } from '../lib/commands/moshky-write-access.js
|
|
|
64
64
|
import { chatIntelligenceTopicsCommand } from '../lib/commands/chat-intelligence-topics.js';
|
|
65
65
|
import { focusCommand } from '../lib/commands/focus.js';
|
|
66
66
|
import { automationDraftCommand } from '../lib/commands/automation-draft.js';
|
|
67
|
-
import { serviceStateCommand } from '../lib/commands/service-state.js';
|
|
68
67
|
import { magentoCommand } from '../lib/commands/magento.js';
|
|
69
68
|
import { sapCommand } from '../lib/commands/sap.js';
|
|
70
69
|
import { salesforceCommand } from '../lib/commands/salesforce.js';
|
|
@@ -232,7 +231,6 @@ await (registerStaffCommands ? registerStaffCommands(baseYargs) : baseYargs)
|
|
|
232
231
|
.command(moshkyWriteAccessCommand)
|
|
233
232
|
.command(focusCommand)
|
|
234
233
|
.command(automationDraftCommand)
|
|
235
|
-
.command(serviceStateCommand)
|
|
236
234
|
.command(magentoCommand)
|
|
237
235
|
.command(sapCommand)
|
|
238
236
|
.command(salesforceCommand)
|
|
@@ -119,8 +119,8 @@ async function contactHandler(argv) {
|
|
|
119
119
|
const sharedOptions = yy => yy
|
|
120
120
|
.option('take', { describe: 'Page size (1-100)', type: 'number', default: 25 })
|
|
121
121
|
.option('skip', { describe: 'Rows to skip', type: 'number', default: 0 })
|
|
122
|
-
.option('source', { describe: 'Transactional | Campaign | Broadcast
|
|
123
|
-
.option('status', { describe: 'Sent | Pending | Failed | Unsubscribed |
|
|
122
|
+
.option('source', { describe: 'Transactional | Campaign | Broadcast', type: 'string' })
|
|
123
|
+
.option('status', { describe: 'Sent | Pending | Failed | Unsubscribed | Skipped', type: 'string' });
|
|
124
124
|
|
|
125
125
|
export const outboundActivityCommand = {
|
|
126
126
|
command: 'outbound-activity <subcommand>',
|
package/package.json
CHANGED
|
@@ -1,183 +0,0 @@
|
|
|
1
|
-
import { request } from '../api.js';
|
|
2
|
-
import { runCommand } from '../run.js';
|
|
3
|
-
|
|
4
|
-
// -- velaro service-state ------------------------------------------------------
|
|
5
|
-
// Conversation Intelligence: pause promotional email and text for contacts who need service
|
|
6
|
-
// (open case, bad recent chat or call, unanswered call, failed delivery), and follow up after
|
|
7
|
-
// unanswered calls. siteId is applied server-side from the authenticated session, never a CLI arg.
|
|
8
|
-
//
|
|
9
|
-
// Backend contract (server/Velaro.Admin/Controllers/ServiceStateController.cs):
|
|
10
|
-
// GET ServiceState/policy PUT ServiceState/policy
|
|
11
|
-
// POST ServiceState/policy/reset GET ServiceState/holds
|
|
12
|
-
// POST ServiceState/holds/{id}/release GET ServiceState/preview
|
|
13
|
-
// POST ServiceState/voice-flow/ensure-default GET ServiceState/voice-enrollments
|
|
14
|
-
// Every endpoint answers 402 {error, package, fallback} when the site lacks Conversation Intelligence.
|
|
15
|
-
|
|
16
|
-
const qs = (o) => {
|
|
17
|
-
const p = new URLSearchParams();
|
|
18
|
-
for (const [k, v] of Object.entries(o)) if (v !== undefined && v !== null && v !== '') p.set(k, String(v));
|
|
19
|
-
const s = p.toString();
|
|
20
|
-
return s ? '?' + s : '';
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
function fmtDate(d) {
|
|
24
|
-
return d ? new Date(d).toISOString().replace('T', ' ').slice(0, 19) : '-';
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
function printPolicy(p) {
|
|
28
|
-
const row = (l, v) => console.log(` ${l.padEnd(34)}${v ?? '-'}`);
|
|
29
|
-
console.log(`\nService pauses${p.isDefault ? ' (recommended defaults, never edited)' : ''}\n`);
|
|
30
|
-
row('On', p.enabled);
|
|
31
|
-
row('Pause for an open case', p.holdOpenCase);
|
|
32
|
-
row('Pause after a bad chat or call', `${p.holdNegativeSentiment} (${p.negativeSentimentWindowDays} days)`);
|
|
33
|
-
row('Pause after an unanswered call', `${p.holdUnresolvedVoice} (${p.unresolvedVoiceWindowDays} days)`);
|
|
34
|
-
row('Pause after a failed message', `${p.holdFailedDelivery} (${p.failedDeliveryWindowDays} days)`);
|
|
35
|
-
row('Longest a message waits (days)', p.maxHoldDays);
|
|
36
|
-
row('Check again every (minutes)', p.recheckMinutes);
|
|
37
|
-
row('Quiet hours', `${p.quietHoursStart} to ${p.quietHoursEnd} (${p.quietHoursTimeZone})`);
|
|
38
|
-
row('Follow up after unanswered calls', p.voiceFlowEnabled);
|
|
39
|
-
row('Follow-up sequence id', p.voiceFlowCampaignId);
|
|
40
|
-
row('Minimum call length (seconds)', p.voiceFlowMinCallSeconds);
|
|
41
|
-
row('Updated', fmtDate(p.updatedAt));
|
|
42
|
-
console.log('');
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
const toBool = (v) => (v === undefined ? undefined : v === true || v === 'true');
|
|
46
|
-
|
|
47
|
-
export const serviceStateCommand = {
|
|
48
|
-
command: 'service-state <subcommand>',
|
|
49
|
-
describe: 'Pause promotions for customers who need service, and follow up after unanswered calls',
|
|
50
|
-
builder: (y) => y
|
|
51
|
-
.command({
|
|
52
|
-
command: 'policy',
|
|
53
|
-
describe: 'Show the current service pause settings',
|
|
54
|
-
handler: runCommand(async () => printPolicy(await request('GET', 'ServiceState/policy'))),
|
|
55
|
-
})
|
|
56
|
-
.command({
|
|
57
|
-
command: 'set-policy',
|
|
58
|
-
describe: 'Change service pause settings (only the options you pass change)',
|
|
59
|
-
builder: (y2) => y2
|
|
60
|
-
.option('enabled', { type: 'boolean' })
|
|
61
|
-
.option('hold-open-case', { type: 'boolean' })
|
|
62
|
-
.option('hold-negative-sentiment', { type: 'boolean' })
|
|
63
|
-
.option('negative-sentiment-window-days', { type: 'number' })
|
|
64
|
-
.option('hold-unresolved-voice', { type: 'boolean' })
|
|
65
|
-
.option('unresolved-voice-window-days', { type: 'number' })
|
|
66
|
-
.option('hold-failed-delivery', { type: 'boolean' })
|
|
67
|
-
.option('failed-delivery-window-days', { type: 'number' })
|
|
68
|
-
.option('max-hold-days', { type: 'number' })
|
|
69
|
-
.option('recheck-minutes', { type: 'number' })
|
|
70
|
-
.option('quiet-hours-start', { type: 'number' })
|
|
71
|
-
.option('quiet-hours-end', { type: 'number' })
|
|
72
|
-
.option('quiet-hours-time-zone', { type: 'string', describe: 'For example America/Los_Angeles' })
|
|
73
|
-
.option('voice-flow-enabled', { type: 'boolean' })
|
|
74
|
-
.option('voice-flow-campaign-id', { type: 'number' })
|
|
75
|
-
.option('voice-flow-min-call-seconds', { type: 'number' }),
|
|
76
|
-
handler: runCommand(async (a) => {
|
|
77
|
-
const body = {
|
|
78
|
-
enabled: toBool(a.enabled),
|
|
79
|
-
holdOpenCase: toBool(a.holdOpenCase),
|
|
80
|
-
holdNegativeSentiment: toBool(a.holdNegativeSentiment),
|
|
81
|
-
negativeSentimentWindowDays: a.negativeSentimentWindowDays,
|
|
82
|
-
holdUnresolvedVoice: toBool(a.holdUnresolvedVoice),
|
|
83
|
-
unresolvedVoiceWindowDays: a.unresolvedVoiceWindowDays,
|
|
84
|
-
holdFailedDelivery: toBool(a.holdFailedDelivery),
|
|
85
|
-
failedDeliveryWindowDays: a.failedDeliveryWindowDays,
|
|
86
|
-
maxHoldDays: a.maxHoldDays,
|
|
87
|
-
recheckMinutes: a.recheckMinutes,
|
|
88
|
-
quietHoursStart: a.quietHoursStart,
|
|
89
|
-
quietHoursEnd: a.quietHoursEnd,
|
|
90
|
-
quietHoursTimeZone: a.quietHoursTimeZone,
|
|
91
|
-
voiceFlowEnabled: toBool(a.voiceFlowEnabled),
|
|
92
|
-
voiceFlowCampaignId: a.voiceFlowCampaignId,
|
|
93
|
-
voiceFlowMinCallSeconds: a.voiceFlowMinCallSeconds,
|
|
94
|
-
};
|
|
95
|
-
Object.keys(body).forEach((k) => body[k] === undefined && delete body[k]);
|
|
96
|
-
if (!Object.keys(body).length) throw new Error('Pass at least one option to change.');
|
|
97
|
-
printPolicy(await request('PUT', 'ServiceState/policy', body));
|
|
98
|
-
}),
|
|
99
|
-
})
|
|
100
|
-
.command({
|
|
101
|
-
command: 'reset-policy',
|
|
102
|
-
describe: 'Go back to the recommended defaults (prints the previous settings so you can restore them)',
|
|
103
|
-
handler: runCommand(async () => {
|
|
104
|
-
const r = await request('POST', 'ServiceState/policy/reset');
|
|
105
|
-
console.log('\nSettings reset. Previous settings (pass these to set-policy to restore):\n');
|
|
106
|
-
console.log(JSON.stringify(r?.snapshot ?? {}, null, 2));
|
|
107
|
-
console.log('');
|
|
108
|
-
}),
|
|
109
|
-
})
|
|
110
|
-
.command({
|
|
111
|
-
command: 'holds',
|
|
112
|
-
describe: 'List promotions held for service reasons',
|
|
113
|
-
builder: (y2) => y2
|
|
114
|
-
.option('status', { type: 'string', choices: ['held', 'released', 'expired'], default: 'held' })
|
|
115
|
-
.option('contact-email', { type: 'string' })
|
|
116
|
-
.option('page', { type: 'number', default: 1 })
|
|
117
|
-
.option('page-size', { type: 'number', default: 25 }),
|
|
118
|
-
handler: runCommand(async (a) => {
|
|
119
|
-
const r = await request('GET', 'ServiceState/holds' + qs({
|
|
120
|
-
status: a.status, contactEmail: a.contactEmail, page: a.page, pageSize: a.pageSize,
|
|
121
|
-
}));
|
|
122
|
-
const items = r?.items ?? [];
|
|
123
|
-
if (!items.length) { console.log('\nNothing is held.\n'); return; }
|
|
124
|
-
console.log(`\nHolds (${r.total} total, page ${r.page}):\n`);
|
|
125
|
-
for (const h of items) {
|
|
126
|
-
console.log(` #${h.id} ${h.status.padEnd(9)} ${h.contactEmail} ${h.channel} held ${fmtDate(h.heldAt)} expires ${fmtDate(h.expiresAt)}`);
|
|
127
|
-
console.log(` ${h.reasonText ?? (h.reasons || []).join(', ')}`);
|
|
128
|
-
}
|
|
129
|
-
console.log('');
|
|
130
|
-
}),
|
|
131
|
-
})
|
|
132
|
-
.command({
|
|
133
|
-
command: 'release-hold <id>',
|
|
134
|
-
describe: 'Send a held promotion now',
|
|
135
|
-
builder: (y2) => y2.positional('id', { type: 'number' }),
|
|
136
|
-
handler: runCommand(async (a) => {
|
|
137
|
-
await request('POST', `ServiceState/holds/${a.id}/release`);
|
|
138
|
-
console.log(`\nHold #${a.id} released.\n`);
|
|
139
|
-
}),
|
|
140
|
-
})
|
|
141
|
-
.command({
|
|
142
|
-
command: 'preview',
|
|
143
|
-
describe: 'Check whether a promotion to a contact would be held right now (nothing is sent)',
|
|
144
|
-
builder: (y2) => y2
|
|
145
|
-
.option('email', { type: 'string' })
|
|
146
|
-
.option('phone', { type: 'string' })
|
|
147
|
-
.option('message-class', { type: 'string', choices: ['promotional', 'transactional'], default: 'promotional' }),
|
|
148
|
-
handler: runCommand(async (a) => {
|
|
149
|
-
if (!a.email && !a.phone) throw new Error('Pass --email or --phone.');
|
|
150
|
-
const r = await request('GET', 'ServiceState/preview' + qs({ email: a.email, phone: a.phone, messageClass: a.messageClass }));
|
|
151
|
-
console.log(`\n${r.held ? 'HELD' : 'Would send'}${r.reasonText ? ': ' + r.reasonText : ''}`);
|
|
152
|
-
if (r.stateAvailable === false) console.log('Support status could not be checked, so promotions are held to be safe.');
|
|
153
|
-
console.log('');
|
|
154
|
-
}),
|
|
155
|
-
})
|
|
156
|
-
.command({
|
|
157
|
-
command: 'voice-flow-setup',
|
|
158
|
-
describe: 'Create (or reuse) the ready-made follow-up sequence for unanswered calls',
|
|
159
|
-
handler: runCommand(async () => {
|
|
160
|
-
const r = await request('POST', 'ServiceState/voice-flow/ensure-default');
|
|
161
|
-
console.log(`\nFollow-up sequence #${r.campaignId} ${r.created ? 'created' : 'already in place'}.\n`);
|
|
162
|
-
}),
|
|
163
|
-
})
|
|
164
|
-
.command({
|
|
165
|
-
command: 'voice-enrollments',
|
|
166
|
-
describe: 'List callers followed up after unanswered calls (and callers skipped, with the reason)',
|
|
167
|
-
builder: (y2) => y2
|
|
168
|
-
.option('page', { type: 'number', default: 1 })
|
|
169
|
-
.option('page-size', { type: 'number', default: 25 }),
|
|
170
|
-
handler: runCommand(async (a) => {
|
|
171
|
-
const r = await request('GET', 'ServiceState/voice-enrollments' + qs({ page: a.page, pageSize: a.pageSize }));
|
|
172
|
-
const items = r?.items ?? [];
|
|
173
|
-
if (!items.length) { console.log('\nNo unanswered calls have been followed up yet.\n'); return; }
|
|
174
|
-
console.log(`\nVoice follow-ups (${r.total} total, page ${r.page}):\n`);
|
|
175
|
-
for (const e of items) {
|
|
176
|
-
console.log(` #${e.id} ${e.outcome.padEnd(8)} ${e.contactEmail} call ${e.callConversationId} ${fmtDate(e.createdAt)} ${e.reasonText ?? ''}`);
|
|
177
|
-
}
|
|
178
|
-
console.log('');
|
|
179
|
-
}),
|
|
180
|
-
})
|
|
181
|
-
.demandCommand(1),
|
|
182
|
-
handler: () => {},
|
|
183
|
-
};
|