@velaro/cli 1.4.196 → 1.4.198
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 +2 -0
- package/lib/commands/sales.js +205 -0
- package/package.json +1 -1
package/bin/velaro.js
CHANGED
|
@@ -110,6 +110,7 @@ import { signupFormCommand } from '../lib/commands/signup-form.js';
|
|
|
110
110
|
import { authorityCommand } from '../lib/commands/authority.js';
|
|
111
111
|
import { caseCommand } from '../lib/commands/case.js';
|
|
112
112
|
import { dealCommand } from '../lib/commands/deal.js';
|
|
113
|
+
import { salesCommand } from '../lib/commands/sales.js';
|
|
113
114
|
import { ticketCommand } from '../lib/commands/ticket.js';
|
|
114
115
|
import { crmCommand } from '../lib/commands/crm-studio.js';
|
|
115
116
|
import { emailRouteCommand } from '../lib/commands/email-route.js';
|
|
@@ -279,6 +280,7 @@ await (registerStaffCommands ? registerStaffCommands(baseYargs) : baseYargs)
|
|
|
279
280
|
.command(authorityCommand)
|
|
280
281
|
.command(caseCommand)
|
|
281
282
|
.command(dealCommand)
|
|
283
|
+
.command(salesCommand)
|
|
282
284
|
.command(ticketCommand)
|
|
283
285
|
.command(crmCommand)
|
|
284
286
|
.command(emailRouteCommand)
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import { request } from '../api.js';
|
|
2
|
+
import { runCommand } from '../run.js';
|
|
3
|
+
|
|
4
|
+
// -- velaro sales -------------------------------------------------------------
|
|
5
|
+
// CLI for the Revenue Suite (sales sequences and speed to lead), velaro-admin SalesAutomationController:
|
|
6
|
+
// status GET /SalesAutomation/Status
|
|
7
|
+
// step-types GET /SalesAutomation/StepTypes
|
|
8
|
+
// templates GET /SalesAutomation/Templates
|
|
9
|
+
// template-install POST /SalesAutomation/Templates/{key}/Install
|
|
10
|
+
// enroll POST /SalesAutomation/Enroll
|
|
11
|
+
// rules GET /SalesAutomation/SpeedToLead/Rules
|
|
12
|
+
// rule-upsert PUT /SalesAutomation/SpeedToLead/Rules
|
|
13
|
+
// rule-delete DELETE /SalesAutomation/SpeedToLead/Rules/{id}
|
|
14
|
+
// report GET /SalesAutomation/SpeedToLead/Report
|
|
15
|
+
// leads GET /SalesAutomation/SpeedToLead/Leads
|
|
16
|
+
// The site always comes from the signed-in credential; no command takes a site id.
|
|
17
|
+
// MCP parity: mcp/parity/sales-automation.customer.js (sales_* and speed_to_lead_* tools).
|
|
18
|
+
|
|
19
|
+
const BOLD = '\x1b[1m';
|
|
20
|
+
const DIM = '\x1b[2m';
|
|
21
|
+
const RST = '\x1b[0m';
|
|
22
|
+
|
|
23
|
+
const printJson = (v) => console.log(JSON.stringify(v, null, 2));
|
|
24
|
+
const list = (v) => (Array.isArray(v) ? v : []);
|
|
25
|
+
const csv = (v) => (v === undefined ? undefined : String(v).split(',').map((s) => s.trim()).filter(Boolean));
|
|
26
|
+
|
|
27
|
+
async function statusHandler(argv) {
|
|
28
|
+
const v = await request('GET', '/SalesAutomation/Status');
|
|
29
|
+
if (argv.json) return printJson(v);
|
|
30
|
+
const on = (b) => (b ? 'on' : 'off');
|
|
31
|
+
console.log(`\n${BOLD}${v.package ?? 'Revenue Suite'}${RST}`);
|
|
32
|
+
console.log(` Sales sequences: ${on(v.salesSequences)}`);
|
|
33
|
+
console.log(` Speed to lead: ${on(v.speedToLead)}`);
|
|
34
|
+
console.log(` Deal automation: ${on(v.dealAutomation)}`);
|
|
35
|
+
if (!v.salesSequences && !v.speedToLead && v.missingMessage) console.log(` ${DIM}${v.missingMessage}${RST}`);
|
|
36
|
+
console.log('');
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
async function stepTypesHandler(argv) {
|
|
40
|
+
const v = list(await request('GET', '/SalesAutomation/StepTypes'));
|
|
41
|
+
if (argv.json) return printJson(v);
|
|
42
|
+
console.log(`\n${BOLD}Sequence step types${RST} (${v.length})`);
|
|
43
|
+
for (const t of v) {
|
|
44
|
+
console.log(` ${String(t.type).padEnd(22)} ${t.label ?? ''}`);
|
|
45
|
+
if (t.description) console.log(` ${DIM}${t.description}${RST}`);
|
|
46
|
+
}
|
|
47
|
+
console.log('');
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
async function templatesHandler(argv) {
|
|
51
|
+
const v = list(await request('GET', '/SalesAutomation/Templates'));
|
|
52
|
+
if (argv.json) return printJson(v);
|
|
53
|
+
console.log(`\n${BOLD}Starter sequences${RST}`);
|
|
54
|
+
for (const t of v) {
|
|
55
|
+
const state = t.installed ? (t.isActive ? 'installed, on' : 'installed, off') : 'not installed';
|
|
56
|
+
console.log(` ${String(t.key).padEnd(24)} ${t.name} ${DIM}(${t.stepCount} steps, ${state}${t.campaignId ? `, campaign ${t.campaignId}` : ''})${RST}`);
|
|
57
|
+
if (t.needsBookingLink) console.log(` ${DIM}Needs a scheduler link: pass --booking-link when installing.${RST}`);
|
|
58
|
+
}
|
|
59
|
+
console.log('');
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
async function templateInstallHandler(argv) {
|
|
63
|
+
const body = { bookingLinkUrl: argv.bookingLink, activate: !!argv.activate, reset: !!argv.reset };
|
|
64
|
+
const v = await request('POST', `/SalesAutomation/Templates/${encodeURIComponent(argv.key)}/Install`, body);
|
|
65
|
+
if (argv.json) return printJson(v);
|
|
66
|
+
console.log(`\n Starter sequence "${argv.key}" is installed.`);
|
|
67
|
+
if (v?.campaignId !== undefined) console.log(` Campaign ${v.campaignId}, ${v.isActive ? 'on' : 'off'}.`);
|
|
68
|
+
for (const n of list(v?.notes)) console.log(` ${DIM}${n}${RST}`);
|
|
69
|
+
console.log('');
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
async function enrollHandler(argv) {
|
|
73
|
+
const body = { campaignId: argv.campaignId, email: argv.email, name: argv.name };
|
|
74
|
+
const v = await request('POST', '/SalesAutomation/Enroll', body);
|
|
75
|
+
if (argv.json) return printJson(v);
|
|
76
|
+
console.log(`\n ${v?.enrolled ? `Enrolled ${argv.email}.` : `${argv.email} was already enrolled.`}\n`);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
async function rulesHandler(argv) {
|
|
80
|
+
const v = list(await request('GET', '/SalesAutomation/SpeedToLead/Rules'));
|
|
81
|
+
if (argv.json) return printJson(v);
|
|
82
|
+
console.log(`\n${BOLD}Speed to lead rules${RST} (${v.length})`);
|
|
83
|
+
for (const r of v) {
|
|
84
|
+
console.log(` #${r.id} ${r.name} ${r.isActive ? 'on' : 'off'} ${DIM}notify in ${r.notifySeconds}s, escalate after ${r.escalateAfterMinutes} min, ${r.maxEscalations} escalations at most${RST}`);
|
|
85
|
+
}
|
|
86
|
+
console.log('');
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
async function ruleUpsertHandler(argv) {
|
|
90
|
+
const body = { name: argv.name };
|
|
91
|
+
if (argv.id !== undefined) body.id = argv.id;
|
|
92
|
+
if (argv.active !== undefined) body.isActive = argv.active;
|
|
93
|
+
if (argv.triggers !== undefined) body.triggerTypes = csv(argv.triggers);
|
|
94
|
+
if (argv.sources !== undefined) body.sources = csv(argv.sources);
|
|
95
|
+
if (argv.minScore !== undefined) body.minScore = argv.minScore;
|
|
96
|
+
if (argv.notifySeconds !== undefined) body.notifySeconds = argv.notifySeconds;
|
|
97
|
+
if (argv.escalateAfterMinutes !== undefined) body.escalateAfterMinutes = argv.escalateAfterMinutes;
|
|
98
|
+
if (argv.maxEscalations !== undefined) body.maxEscalations = argv.maxEscalations;
|
|
99
|
+
if (argv.teamId !== undefined) body.teamId = argv.teamId;
|
|
100
|
+
if (argv.skillId !== undefined) body.skillId = argv.skillId;
|
|
101
|
+
if (argv.channels !== undefined) body.notifyChannels = csv(argv.channels);
|
|
102
|
+
if (argv.sequence !== undefined) body.sequenceCampaignId = argv.sequence;
|
|
103
|
+
const v = await request('PUT', '/SalesAutomation/SpeedToLead/Rules', body);
|
|
104
|
+
if (argv.json) return printJson(v);
|
|
105
|
+
console.log(`\n Saved rule #${v?.id ?? argv.id ?? ''} "${v?.name ?? argv.name}".\n`);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
async function ruleDeleteHandler(argv) {
|
|
109
|
+
await request('DELETE', `/SalesAutomation/SpeedToLead/Rules/${argv.id}`);
|
|
110
|
+
console.log(`\n Deleted rule #${argv.id}.\n`);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
async function reportHandler(argv) {
|
|
114
|
+
const qs = argv.days ? `?days=${argv.days}` : '';
|
|
115
|
+
const v = await request('GET', `/SalesAutomation/SpeedToLead/Report${qs}`);
|
|
116
|
+
if (argv.json) return printJson(v);
|
|
117
|
+
console.log(`\n${BOLD}Speed to lead report${RST}${argv.days ? ` (last ${argv.days} days)` : ''}`);
|
|
118
|
+
printJson(v);
|
|
119
|
+
console.log('');
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
async function leadsHandler(argv) {
|
|
123
|
+
const qs = new URLSearchParams();
|
|
124
|
+
if (argv.page) qs.set('page', String(argv.page));
|
|
125
|
+
if (argv.pageSize) qs.set('pageSize', String(argv.pageSize));
|
|
126
|
+
if (argv.status) qs.set('status', argv.status);
|
|
127
|
+
const q = qs.toString();
|
|
128
|
+
const v = await request('GET', `/SalesAutomation/SpeedToLead/Leads${q ? `?${q}` : ''}`);
|
|
129
|
+
if (argv.json) return printJson(v);
|
|
130
|
+
const items = list(v?.items);
|
|
131
|
+
console.log(`\n${BOLD}Speed to lead leads${RST} page ${v?.page ?? 1}, ${items.length} of ${v?.total ?? items.length}`);
|
|
132
|
+
for (const l of items) {
|
|
133
|
+
const secs = l.secondsToFirstTouch == null ? 'no touch yet' : `first touch in ${l.secondsToFirstTouch}s`;
|
|
134
|
+
console.log(` ${l.arrivedAt} ${l.contactName ?? '-'} <${l.contactEmail}> ${l.status} ${DIM}${secs}${l.ownerName ? `, owner ${l.ownerName}` : ''}${RST}`);
|
|
135
|
+
}
|
|
136
|
+
console.log('');
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
const json = (y) => y.option('json', { type: 'boolean' });
|
|
140
|
+
|
|
141
|
+
export const salesCommand = {
|
|
142
|
+
command: 'sales',
|
|
143
|
+
describe: 'Revenue Suite: sales sequences and speed to lead (native CRM)',
|
|
144
|
+
builder: (y) => y
|
|
145
|
+
.command({ command: 'status', describe: 'Which Revenue Suite features are on', builder: json, handler: runCommand(statusHandler) })
|
|
146
|
+
.command({ command: 'step-types', describe: 'Step types a sequence can use', builder: json, handler: runCommand(stepTypesHandler) })
|
|
147
|
+
.command({ command: 'templates', describe: 'Starter sequences and their install state', builder: json, handler: runCommand(templatesHandler) })
|
|
148
|
+
.command({
|
|
149
|
+
command: 'template-install <key>',
|
|
150
|
+
describe: 'Install (or re-open) a starter sequence; repeating it creates nothing new',
|
|
151
|
+
builder: (yy) => json(yy
|
|
152
|
+
.option('booking-link', { type: 'string', describe: 'Full https scheduler link for booking steps' })
|
|
153
|
+
.option('activate', { type: 'boolean', describe: 'Turn the sequence on' })
|
|
154
|
+
.option('reset', { type: 'boolean', describe: 'Start over: replace steps (snapshot saved to the audit trail)' })),
|
|
155
|
+
handler: runCommand(templateInstallHandler),
|
|
156
|
+
})
|
|
157
|
+
.command({
|
|
158
|
+
command: 'enroll',
|
|
159
|
+
describe: 'Enroll one contact in a sequence',
|
|
160
|
+
builder: (yy) => json(yy
|
|
161
|
+
.option('campaign-id', { type: 'number', demandOption: true, describe: 'Sequence (campaign) id' })
|
|
162
|
+
.option('email', { type: 'string', demandOption: true })
|
|
163
|
+
.option('name', { type: 'string' })),
|
|
164
|
+
handler: runCommand(enrollHandler),
|
|
165
|
+
})
|
|
166
|
+
.command({ command: 'rules', describe: 'List speed to lead rules', builder: json, handler: runCommand(rulesHandler) })
|
|
167
|
+
.command({
|
|
168
|
+
command: 'rule-upsert',
|
|
169
|
+
describe: 'Create a speed to lead rule, or update one with --id',
|
|
170
|
+
builder: (yy) => json(yy
|
|
171
|
+
.option('name', { type: 'string', demandOption: true })
|
|
172
|
+
.option('id', { type: 'number', describe: 'Update this rule' })
|
|
173
|
+
.option('active', { type: 'boolean' })
|
|
174
|
+
.option('triggers', { type: 'string', describe: 'Comma separated trigger ids' })
|
|
175
|
+
.option('sources', { type: 'string', describe: 'Comma separated lead sources' })
|
|
176
|
+
.option('min-score', { type: 'number' })
|
|
177
|
+
.option('notify-seconds', { type: 'number', describe: 'Notify the owner within this many seconds' })
|
|
178
|
+
.option('escalate-after-minutes', { type: 'number' })
|
|
179
|
+
.option('max-escalations', { type: 'number' })
|
|
180
|
+
.option('team-id', { type: 'number' })
|
|
181
|
+
.option('skill-id', { type: 'number' })
|
|
182
|
+
.option('channels', { type: 'string', describe: 'Comma separated: desktop, teams, slack' })
|
|
183
|
+
.option('sequence', { type: 'number', describe: 'Sequence (campaign) id to enroll the lead in' })),
|
|
184
|
+
handler: runCommand(ruleUpsertHandler),
|
|
185
|
+
})
|
|
186
|
+
.command({ command: 'rule-delete <id>', describe: 'Delete a speed to lead rule', builder: (yy) => yy.positional('id', { type: 'number' }), handler: runCommand(ruleDeleteHandler) })
|
|
187
|
+
.command({
|
|
188
|
+
command: 'report',
|
|
189
|
+
describe: 'Time to first touch report',
|
|
190
|
+
builder: (yy) => json(yy.option('days', { type: 'number', describe: 'Days to cover' })),
|
|
191
|
+
handler: runCommand(reportHandler),
|
|
192
|
+
})
|
|
193
|
+
.command({
|
|
194
|
+
command: 'leads',
|
|
195
|
+
describe: 'Page through speed to lead leads',
|
|
196
|
+
builder: (yy) => json(yy
|
|
197
|
+
.option('page', { type: 'number' })
|
|
198
|
+
.option('page-size', { type: 'number' })
|
|
199
|
+
.option('status', { type: 'string', choices: ['pending', 'touched', 'breached'] })),
|
|
200
|
+
handler: runCommand(leadsHandler),
|
|
201
|
+
})
|
|
202
|
+
.demandCommand(1, 'Specify a sales subcommand.')
|
|
203
|
+
.strict(),
|
|
204
|
+
handler: () => {},
|
|
205
|
+
};
|
package/package.json
CHANGED