@omnidim-ai/mcp-server 0.20.0 → 0.21.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 +48 -35
- package/build/flat-args.d.ts +15 -0
- package/build/flat-args.js +57 -0
- package/build/flat-args.js.map +1 -0
- package/build/helpers.js +3 -4
- package/build/helpers.js.map +1 -1
- package/build/index.d.ts +1 -1
- package/build/index.js +397 -287
- package/build/index.js.map +1 -1
- package/build/playbooks.generated.d.ts +23 -0
- package/build/playbooks.generated.js +420 -0
- package/build/playbooks.generated.js.map +1 -0
- package/build/procedures.d.ts +11 -7
- package/build/procedures.js +45 -843
- package/build/procedures.js.map +1 -1
- package/build/telemetry.js +2 -2
- package/build/telemetry.js.map +1 -1
- package/build/tool-annotations.js +3 -2
- package/build/tool-annotations.js.map +1 -1
- package/build/tool-marks.js +14 -14
- package/build/tool-marks.js.map +1 -1
- package/package.json +4 -2
- package/src/flat-args.ts +57 -0
- package/src/helpers.ts +3 -4
- package/src/index.ts +396 -287
- package/src/playbooks.generated.ts +419 -0
- package/src/procedures.ts +52 -862
- package/src/telemetry.ts +2 -2
- package/src/tool-annotations.ts +3 -2
- package/src/tool-marks.ts +14 -14
package/src/procedures.ts
CHANGED
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Procedure layer: MCP prompts (parameterized procedures) and resources
|
|
3
|
-
* (reference material) that sit on top of the raw API tools. The tools say
|
|
4
|
-
* WHAT can be called; these say which tool to call WHEN, in what order, with
|
|
5
|
-
* which payload shape, and which gotchas to avoid. Every step here was proven
|
|
6
|
-
* against the live API before being written down.
|
|
7
|
-
*/
|
|
8
1
|
import type { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
9
2
|
import {
|
|
10
3
|
GetPromptRequestSchema,
|
|
@@ -13,650 +6,18 @@ import {
|
|
|
13
6
|
ReadResourceRequestSchema,
|
|
14
7
|
} from "@modelcontextprotocol/sdk/types.js";
|
|
15
8
|
|
|
9
|
+
import generated from "./playbooks.generated.js";
|
|
16
10
|
import { LEGACY_CANVAS_URI, WORKFLOW_CANVAS_HTML, WORKFLOW_CANVAS_URI } from "./workflow-canvas.js";
|
|
17
11
|
|
|
18
12
|
interface PromptArg { name: string; description: string; required?: boolean; }
|
|
19
|
-
interface
|
|
20
|
-
|
|
21
|
-
description: string;
|
|
22
|
-
arguments: PromptArg[];
|
|
23
|
-
build: (args: Record<string, string>) => string;
|
|
24
|
-
}
|
|
13
|
+
interface Variant { given: string[]; text: string; }
|
|
14
|
+
interface PlaybookDef { name: string; description: string; arguments: PromptArg[]; variants: Variant[]; }
|
|
25
15
|
interface ResourceDef { uri: string; name: string; description: string; mimeType: string; text: string; }
|
|
26
16
|
|
|
27
|
-
|
|
28
|
-
* Cross-cutting routing reference. An agent reads this to learn the platform
|
|
29
|
-
* shape and the non-obvious rules that the per-operation tool schemas do not
|
|
30
|
-
* surface on their own.
|
|
31
|
-
*/
|
|
32
|
-
const ROUTING_GUIDE = `# OmniDimension routing guide
|
|
33
|
-
|
|
34
|
-
OmniDimension is a voice AI platform. You create an **agent** (a.k.a. "bot"),
|
|
35
|
-
give it a **phone number** and optionally a **knowledge base**, then place
|
|
36
|
-
**calls** (one-off or as a bulk **campaign**) and read **call logs**.
|
|
37
|
-
|
|
38
|
-
## How to pick the right tool
|
|
39
|
-
|
|
40
|
-
- "Create / set up an agent that does X" -> the \`provision_agent\` prompt.
|
|
41
|
-
- "Why did calls fail / what happened on a call / summarize calls" -> the
|
|
42
|
-
\`audit_calls\` prompt, then \`listCallLogs\` + \`getCallLog\`.
|
|
43
|
-
- "List / inspect what exists" -> \`listAgents\`, \`listPhoneNumbers\`,
|
|
44
|
-
\`listVoices\`, \`listKnowledgeBaseFiles\`.
|
|
45
|
-
- "Get me a number / buy a number" -> \`searchPhoneNumbers\` { region, carrier }
|
|
46
|
-
then \`purchasePhoneNumber\`. This spends the account's balance, so confirm the
|
|
47
|
-
exact number and price with the user before buying. \`releasePhoneNumber\`
|
|
48
|
-
gives one up and cannot be undone.
|
|
49
|
-
\`carrier\` is required on both calls, in every region. Carriers do not stock
|
|
50
|
-
the same numbers, so ask the user which one they want rather than picking:
|
|
51
|
-
see the \`omnidim://reference/carriers\` resource for what each one stocks.
|
|
52
|
-
\`searchPhoneNumbers\`'s response echoes the \`carrier\` a purchase must pass.
|
|
53
|
-
- "Place one call now" -> \`dispatchCall\`. "Call many contacts" -> the bulk
|
|
54
|
-
call tools.
|
|
55
|
-
|
|
56
|
-
## Rules that are easy to get wrong (proven against the live API)
|
|
57
|
-
|
|
58
|
-
1. **Write tools wrap their payload in \`requestBody\`.** \`createAgent\`,
|
|
59
|
-
\`updateAgent\`, \`attachPhoneNumber\`, \`dispatchCall\`, etc. all take
|
|
60
|
-
\`{ "requestBody": { ... } }\`. Flat arguments fail validation.
|
|
61
|
-
2. **Voices: use the \`name\` string as \`voice_id\`.** \`listVoices\` returns
|
|
62
|
-
\`id: null\` for most voices; the usable identifier is the \`name\` field.
|
|
63
|
-
Not every listed voice is synthesizable: an arbitrary one can produce a
|
|
64
|
-
silent call. Prefer a known premade voice and confirm audio on a test call.
|
|
65
|
-
3. **The agent's numeric \`voice\` field is not used for speech.** It can read
|
|
66
|
-
back as \`false\` on an API-created agent; that is normal. The call handler
|
|
67
|
-
uses \`voice_external_id\` + \`voice_provider\`.
|
|
68
|
-
4. **Use the platform defaults:** transcriber \`soniox\`, one of the
|
|
69
|
-
OmniDimension voices, model \`gpt-4.1-mini\`. Pick another provider only when
|
|
70
|
-
the user names one. OmniDimension voices are our most recommended voices:
|
|
71
|
-
picked by our team for each language and tested on real calls. List them
|
|
72
|
-
with \`listVoices\` \`provider=featured\`, best first, and save one as
|
|
73
|
-
\`voice.provider\` = its \`service\` (\`cartesia\`) with its \`name\` as
|
|
74
|
-
\`voice_id\`. A Cartesia \`search\` does not find them. If none fits the
|
|
75
|
-
language or tone, pick another \`cartesia\` voice.
|
|
76
|
-
5. **\`dispatchCall\` returning \`success: true\` does NOT mean a call
|
|
77
|
-
connected.** It means the request was accepted. Proof of a real call is a
|
|
78
|
-
resulting entry in \`listCallLogs\` whose \`getCallLog\` shows a non-empty
|
|
79
|
-
\`call_conversation\`. Never treat the dispatch response as the outcome.
|
|
80
|
-
6. **Reading agents:** \`getAgent\` reports \`voice: false\`; read
|
|
81
|
-
\`voice_external_id\` for the configured voice. \`listAgents\` puts the voice
|
|
82
|
-
in the \`voice\` field. Do not report "no voice" from \`getAgent.voice\`.
|
|
83
|
-
7. **\`listCallLogs\` rows are large** and the response is trimmed if it grows
|
|
84
|
-
past the size cap. Use a small \`pagesize\` (1-3) and fetch detail per row
|
|
85
|
-
with \`getCallLog\`.
|
|
86
|
-
8. **Outbound \`from_number_id\`:** omit it to use the platform default number.
|
|
87
|
-
A number that cannot reach the destination country yields an accepted
|
|
88
|
-
dispatch but no connected call.
|
|
89
|
-
9. **IDs flow between calls:** \`createAgent\` -> \`id\` (the agent_id used
|
|
90
|
-
everywhere downstream); \`listPhoneNumbers\` -> \`id\` (used as
|
|
91
|
-
\`phone_number_id\` to attach and as \`from_number_id\` to dispatch).
|
|
92
|
-
10. **Phone numbers are E.164 with a leading \`+\`** everywhere.
|
|
93
|
-
`;
|
|
94
|
-
|
|
95
|
-
// Provider recommendations by caller language, grounded in what works in
|
|
96
|
-
// production. Names match the createAgent enums (transcriber/voice/model).
|
|
97
|
-
const RECOMMENDED_STACK = `# Recommended provider stacks
|
|
98
|
-
|
|
99
|
-
Each agent uses a transcriber (speech-to-text), a voice (text-to-speech), and a
|
|
100
|
-
language model, all set on \`createAgent\`. The pairings below work well in
|
|
101
|
-
production, grouped by the language your callers speak. Use \`listSTTProviders\`,
|
|
102
|
-
\`listTTSProviders\`, \`listLLMProviders\`, and \`listVoices\` for the live catalog.
|
|
103
|
-
|
|
104
|
-
## Language model
|
|
105
|
-
|
|
106
|
-
- Default: \`gpt-4.1-mini\` — fast and accurate across languages, a good first
|
|
107
|
-
choice for almost any agent.
|
|
108
|
-
- Alternatives: any other \`name\` from \`listLLMProviders\`, which lists only the
|
|
109
|
-
models your organization can use.
|
|
110
|
-
|
|
111
|
-
## Voice
|
|
112
|
-
|
|
113
|
-
- Default: one of the OmniDimension voices, our most recommended voices. Our
|
|
114
|
-
team picks them for each language and tests them on real calls. List them
|
|
115
|
-
with \`listVoices\` \`provider=featured\`, best first, and save one under its
|
|
116
|
-
\`service\` (\`cartesia\`). See \`omnidim://reference/voices\`.
|
|
117
|
-
|
|
118
|
-
## By caller language
|
|
119
|
-
|
|
120
|
-
- **Indian English (en-IN):** transcriber \`soniox\`; an OmniDimension voice
|
|
121
|
-
for English (India).
|
|
122
|
-
- **Hindi / Hinglish (mixed Hindi and English):** transcriber \`soniox\`
|
|
123
|
-
(handles code-mixed speech in one stream); an OmniDimension voice for Hindi.
|
|
124
|
-
- **Other Indian languages (Tamil, Telugu, Marathi, Bengali, Gujarati,
|
|
125
|
-
Kannada, Malayalam, Punjabi):** transcriber \`soniox\`, or \`sarvam\` (tuned for
|
|
126
|
-
Indian languages); an OmniDimension voice for that language.
|
|
127
|
-
- **US English:** transcriber \`soniox\` or \`deepgram_stream\`; an OmniDimension
|
|
128
|
-
voice for English (American).
|
|
129
|
-
- **No OmniDimension voice for the language:** another \`cartesia\` voice.
|
|
130
|
-
|
|
131
|
-
## Field notes
|
|
132
|
-
|
|
133
|
-
- \`transcriber.provider\` is a \`name\` from \`listSTTProviders\`, which lists only
|
|
134
|
-
the transcribers your organization can use. \`deepgram_stream\` also needs a
|
|
135
|
-
\`model\` (\`nova-3\` or \`nova-2\`); the others do not.
|
|
136
|
-
- \`voice.provider\` is the \`service\` of a voice from \`listVoices\`, which lists
|
|
137
|
-
only voices your organization can use. Send only \`provider\` and \`voice_id\`:
|
|
138
|
-
the platform picks the voice model.
|
|
139
|
-
|
|
140
|
-
## Responsiveness
|
|
141
|
-
|
|
142
|
-
- Keep the system prompt focused. Long prompts add latency to every turn.
|
|
143
|
-
- Verify your chosen voice on a short test call before launch (see
|
|
144
|
-
\`omnidim://reference/voices\`).
|
|
145
|
-
`;
|
|
146
|
-
|
|
147
|
-
// How to choose a voice: OmniDimension voices first, then other Cartesia voices.
|
|
148
|
-
const VOICES_GUIDE = `# Choosing a voice
|
|
149
|
-
|
|
150
|
-
\`listVoices\` returns only the voices your organization can use. Use a voice's
|
|
151
|
-
\`name\` field as the \`voice_id\` and its \`service\` as the \`voice.provider\` you
|
|
152
|
-
pass to \`createAgent\`.
|
|
153
|
-
|
|
154
|
-
## Start with OmniDimension voices
|
|
155
|
-
|
|
156
|
-
OmniDimension voices are our most recommended voices. Our team picks them for
|
|
157
|
-
each language and tests them on real calls. Use one unless the user asks for
|
|
158
|
-
something else.
|
|
159
|
-
|
|
160
|
-
- List them with \`listVoices\` \`provider=featured\`. They come back best first.
|
|
161
|
-
- They cover English (India), English (American), Hindi, Tamil, Telugu,
|
|
162
|
-
Marathi, Bengali, Gujarati, Kannada, Malayalam and Punjabi.
|
|
163
|
-
- Each one runs on Cartesia: save it as \`voice.provider\` \`cartesia\` with its
|
|
164
|
-
\`name\` as \`voice_id\`.
|
|
165
|
-
- A Cartesia \`search\` does not find them. Only \`provider=featured\` lists them.
|
|
166
|
-
|
|
167
|
-
Example: Aadya, English (India) and Hindi, voice_id
|
|
168
|
-
\`b521b304-7672-4cf9-9a34-b4eb1df1bde0\`.
|
|
169
|
-
|
|
170
|
-
## If none fits
|
|
171
|
-
|
|
172
|
-
Pick another \`cartesia\` voice. \`listVoices\` \`provider=cartesia\` filters by
|
|
173
|
-
\`search\`, \`language\`, \`accent\` and \`gender\`. Not every catalog voice
|
|
174
|
-
synthesizes cleanly, so place a short test call and listen before launch.
|
|
175
|
-
`;
|
|
176
|
-
|
|
177
|
-
// The createAgent field shape with two complete, copy-ready examples.
|
|
178
|
-
const AGENT_CONFIG_GUIDE = `# Building an agent with createAgent
|
|
179
|
-
|
|
180
|
-
On this server \`createAgent\` wraps its payload in \`requestBody\` (see the
|
|
181
|
-
routing guide). The fields inside:
|
|
182
|
-
|
|
183
|
-
- \`name\` — agent name.
|
|
184
|
-
- \`welcome_message\` — the first line the agent speaks.
|
|
185
|
-
- \`context_breakdown\` — a list of \`{ title, body }\` sections that form the
|
|
186
|
-
agent's instructions.
|
|
187
|
-
- \`call_type\` — "Incoming" or "Outgoing".
|
|
188
|
-
- \`model\` — \`{ model, temperature? }\`, e.g. \`{ "model": "gpt-4.1-mini" }\`.
|
|
189
|
-
- \`voice\` — \`{ provider, voice_id }\`. Start with an OmniDimension voice
|
|
190
|
-
(\`listVoices\` \`provider=featured\`); its \`service\` is the \`provider\`.
|
|
191
|
-
- \`transcriber\` — \`{ provider, model?, language? }\`. \`model\` (\`nova-3\` /
|
|
192
|
-
\`nova-2\`) is only needed for \`deepgram_stream\`.
|
|
193
|
-
|
|
194
|
-
## Example: Indian-English support agent (inbound)
|
|
195
|
-
|
|
196
|
-
{
|
|
197
|
-
"requestBody": {
|
|
198
|
-
"name": "Support agent",
|
|
199
|
-
"welcome_message": "Hi, thanks for calling. How can I help you today?",
|
|
200
|
-
"context_breakdown": [
|
|
201
|
-
{ "title": "Role", "body": "You are a friendly customer-support agent. Answer questions, and if you cannot help, offer to connect the caller to a human." }
|
|
202
|
-
],
|
|
203
|
-
"call_type": "Incoming",
|
|
204
|
-
"model": { "model": "gpt-4.1-mini" },
|
|
205
|
-
"voice": { "provider": "cartesia", "voice_id": "b521b304-7672-4cf9-9a34-b4eb1df1bde0" },
|
|
206
|
-
"transcriber": { "provider": "soniox" }
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
## Example: Hindi / Hinglish appointment reminder (outbound)
|
|
211
|
-
|
|
212
|
-
{
|
|
213
|
-
"requestBody": {
|
|
214
|
-
"name": "Appointment reminder",
|
|
215
|
-
"welcome_message": "Namaste, main aapke appointment ke baare mein baat karne ke liye call kar rahi hoon.",
|
|
216
|
-
"context_breakdown": [
|
|
217
|
-
{ "title": "Role", "body": "You remind customers about an upcoming appointment and confirm whether they can attend. Speak naturally in the caller's language, Hindi or English." }
|
|
218
|
-
],
|
|
219
|
-
"call_type": "Outgoing",
|
|
220
|
-
"model": { "model": "gpt-4.1-mini" },
|
|
221
|
-
"voice": { "provider": "cartesia", "voice_id": "<a Hindi voice from listVoices provider=featured>" },
|
|
222
|
-
"transcriber": { "provider": "soniox" }
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
Then give the agent a phone number and verify with a test call (the
|
|
227
|
-
\`provision_agent\` prompt walks through this end to end).
|
|
228
|
-
`;
|
|
229
|
-
|
|
230
|
-
const VERSIONING_GUIDE = `# Agent version history
|
|
231
|
-
|
|
232
|
-
A **version** is a frozen snapshot of an agent's configuration at a point in
|
|
233
|
-
time. Use it to save a known-good setup before a risky change, and to roll back
|
|
234
|
-
if a change makes the agent worse.
|
|
235
|
-
|
|
236
|
-
## The tools
|
|
237
|
-
|
|
238
|
-
- \`listAgentVersions\` { agent_id } - the timeline, newest first. Each entry has
|
|
239
|
-
a \`version_number\`, a \`kind\`, who saved it, and a \`change_summary\` (a
|
|
240
|
-
one-line "what changed in this version vs the one before it").
|
|
241
|
-
- \`createAgentVersion\` { agent_id, requestBody: { name, note? } } - save the
|
|
242
|
-
agent's CURRENT config as a named version.
|
|
243
|
-
- \`diffAgentVersion\` { agent_id, version_number, against? } - what changed (see
|
|
244
|
-
below).
|
|
245
|
-
- \`restoreAgentVersion\` { agent_id, version_number } - write a version back onto
|
|
246
|
-
the live agent.
|
|
247
|
-
- \`renameAgentVersion\` / \`deleteAgentVersion\` - tidy the timeline.
|
|
248
|
-
|
|
249
|
-
\`kind\` is \`manual\` (a person saved it), \`auto\` (saved automatically a few
|
|
250
|
-
minutes after editing settles - you do NOT trigger these), or \`system\` (a
|
|
251
|
-
safety backup taken automatically right before a restore).
|
|
252
|
-
|
|
253
|
-
## When to snapshot
|
|
254
|
-
|
|
255
|
-
Call \`createAgentVersion\` right BEFORE you make a change you might want to undo
|
|
256
|
-
(swapping the model/voice, rewriting the prompt, changing transfer rules). Give
|
|
257
|
-
it a clear \`name\` ("before pricing-flow rewrite"). You do not need to snapshot
|
|
258
|
-
after routine edits - the platform auto-saves settled states on its own.
|
|
259
|
-
|
|
260
|
-
## How to read a diff
|
|
261
|
-
|
|
262
|
-
\`diffAgentVersion\` compares two snapshots and returns \`{ changed, groups }\`,
|
|
263
|
-
where each group is an area (Settings, Prompt, Transfer rules, Post-call actions,
|
|
264
|
-
Knowledge, Integrations, Web widget, Conversation flow, Other settings) with the
|
|
265
|
-
specific old -> new changes. Pick the comparison with \`against\`:
|
|
266
|
-
|
|
267
|
-
- **omit / \`against=previous\`** (default): what changed IN this version vs the
|
|
268
|
-
one before it. This matches the \`change_summary\` in the list.
|
|
269
|
-
- **\`against=current\`**: what restoring this version WOULD change vs the agent's
|
|
270
|
-
live config right now. Read this before a restore to preview the effect.
|
|
271
|
-
- **\`against=<number>\`**: compare with a specific other version.
|
|
272
|
-
|
|
273
|
-
## How to decide and perform a restore
|
|
274
|
-
|
|
275
|
-
1. \`listAgentVersions\` and scan \`change_summary\` to find the version you want.
|
|
276
|
-
2. \`diffAgentVersion\` { version_number, against: "current" } to preview exactly
|
|
277
|
-
what restoring changes. If it says nothing meaningful changed, there is
|
|
278
|
-
nothing to restore.
|
|
279
|
-
3. \`restoreAgentVersion\` { agent_id, version_number }. This first saves the
|
|
280
|
-
current state as a \`system\` "Backup before restore" version (so the restore
|
|
281
|
-
is itself undoable), then writes the chosen config back. The response
|
|
282
|
-
includes a \`skipped\` list: references (knowledge files, integrations) that no
|
|
283
|
-
longer exist are dropped and reported rather than failing the restore.
|
|
284
|
-
4. Confirm with \`listAgentVersions\` (a new \`system\` backup should appear) or
|
|
285
|
-
\`getAgent\` to see the live config.
|
|
286
|
-
|
|
287
|
-
## Gotchas
|
|
288
|
-
|
|
289
|
-
- Version history is enabled per organization. If it is off for the caller's
|
|
290
|
-
org, these endpoints return 403 (\`feature_disabled\`).
|
|
291
|
-
- \`createAgentVersion\` refuses a no-op: if nothing changed since the latest
|
|
292
|
-
version it returns 409 (\`no_changes\`). Make (or intend) a real change first.
|
|
293
|
-
- There is a per-agent cap on versions created through the API; at the cap
|
|
294
|
-
\`createAgentVersion\` returns 409 (\`version_limit_reached\`) - delete an old
|
|
295
|
-
version to make room.
|
|
296
|
-
- \`listAgentVersions\` and \`diffAgentVersion\` are read-only and safe to call
|
|
297
|
-
freely. Restore and delete mutate the live agent - confirm intent first.
|
|
298
|
-
`;
|
|
299
|
-
|
|
300
|
-
const BULK_CAMPAIGNS_GUIDE = `# Running outbound campaigns
|
|
301
|
-
|
|
302
|
-
## Normal or dynamic
|
|
303
|
-
- One-time list: a normal campaign. Create it (as a draft), add contacts, start it.
|
|
304
|
-
- Continuous leads (form fills, CRM events): a dynamic campaign
|
|
305
|
-
(\`is_dynamic: true\`, no contact list) fed by \`addBulkCallContact\` as each
|
|
306
|
-
lead arrives. The faster a fresh lead is called, the higher the conversion.
|
|
307
|
-
|
|
308
|
-
## The two contact shapes (do not mix them)
|
|
309
|
-
- \`createBulkCall\`'s \`contact_list\` rows are FLAT:
|
|
310
|
-
\`{ "phone_number": "+1...", "any_other_key": "reaches the agent as context" }\`.
|
|
311
|
-
- \`addBulkCallContact\` / \`addBulkCallContacts\` instead take
|
|
312
|
-
\`{ to_number, custom_variables: {...}, metadata: {...} }\`. \`metadata\` is
|
|
313
|
-
bookkeeping the agent never sees.
|
|
314
|
-
- Sending \`custom_variables\` inside a \`contact_list\` row does not error; it
|
|
315
|
-
becomes one nested variable and garbles the agent's context.
|
|
316
|
-
|
|
317
|
-
## Build as a draft, then start
|
|
318
|
-
- \`createBulkCall\` { requestBody: { name, phone_number_id, save_as_draft: true, ... } }.
|
|
319
|
-
Keep the returned \`id\`. Without \`save_as_draft\` the campaign dials the
|
|
320
|
-
moment it is created.
|
|
321
|
-
- \`addBulkCallContacts\` accepts up to 1000 contacts per request. Invalid rows
|
|
322
|
-
come back in \`rejected\` with their index and reason; valid rows are still
|
|
323
|
-
added, so one bad number never costs the batch.
|
|
324
|
-
- \`startBulkCall\` launches a draft.
|
|
325
|
-
- Adding contacts is NOT dynamic-only: any campaign that is not cancelled or
|
|
326
|
-
failed accepts them, and a completed campaign wakes up and dials again.
|
|
327
|
-
|
|
328
|
-
## Size concurrency with arithmetic, not vibes
|
|
329
|
-
- Calls per hour per channel = 3600 / average call seconds (~40/hour at 90s).
|
|
330
|
-
- Channels needed = target calls per hour / per-channel rate.
|
|
331
|
-
- Example: 100,000 calls in an 8-hour day is 12,500/hour, ~315 channels.
|
|
332
|
-
The failure mode: concurrency 5 against 10,000 leads is ~200 calls/hour,
|
|
333
|
-
a 50-hour "today" campaign.
|
|
334
|
-
- \`setBulkCallConcurrency\` changes it mid-run; the org's ceiling caps it.
|
|
335
|
-
|
|
336
|
-
## Numbers and rotation
|
|
337
|
-
- One number dialing a whole campaign collects spam reports and stops being
|
|
338
|
-
answered. Rotate: \`rotation: { numbers: [{ phone_number_id, sequence }],
|
|
339
|
-
strategy: "fixed_count", calls_per_number: 50 }\` at create.
|
|
340
|
-
- \`phone_number_id\` stays required and becomes the standby; list it in
|
|
341
|
-
\`rotation.numbers\` too if it should take a share of the calls.
|
|
342
|
-
- A rotation number attached to a DIFFERENT agent is refused by name. Attach
|
|
343
|
-
it to this campaign's agent first, or leave it out.
|
|
344
|
-
- \`listBulkCallNumbers\` shows which number is dialing now;
|
|
345
|
-
\`setBulkCallNumberActive\` pauses one without losing its history (the last
|
|
346
|
-
active number of a running campaign cannot be paused).
|
|
347
|
-
- Check a new number's reputation before a campaign and watch pickup rates.
|
|
348
|
-
|
|
349
|
-
## Calling hours and the timezone trap
|
|
350
|
-
- \`setBulkCallDailyTimeControl\` sets a hard stop and an auto start; the API
|
|
351
|
-
requires both blocks together.
|
|
352
|
-
- Each block carries its own timezone (\`daily_stop_timezone\`,
|
|
353
|
-
\`daily_start_timezone\`); left out, it falls back to the campaign's
|
|
354
|
-
\`timezone\`, not the operator's. A wrong timezone dials people at 11 PM,
|
|
355
|
-
which is a compliance problem. Set both to the customers' region.
|
|
356
|
-
- The agent has its own \`timezone\` field (\`createAgent\`/\`updateAgent\`)
|
|
357
|
-
that sets the local date and time it works with during calls. Set that to
|
|
358
|
-
the customers' region too.
|
|
359
|
-
|
|
360
|
-
## Watching a campaign and reading results
|
|
361
|
-
- \`getBulkCallLiveStatus\` for progress counts while it runs.
|
|
362
|
-
- \`listBulkCallLines\` for per-contact outcomes: \`pagesize\` up to 150, follow
|
|
363
|
-
\`next_cursor\` until it comes back null, never build a cursor yourself.
|
|
364
|
-
\`include_total\` once for a header, not on every page.
|
|
365
|
-
- Rows carry \`recording_id\`, not the transcript; \`getCallLog\` serves it.
|
|
366
|
-
- \`retryBulkCall\` re-queues contacts that did not connect; it refuses a
|
|
367
|
-
campaign that is still running.
|
|
368
|
-
|
|
369
|
-
## Contact rules
|
|
370
|
-
- Numbers are E.164 with the country code. Run one campaign per country code.
|
|
371
|
-
- Dashboard CSV uploads need the phone column named exactly \`phone_number\`.
|
|
372
|
-
`;
|
|
373
|
-
|
|
374
|
-
const CARRIERS_GUIDE = `# Which carrier to buy from
|
|
375
|
-
|
|
376
|
-
A region holds one or more carriers. They do not stock the same numbers and
|
|
377
|
-
they are not interchangeable, so \`carrier\` is **required** on
|
|
378
|
-
\`searchPhoneNumbers\` and \`purchasePhoneNumber\`, in every region, however few
|
|
379
|
-
it holds.
|
|
380
|
-
|
|
381
|
-
## What each one stocks
|
|
382
|
-
|
|
383
|
-
| Region | \`carrier\` | Stocks |
|
|
384
|
-
|---|---|---|
|
|
385
|
-
| \`IN\` | \`carrier-1\` | Landline numbers, city codes 11, 12 and 80 |
|
|
386
|
-
| \`IN\` | \`carrier-2-new\` | Mobile numbers, 94 and 79 series |
|
|
387
|
-
| \`US\` | \`carrier-us\` | US local numbers, by area code |
|
|
388
|
-
|
|
389
|
-
A snapshot, not the authority. The API is: omit \`carrier\` on a call that needs
|
|
390
|
-
one and the \`409 carrier_required\` body lists that region's carriers with what
|
|
391
|
-
each stocks and whether each is taking orders. This server validates the tool
|
|
392
|
-
schema before the call leaves, so a required field cannot in fact be omitted
|
|
393
|
-
here, which is why the table exists at all. If a user names a carrier that is
|
|
394
|
-
not in it, pass it through rather than refusing: this file can be older than
|
|
395
|
-
the account.
|
|
396
|
-
|
|
397
|
-
## Rules
|
|
398
|
-
|
|
399
|
-
- **Ask, do not pick.** Landline and mobile are not substitutes, and buying
|
|
400
|
-
spends the account's balance on a rental that renews. If the user has not
|
|
401
|
-
said which they want, ask, and say what each one stocks.
|
|
402
|
-
- **Buy from the carrier you searched.** \`searchPhoneNumbers\` echoes the
|
|
403
|
-
\`carrier\` its results came from. Pass that exact value to
|
|
404
|
-
\`purchasePhoneNumber\`, or you are buying out of inventory you never looked
|
|
405
|
-
at.
|
|
406
|
-
- **Verification is per carrier.** An account verified on one carrier of a
|
|
407
|
-
region is not verified on the other, and a purchase it has not cleared fails
|
|
408
|
-
with \`409 kyc_incomplete\`. Verification is not on this surface: send the user
|
|
409
|
-
to the dashboard number shop.
|
|
410
|
-
- **A carrier can be down.** One flagged unavailable is still named in the
|
|
411
|
-
refusal, and a purchase against it answers \`422 purchase_failed\`. Sell from
|
|
412
|
-
another one meanwhile.
|
|
413
|
-
- **The name is stable across a rename**, so it is safe for a user to store.
|
|
414
|
-
`;
|
|
415
|
-
|
|
416
|
-
const WORKFLOWS_GUIDE = `# Building workflows
|
|
417
|
-
|
|
418
|
-
A workflow is a graph: one trigger node, then action and flow nodes joined by
|
|
419
|
-
edges. It runs on OmniDimension's servers each time its trigger fires.
|
|
420
|
-
|
|
421
|
-
## The tools, in the order you use them
|
|
422
|
-
|
|
423
|
-
1. \`listWorkflowNodeTypes\` (with \`q\`, e.g. "whatsapp") to find node types.
|
|
424
|
-
2. \`getWorkflowNodeType\` (\`detail: minimal\`) for the fields one type needs.
|
|
425
|
-
Ask for \`detail: full\` only when you need the examples.
|
|
426
|
-
3. \`listWorkflowFieldOptions\` for any field of type \`ref\` (a number, an
|
|
427
|
-
integration, a template, an agent). Never guess an id. If it returns
|
|
428
|
-
\`no_options\`, ask the user for the value.
|
|
429
|
-
4. \`createWorkflow\` with a \`name\`. It starts with one node, \`trigger\`. You may
|
|
430
|
-
pass a complete first \`graph\` instead, in the same shape \`getWorkflow\`
|
|
431
|
-
returns under \`draft\` (node \`config\`, edges with \`from\`, \`to\`, \`handle\`).
|
|
432
|
-
5. \`editWorkflow\` with the \`revision\` from the last read and a list of \`ops\`.
|
|
433
|
-
6. \`validateWorkflow\`, then fix what it reports with another \`editWorkflow\`.
|
|
434
|
-
7. \`testWorkflow\` only after the user agrees (see "Test runs are real").
|
|
435
|
-
8. \`publishWorkflow\`. That makes the draft live and real events run it. You do not need \`activateWorkflow\` after it.
|
|
436
|
-
|
|
437
|
-
\`getWorkflow\` with \`view: structure\` shows nodes and edges without config.
|
|
438
|
-
Use it to orient in a large workflow. Use \`view: full\` before you edit config.
|
|
439
|
-
|
|
440
|
-
## Lifecycle
|
|
441
|
-
|
|
442
|
-
- You always edit the **draft**. A published workflow is never changed in place.
|
|
443
|
-
- \`publishWorkflow\` copies the draft to the live version and leaves a fresh draft
|
|
444
|
-
for the next round of edits. It refuses while \`validateWorkflow\` has errors.
|
|
445
|
-
- \`deactivateWorkflow\` pauses the live version. \`activateWorkflow\` resumes it. Use them only to
|
|
446
|
-
pause and resume, not to go live.
|
|
447
|
-
- Every edit needs the current \`revision\`. On \`409 revision_conflict\`, someone
|
|
448
|
-
(often the user in the dashboard) saved first. Call \`getWorkflow\` and retry.
|
|
449
|
-
|
|
450
|
-
## Do not break a workflow that is already running
|
|
451
|
-
|
|
452
|
-
Most harm comes from changing a workflow the user did not ask you to touch.
|
|
453
|
-
|
|
454
|
-
- Default to creating a NEW workflow. Edit an existing one only when the user names it.
|
|
455
|
-
- Call \`getWorkflow\` first and read what it does before any edit. Keep its \`revision\`.
|
|
456
|
-
- Your edits land on the draft and change nothing live until you publish.
|
|
457
|
-
- \`publishWorkflow\` overwrites the live version that real events run. \`deactivateWorkflow\` pauses automation the user depends on. \`deleteWorkflow\` stops it for good. Before any of these on an existing workflow, tell the user exactly what will change and get a yes.
|
|
458
|
-
- Never publish, activate, deactivate, delete or test a workflow as a side effect of another task.
|
|
459
|
-
|
|
460
|
-
## Entry: the trigger
|
|
461
|
-
|
|
462
|
-
Every workflow has exactly one trigger node. Its output is the event payload,
|
|
463
|
-
which later nodes read as \`{{ context.<trigger id>.<field> }}\`.
|
|
464
|
-
|
|
465
|
-
| Trigger type | Fires when | How it is attached |
|
|
466
|
-
|---|---|---|
|
|
467
|
-
| \`trigger\` | After a call (post-call), or on a POST to the webhook URL | Post-call: the agent's post-call actions point at this workflow. Webhook: \`update_node\` the trigger with \`config: { webhook_enabled: true }\`, then \`getWorkflow\` returns \`webhook_url\` |
|
|
468
|
-
| \`whatsapp_inbound\` | A WhatsApp message arrives | Its \`phone_number_id\` |
|
|
469
|
-
| \`twilio_sms_inbound\` | An SMS arrives | Its Twilio integration |
|
|
470
|
-
| \`email_event_trigger\` | A sent email is opened, clicked, replied to, or bounces | The source workflow or campaign |
|
|
471
|
-
| \`omnidim_crm_trigger\`, \`leadsquared_trigger\`, \`shopify_trigger\`, \`instantly_event_trigger\` | An event in that system | Its integration |
|
|
472
|
-
|
|
473
|
-
\`getWorkflowNodeType\` shows each trigger's \`output_example\`. The post-call
|
|
474
|
-
trigger carries \`customer_number\`, \`call_status\`, \`summary\`, \`sentiment\`,
|
|
475
|
-
\`extracted_variables\` and the transcript.
|
|
476
|
-
|
|
477
|
-
## Connecting nodes
|
|
478
|
-
|
|
479
|
-
An edge runs from one node's **output** to the next node. Plain nodes have one
|
|
480
|
-
output, \`default\`. Branching nodes have named outputs, and you must say which.
|
|
481
|
-
\`getWorkflowNodeType\` lists each type's outputs; this table is a summary:
|
|
482
|
-
|
|
483
|
-
| Node | Outputs |
|
|
484
|
-
|---|---|
|
|
485
|
-
| \`conditional\` | \`True\`, \`False\` |
|
|
486
|
-
| \`switch_condition\` | each case \`id\`, plus \`else\` |
|
|
487
|
-
| \`time_condition\` | \`Yes\`, \`No\` |
|
|
488
|
-
| \`photo_analyzer\` | \`pass\`, \`fail\` |
|
|
489
|
-
| \`voice_ai\` | \`Completed\`, \`Not Completed\` |
|
|
490
|
-
| \`zoho_bigin\` | \`Created\`, \`Found\`, \`Ambiguous\`, \`Failed\`, \`Success\` |
|
|
491
|
-
|
|
492
|
-
- One output can feed several nodes. They all run.
|
|
493
|
-
- \`add_node\` with \`after\` and \`handle\` places and connects a node in one step.
|
|
494
|
-
- To rewire, send \`disconnect\` and \`connect\` in the same batch.
|
|
495
|
-
- Every node except notes must be reachable from the trigger.
|
|
496
|
-
|
|
497
|
-
## Exit
|
|
498
|
-
|
|
499
|
-
There is no end node. A branch ends at a node with no outgoing edge, and the
|
|
500
|
-
run finishes when every branch has ended. \`wait\`, \`wait_for_time\`, \`voice_ai\`
|
|
501
|
-
and \`send_email\` pause the run and resume it later. \`sub_workflow\` starts
|
|
502
|
-
another workflow and continues at once. The target must be published and active, or the run fails
|
|
503
|
-
with "Target workflow has no published version".
|
|
504
|
-
|
|
505
|
-
## Passing data
|
|
506
|
-
|
|
507
|
-
\`{{ context.<node id>.<field> }}\` reads an earlier node's output. The engine
|
|
508
|
-
also provides \`{{ context.webhook }}\` (the trigger payload) and
|
|
509
|
-
\`{{ context.execution_link }}\`. Only nodes that run earlier have output. A
|
|
510
|
-
reference to a later node renders empty, and \`validateWorkflow\` warns about it.
|
|
511
|
-
|
|
512
|
-
Node ids appear in these references, so pick readable ones: \`check_interest\`,
|
|
513
|
-
\`wa_followup\`, \`notify_sales\`. Use lowercase letters, digits and underscores.
|
|
514
|
-
These names are taken: \`webhook\`, \`execution_id\`, \`execution_link\`, \`get\`,
|
|
515
|
-
\`items\`, \`keys\`, \`values\`.
|
|
516
|
-
|
|
517
|
-
Id fields (a number, template, integration, agent) always hold a literal id.
|
|
518
|
-
A \`{{ }}\` template there is refused, because it could resolve to a record in
|
|
519
|
-
another workspace.
|
|
520
|
-
|
|
521
|
-
## Moving things around
|
|
522
|
-
|
|
523
|
-
- \`move_node\` sets \`{x, y}\` on the dashboard canvas.
|
|
524
|
-
- \`add_node\` without a \`position\` lands to the right of its parent, below any
|
|
525
|
-
siblings, so the canvas stays readable for the user.
|
|
526
|
-
|
|
527
|
-
## Notes
|
|
528
|
-
|
|
529
|
-
A \`notes\` node holds \`note_text\` for people reading the canvas. It is never
|
|
530
|
-
connected and never runs. Add one that says what the workflow is for, so the
|
|
531
|
-
next person to open it in the dashboard understands it.
|
|
532
|
-
|
|
533
|
-
## Ops
|
|
534
|
-
|
|
535
|
-
| Op | Fields |
|
|
536
|
-
|---|---|
|
|
537
|
-
| \`add_node\` | \`id\`, \`type\`, \`config?\`, \`label?\`, \`position?\`, \`after?\`, \`handle?\` |
|
|
538
|
-
| \`update_node\` | \`id\`, \`config\` (merged; \`null\` removes a key), \`label?\` |
|
|
539
|
-
| \`move_node\` | \`id\`, \`position {x, y}\` |
|
|
540
|
-
| \`delete_node\` | \`id\` (its edges go too) |
|
|
541
|
-
| \`connect\` | \`from\`, \`to\`, \`handle?\` (default \`default\`) |
|
|
542
|
-
| \`disconnect\` | \`from\`, \`to\`, \`handle?\` |
|
|
543
|
-
|
|
544
|
-
A batch applies completely or not at all. A failing op returns
|
|
545
|
-
\`422 invalid_op\` with its \`op_index\`.
|
|
546
|
-
|
|
547
|
-
## Credentials
|
|
548
|
-
|
|
549
|
-
Never put secrets in config when an integration exists. Pick integrations,
|
|
550
|
-
numbers and templates from \`listWorkflowFieldOptions\`. Secret fields (a Slack
|
|
551
|
-
webhook URL, API headers) read back as \`********\`. Send \`********\` back
|
|
552
|
-
unchanged and the stored value is kept. If the user has no matching
|
|
553
|
-
integration, tell them to connect one in the dashboard first.
|
|
554
|
-
|
|
555
|
-
## Test runs are real
|
|
556
|
-
|
|
557
|
-
\`testWorkflow\` runs the draft once with your \`payload\` as the trigger data.
|
|
558
|
-
**Every node runs for real**: WhatsApp messages, SMS, emails and calls go out,
|
|
559
|
-
and CRM records change. Before you call it, tell the user what will happen and
|
|
560
|
-
get a yes. Use their own phone number or email in the payload.
|
|
561
|
-
|
|
562
|
-
\`testWorkflow\` is async. It returns 202 with an \`execution_id\`. Poll \`getWorkflowExecution\`
|
|
563
|
-
until \`state\` is \`completed\`, \`failed\` or \`cancelled\`, then read each node's status, output and error.
|
|
564
|
-
|
|
565
|
-
## Errors you will see
|
|
566
|
-
|
|
567
|
-
| Error | Meaning | What to do |
|
|
568
|
-
|---|---|---|
|
|
569
|
-
| \`422 validation_failed\` with \`not_found\` | An id is not in this workspace | Pick from \`listWorkflowFieldOptions\` |
|
|
570
|
-
| \`422 validation_failed\` on publish | Missing fields, an unconnected node, a bad handle | Fix each one, then publish again |
|
|
571
|
-
| \`422 invalid_op\` | An op is malformed | Fix the op at \`op_index\` |
|
|
572
|
-
| \`409 revision_conflict\` | The draft changed since you read it | \`getWorkflow\`, then retry |
|
|
573
|
-
| \`409 no_draft\` | The workflow has no draft to edit, test or publish | \`getWorkflow\`, then make an edit to start a new draft |
|
|
574
|
-
| \`400 no_options\` | The field holds an id from another system | Ask the user for the value |
|
|
575
|
-
| \`422\` with \`templated_ref\` | An id field holds a \`{{ }}\` template | Put a literal id from \`listWorkflowFieldOptions\` |
|
|
576
|
-
|
|
577
|
-
## Worked example
|
|
578
|
-
|
|
579
|
-
"After a call, if the lead is interested, send our follow-up WhatsApp template
|
|
580
|
-
and tell #sales in Slack."
|
|
581
|
-
|
|
582
|
-
1. \`createWorkflow { name: "Interested lead follow-up" }\` gives you \`trigger\`
|
|
583
|
-
and a \`revision\`.
|
|
584
|
-
2. \`listWorkflowFieldOptions\` for \`whatsapp.phone_number_id\`, then for
|
|
585
|
-
\`whatsapp.template_id\` with \`depends\` set to that number. Confirm both with
|
|
586
|
-
the user.
|
|
587
|
-
3. One \`editWorkflow\` batch:
|
|
588
|
-
- \`add_node { id: "check_interest", type: "conditional", after: "trigger",
|
|
589
|
-
config: { conditions: [{ variable: "{{ context.trigger.extracted_variables.interested }}",
|
|
590
|
-
operator: "==", value: "yes" }] } }\`
|
|
591
|
-
- \`add_node { id: "wa_followup", type: "whatsapp", after: "check_interest",
|
|
592
|
-
handle: "True", config: { phone_number_id: <id>, message_type: "template",
|
|
593
|
-
template_id: <id>, to_number: "{{ context.trigger.customer_number }}" } }\`
|
|
594
|
-
- \`add_node { id: "notify_sales", type: "slack", after: "wa_followup",
|
|
595
|
-
config: { slack_webhook_url: "<from the user>",
|
|
596
|
-
message: "Follow-up sent to {{ context.trigger.customer_number }}" } }\`
|
|
597
|
-
- \`add_node { id: "about", type: "notes", config: { note_text: "Follows up
|
|
598
|
-
interested leads after a call." } }\`
|
|
599
|
-
4. \`validateWorkflow\`, fix anything reported, then \`publishWorkflow\`.
|
|
600
|
-
5. Tell the user to point the agent's post-call action at this workflow.
|
|
601
|
-
`;
|
|
17
|
+
const PLAYBOOKS: PlaybookDef[] = generated.playbooks;
|
|
602
18
|
|
|
603
19
|
const RESOURCES: ResourceDef[] = [
|
|
604
|
-
|
|
605
|
-
uri: "omnidim://guide/routing",
|
|
606
|
-
name: "OmniDimension routing guide",
|
|
607
|
-
description: "Which tool to call when, ID flow between calls, and the non-obvious rules proven against the live API.",
|
|
608
|
-
mimeType: "text/markdown",
|
|
609
|
-
text: ROUTING_GUIDE,
|
|
610
|
-
},
|
|
611
|
-
{
|
|
612
|
-
uri: "omnidim://reference/recommended-stack",
|
|
613
|
-
name: "Recommended provider stacks by language",
|
|
614
|
-
description: "Which transcriber (STT), voice (TTS), and language model to choose, grouped by the caller's language. Reflects what works in production.",
|
|
615
|
-
mimeType: "text/markdown",
|
|
616
|
-
text: RECOMMENDED_STACK,
|
|
617
|
-
},
|
|
618
|
-
{
|
|
619
|
-
uri: "omnidim://reference/voices",
|
|
620
|
-
name: "Choosing a voice",
|
|
621
|
-
description: "Start with OmniDimension voices (listVoices provider=featured), our most recommended; how to save one, and what to pick when none fits.",
|
|
622
|
-
mimeType: "text/markdown",
|
|
623
|
-
text: VOICES_GUIDE,
|
|
624
|
-
},
|
|
625
|
-
{
|
|
626
|
-
uri: "omnidim://reference/carriers",
|
|
627
|
-
name: "Which carrier to buy from",
|
|
628
|
-
description: "What each region's carriers stock, why `carrier` is required on search and purchase, and the ask-do-not-pick rule. The only place an agent on this server can learn a carrier value.",
|
|
629
|
-
mimeType: "text/markdown",
|
|
630
|
-
text: CARRIERS_GUIDE,
|
|
631
|
-
},
|
|
632
|
-
{
|
|
633
|
-
uri: "omnidim://reference/agent-config",
|
|
634
|
-
name: "Building an agent with createAgent",
|
|
635
|
-
description: "The createAgent field shape with two complete, copy-ready example configurations (Indian-English support, Hindi/Hinglish reminder).",
|
|
636
|
-
mimeType: "text/markdown",
|
|
637
|
-
text: AGENT_CONFIG_GUIDE,
|
|
638
|
-
},
|
|
639
|
-
{
|
|
640
|
-
uri: "omnidim://guide/bulk-campaigns",
|
|
641
|
-
name: "Running outbound campaigns",
|
|
642
|
-
description: "The campaign lifecycle end to end: draft, batch contacts (two contact shapes, do not mix), rotation, concurrency arithmetic, the agent-timezone trap, cursor-paged results.",
|
|
643
|
-
mimeType: "text/markdown",
|
|
644
|
-
text: BULK_CAMPAIGNS_GUIDE,
|
|
645
|
-
},
|
|
646
|
-
{
|
|
647
|
-
uri: "omnidim://guide/agent-versioning",
|
|
648
|
-
name: "Agent version history",
|
|
649
|
-
description: "How to save, diff, and restore agent config snapshots: which tool to call, what the diff `against` modes mean, how to decide on a restore, and the 403/409 gotchas.",
|
|
650
|
-
mimeType: "text/markdown",
|
|
651
|
-
text: VERSIONING_GUIDE,
|
|
652
|
-
},
|
|
653
|
-
{
|
|
654
|
-
uri: "omnidim://guide/workflows",
|
|
655
|
-
name: "Building workflows",
|
|
656
|
-
description: "How to build a workflow end to end: the tool order, lifecycle, triggers (entry), outputs and edges, exit, passing data, moving nodes, notes, ops, credentials, real test runs, errors, and a worked example.",
|
|
657
|
-
mimeType: "text/markdown",
|
|
658
|
-
text: WORKFLOWS_GUIDE,
|
|
659
|
-
},
|
|
20
|
+
...generated.guides,
|
|
660
21
|
{
|
|
661
22
|
uri: WORKFLOW_CANVAS_URI,
|
|
662
23
|
name: "Workflow canvas",
|
|
@@ -666,221 +27,13 @@ const RESOURCES: ResourceDef[] = [
|
|
|
666
27
|
},
|
|
667
28
|
];
|
|
668
29
|
|
|
669
|
-
const PROMPTS: PromptDef[] = [
|
|
670
|
-
{
|
|
671
|
-
name: "build_workflow",
|
|
672
|
-
description: "Build an automation workflow from a plain-language goal: pick the trigger and nodes, wire them, validate, test with the user's consent, then publish.",
|
|
673
|
-
arguments: [
|
|
674
|
-
{ name: "goal", description: "What should happen and when, in plain language (e.g. 'after a call, WhatsApp interested leads our follow-up template').", required: true },
|
|
675
|
-
],
|
|
676
|
-
build: (a) => {
|
|
677
|
-
const goal = a.goal || "(describe what should happen, and when)";
|
|
678
|
-
return `Build an OmniDimension workflow for this goal:
|
|
679
|
-
|
|
680
|
-
"${goal}"
|
|
681
|
-
|
|
682
|
-
Read the \`omnidim://guide/workflows\` resource first. It explains triggers, outputs, ops and errors.
|
|
683
|
-
|
|
684
|
-
1. Pick the trigger, then find each node type with \`listWorkflowNodeTypes\` and read its fields with
|
|
685
|
-
\`getWorkflowNodeType\`.
|
|
686
|
-
2. For every field that takes an id (a number, template, integration or agent), list real choices with
|
|
687
|
-
\`listWorkflowFieldOptions\` and confirm them with the user. Never guess an id.
|
|
688
|
-
3. \`createWorkflow\`, then build it with \`editWorkflow\` batches. Use readable node ids, wire branches with
|
|
689
|
-
\`after\` and \`handle\`, and add a notes node that says what the workflow is for.
|
|
690
|
-
4. \`validateWorkflow\` and fix every error.
|
|
691
|
-
5. A test run happens for real: messages, calls and CRM writes go out. Only call \`testWorkflow\` after the
|
|
692
|
-
user says yes, with their own phone number or email in the payload. Then poll \`getWorkflowExecution\` until \`state\` is \`completed\`, \`failed\` or \`cancelled\`.
|
|
693
|
-
6. Show the user the finished flow, then \`publishWorkflow\` when they approve.
|
|
694
|
-
7. Prefer creating a new workflow. Never publish, activate, deactivate, delete or test an existing workflow
|
|
695
|
-
without the user's explicit yes, after reading it first.
|
|
696
|
-
`;
|
|
697
|
-
},
|
|
698
|
-
},
|
|
699
|
-
{
|
|
700
|
-
name: "provision_agent",
|
|
701
|
-
description: "Create a working voice agent end to end: configure it, give it a number, and verify it can place a call and speak.",
|
|
702
|
-
arguments: [
|
|
703
|
-
{ name: "purpose", description: "What the agent should do, in plain language (e.g. 'book dental appointments and answer FAQs').", required: true },
|
|
704
|
-
{ name: "voice_id", description: "Optional voice name from listVoices. If omitted, use a known premade voice and confirm audio on the test call.", required: false },
|
|
705
|
-
{ name: "test_number", description: "Optional E.164 number to place a verification call to after setup (e.g. +15551234567).", required: false },
|
|
706
|
-
],
|
|
707
|
-
build: (a) => {
|
|
708
|
-
const purpose = a.purpose || "(describe the agent's job)";
|
|
709
|
-
const voiceLine = a.voice_id
|
|
710
|
-
? `Use voice_id "${a.voice_id}" (the \`name\` from listVoices).`
|
|
711
|
-
: `Start with the OmniDimension voices, our most recommended: call \`listVoices\` with \`provider=featured\` and pick the first one that speaks the caller's language. Use its \`name\` as voice_id and its \`service\` (\`cartesia\`) as the voice provider. Verify audio on the test call.`;
|
|
712
|
-
const testLine = a.test_number
|
|
713
|
-
? `5. Place a verification call with \`dispatchCall\` { requestBody: { agent_id, to_number: "${a.test_number}" } } (omit from_number_id to use the default outbound number). Capture the returned requestId.
|
|
714
|
-
6. Poll \`listCallLogs\` { pagesize: 1 } until a new row appears for ${a.test_number}, then \`getCallLog\` on its id. The call is verified ONLY if \`call_conversation\` is non-empty (the agent actually spoke). A successful dispatch response alone is not proof.`
|
|
715
|
-
: `5. (No test_number given.) Tell the user the agent is configured and offer to place a verification call to a number they control. Until a call log shows a non-empty \`call_conversation\`, do not claim the agent works end to end.`;
|
|
716
|
-
return `Provision a working OmniDimension voice agent for this purpose:
|
|
717
|
-
|
|
718
|
-
"${purpose}"
|
|
719
|
-
|
|
720
|
-
Follow these steps in order. Each write tool wraps its payload in \`requestBody\`.
|
|
721
|
-
|
|
722
|
-
1. Voice + models: ${voiceLine} A good default model is gpt-4.1-mini.
|
|
723
|
-
2. Create the agent with \`createAgent\`:
|
|
724
|
-
{
|
|
725
|
-
"requestBody": {
|
|
726
|
-
"name": "<short name>",
|
|
727
|
-
"welcome_message": "<first line the agent speaks>",
|
|
728
|
-
"context_breakdown": [ { "title": "Purpose", "body": "<the agent's instructions, derived from the purpose above>" } ],
|
|
729
|
-
"call_type": "Outgoing",
|
|
730
|
-
"model": { "model": "gpt-4.1-mini", "temperature": 0.5 },
|
|
731
|
-
"voice": { "provider": "cartesia", "voice_id": "<name from listVoices provider=featured>" },
|
|
732
|
-
"transcriber": { "provider": "soniox" }
|
|
733
|
-
}
|
|
734
|
-
}
|
|
735
|
-
Capture the returned \`id\` as agent_id. (\`status\` is always "Completed"; it is not a build signal.)
|
|
736
|
-
3. Give it a number: \`listPhoneNumbers\` -> pick a number \`id\`. Attach it with
|
|
737
|
-
\`attachPhoneNumber\` { requestBody: { phone_number_id, agent_id } }. If no
|
|
738
|
-
number exists, either buy one (\`searchPhoneNumbers\` { region } then
|
|
739
|
-
\`purchasePhoneNumber\`, which charges the account, so confirm with the user
|
|
740
|
-
first and never pick for them) or import one you already own
|
|
741
|
-
(importTwilioNumber / importExotelNumber / importSipTrunk).
|
|
742
|
-
4. Optional knowledge base: \`uploadKnowledgeBaseFile\` then \`attachKnowledgeBaseFiles\` { requestBody: { file_ids, agent_id } }.
|
|
743
|
-
${testLine}
|
|
744
|
-
|
|
745
|
-
Throughout: phone numbers are E.164 with a leading \`+\`. See the \`omnidim://guide/routing\` resource for the full gotcha list.`;
|
|
746
|
-
},
|
|
747
|
-
},
|
|
748
|
-
{
|
|
749
|
-
name: "audit_calls",
|
|
750
|
-
description: "Review and summarize call logs: find failures, inspect transcripts and sentiment, or audit a specific agent or campaign.",
|
|
751
|
-
arguments: [
|
|
752
|
-
{ name: "focus", description: "What to look into, in plain language (e.g. 'why are calls failing', 'summarize today's calls for agent 123').", required: true },
|
|
753
|
-
{ name: "agent_id", description: "Optional agent id to filter to (the listAgents / createAgent id).", required: false },
|
|
754
|
-
{ name: "call_status", description: "Optional status filter. Note the enum uses a hyphen for no-answer: completed | busy | failed | no-answer.", required: false },
|
|
755
|
-
],
|
|
756
|
-
build: (a) => {
|
|
757
|
-
const focus = a.focus || "(describe what to look into)";
|
|
758
|
-
const filters: string[] = ["\"pagesize\": 3"];
|
|
759
|
-
if (a.agent_id) filters.push(`"agentid": ${a.agent_id}`);
|
|
760
|
-
if (a.call_status) filters.push(`"call_status": "${a.call_status}"`);
|
|
761
|
-
return `Audit OmniDimension call logs for this question:
|
|
762
|
-
|
|
763
|
-
"${focus}"
|
|
764
|
-
|
|
765
|
-
1. List recent calls with \`listCallLogs\` { ${filters.join(", ")} }.
|
|
766
|
-
- Keep \`pagesize\` small (1-3). Each row is large and the response is
|
|
767
|
-
trimmed past a size cap, so a big page comes back truncated and unparseable.
|
|
768
|
-
- Filters: \`agentid\` (note: no underscore) for one agent, \`bulk_call_id\`
|
|
769
|
-
for one campaign, \`call_status\` for triage. The status enum uses a hyphen:
|
|
770
|
-
completed | busy | failed | no-answer.
|
|
771
|
-
- Each row carries \`id\`, \`call_status\`, \`sentiment_score\`, cost, and a
|
|
772
|
-
summary. There is no date-range filter; filter by \`time_of_call\`
|
|
773
|
-
(MM/DD/YYYY HH:MM:SS) yourself if needed.
|
|
774
|
-
2. For each call of interest, call \`getCallLog\` { call_log_id: <row id> } for
|
|
775
|
-
the full transcript (\`call_conversation\`), \`interactions\`,
|
|
776
|
-
\`extracted_variables\`, \`recording_url\`, and per-turn latency/cost.
|
|
777
|
-
Note: an empty \`call_conversation\` means the agent never spoke (a silent
|
|
778
|
-
call), not that the call is missing.
|
|
779
|
-
3. Summarize the answer to "${focus}": group by status or agent, surface failure
|
|
780
|
-
reasons and low-sentiment calls, and cite specific \`call_log_id\`s.
|
|
781
|
-
|
|
782
|
-
See the \`omnidim://guide/routing\` resource for the full gotcha list.`;
|
|
783
|
-
},
|
|
784
|
-
},
|
|
785
|
-
{
|
|
786
|
-
name: "build_outbound_campaign",
|
|
787
|
-
description: "Set up and launch a bulk-call campaign safely: draft it, batch the contacts in, size concurrency from the numbers, check calling hours, then start and watch it.",
|
|
788
|
-
arguments: [
|
|
789
|
-
{ name: "goal", description: "Who to call and why, in plain language (e.g. 'call 8,000 renewal leads today between 9 and 6 Eastern').", required: true },
|
|
790
|
-
{ name: "agent_id", description: "Optional agent to run the calls (the listAgents id). If omitted, the agent attached to the chosen number runs them.", required: false },
|
|
791
|
-
{ name: "phone_number_id", description: "Optional number id to dial from (from listPhoneNumbers). If omitted, pick with the user from their numbers.", required: false },
|
|
792
|
-
],
|
|
793
|
-
build: (a) => {
|
|
794
|
-
const goal = a.goal || "(describe who to call and why)";
|
|
795
|
-
const numberLine = a.phone_number_id
|
|
796
|
-
? `Use phone_number_id "${a.phone_number_id}".`
|
|
797
|
-
: `Call \`listPhoneNumbers\` and pick the dialing number WITH the user; never pick silently.`;
|
|
798
|
-
const agentLine = a.agent_id
|
|
799
|
-
? `Pass bot_id ${a.agent_id} so this agent runs the calls even if the number has a different or no agent attached.`
|
|
800
|
-
: `If the number has an agent attached it runs the calls; otherwise pass a \`bot_id\`.`;
|
|
801
|
-
return `Set up and launch an OmniDimension bulk-call campaign for this goal:
|
|
802
|
-
|
|
803
|
-
"${goal}"
|
|
804
|
-
|
|
805
|
-
Follow these steps in order. Each write tool wraps its payload in \`requestBody\`.
|
|
806
|
-
A campaign dials real people and spends real money: confirm the plan with the
|
|
807
|
-
user before \`startBulkCall\`, and never start one they have not approved.
|
|
808
|
-
|
|
809
|
-
1. Decide the shape: a one-time list is a normal campaign; continuously arriving
|
|
810
|
-
leads mean a dynamic campaign (\`is_dynamic: true\`) fed by
|
|
811
|
-
\`addBulkCallContact\` instead of steps 3 and 5.
|
|
812
|
-
2. Number and agent: ${numberLine} ${agentLine}
|
|
813
|
-
3. Create it as a draft with \`createBulkCall\`
|
|
814
|
-
{ requestBody: { name, phone_number_id, save_as_draft: true, concurrent_call_limit: <sized below> } }.
|
|
815
|
-
Add \`rotation\` when dialing from several numbers (see the bulk-campaigns
|
|
816
|
-
resource for the shape). Keep the returned \`id\`.
|
|
817
|
-
4. Size concurrency from the goal's numbers, not a guess: per channel,
|
|
818
|
-
3600 / average call seconds gives calls per hour (~40 at 90s); divide the
|
|
819
|
-
target hourly rate by that. Show the arithmetic to the user.
|
|
820
|
-
5. Add contacts with \`addBulkCallContacts\` in batches of up to 1000:
|
|
821
|
-
{ requestBody: { contacts: [{ to_number: "+1...", custom_variables: {...} }] } }.
|
|
822
|
-
This shape differs from create's contact_list on purpose; do not mix them.
|
|
823
|
-
Report anything that comes back in \`rejected\` with its row index.
|
|
824
|
-
6. Calling hours: if the goal names a time window, set it with
|
|
825
|
-
\`setBulkCallDailyTimeControl\` (both the stop and start blocks are required)
|
|
826
|
-
and pass \`daily_stop_timezone\`/\`daily_start_timezone\` for the customers'
|
|
827
|
-
region; left out they fall back to the campaign's timezone, and a mismatch
|
|
828
|
-
dials people at night. Also set the agent's own \`timezone\` field
|
|
829
|
-
(\`updateAgent\`) so it works with the customers' local time on calls.
|
|
830
|
-
7. Show the user the plan (campaign id, contact count, concurrency, window,
|
|
831
|
-
rotation) and get their explicit go-ahead. Then \`startBulkCall\`.
|
|
832
|
-
8. Watch it: \`getBulkCallLiveStatus\` for progress. When it finishes, read
|
|
833
|
-
per-contact outcomes with \`listBulkCallLines\` (follow \`next_cursor\` until
|
|
834
|
-
null) and offer \`retryBulkCall\` for contacts that did not connect.
|
|
835
|
-
|
|
836
|
-
See the \`omnidim://guide/bulk-campaigns\` resource for the full rules and
|
|
837
|
-
failure modes.`;
|
|
838
|
-
},
|
|
839
|
-
},
|
|
840
|
-
{
|
|
841
|
-
name: "restore_agent_version",
|
|
842
|
-
description: "Safely roll an agent back to an earlier saved version: find the right snapshot, preview exactly what restoring changes, then restore.",
|
|
843
|
-
arguments: [
|
|
844
|
-
{ name: "agent_id", description: "The agent to roll back (the listAgents / createAgent id).", required: true },
|
|
845
|
-
{ name: "goal", description: "What you want to get back to, in plain language (e.g. 'the version before I broke the transfer flow').", required: false },
|
|
846
|
-
],
|
|
847
|
-
build: (a) => {
|
|
848
|
-
const agentId = a.agent_id || "<agent_id>";
|
|
849
|
-
const goal = a.goal || "(describe which earlier state you want back)";
|
|
850
|
-
return `Roll agent ${agentId} back to an earlier version.
|
|
851
|
-
|
|
852
|
-
Goal: "${goal}"
|
|
853
|
-
|
|
854
|
-
Follow these steps in order. Do NOT restore blindly, preview first.
|
|
855
|
-
|
|
856
|
-
1. \`listAgentVersions\` { agent_id: ${agentId} }. Versions come newest first;
|
|
857
|
-
each has a \`version_number\`, \`kind\` (manual / auto / system), who saved it,
|
|
858
|
-
when, and a \`change_summary\` (what changed in that version). Use the names,
|
|
859
|
-
timestamps, and change summaries to find the one that matches the goal above.
|
|
860
|
-
If the feature is off for this org these calls return 403 (feature_disabled);
|
|
861
|
-
report that and stop.
|
|
862
|
-
2. Preview the effect: \`diffAgentVersion\` { agent_id: ${agentId}, version_number: <chosen>, against: "current" }.
|
|
863
|
-
This shows exactly what restoring that version WOULD change vs the agent's
|
|
864
|
-
live config, grouped by area (Settings, Prompt, Transfer rules, etc.). If it
|
|
865
|
-
reports no meaningful change, tell the user there is nothing to restore and
|
|
866
|
-
stop. Show the user this preview and confirm before the next step.
|
|
867
|
-
3. Restore: \`restoreAgentVersion\` { agent_id: ${agentId}, version_number: <chosen> }.
|
|
868
|
-
This automatically saves the current state as a "Backup before restore"
|
|
869
|
-
version first (so the restore is itself undoable), then writes the chosen
|
|
870
|
-
config back. Check the response's \`skipped\` list: knowledge files or
|
|
871
|
-
integrations that no longer exist are dropped and reported, not restored.
|
|
872
|
-
4. Confirm: \`listAgentVersions\` again (a new system "Backup before restore"
|
|
873
|
-
entry should be at the top) and tell the user they can undo by restoring it.
|
|
874
|
-
|
|
875
|
-
See the \`omnidim://guide/agent-versioning\` resource for the full tool list and
|
|
876
|
-
the diff \`against\` modes.`;
|
|
877
|
-
},
|
|
878
|
-
},
|
|
879
|
-
];
|
|
880
|
-
|
|
881
30
|
export function getPromptText(name: string, args: Record<string, string> = {}): string | null {
|
|
882
|
-
const p =
|
|
883
|
-
|
|
31
|
+
const p = PLAYBOOKS.find((x) => x.name === name);
|
|
32
|
+
if (!p) return null;
|
|
33
|
+
const given = p.arguments.map((a) => a.name).filter((a) => args[a]).sort();
|
|
34
|
+
const variant = p.variants.find((v) => v.given.join() === given.join());
|
|
35
|
+
if (!variant) return null;
|
|
36
|
+
return given.reduce((text, a) => text.replaceAll(`\u27e6${a}\u27e7`, () => args[a]), variant.text);
|
|
884
37
|
}
|
|
885
38
|
function findResource(uri: string): ResourceDef | undefined {
|
|
886
39
|
const current = uri === LEGACY_CANVAS_URI ? WORKFLOW_CANVAS_URI : uri;
|
|
@@ -889,23 +42,60 @@ function findResource(uri: string): ResourceDef | undefined {
|
|
|
889
42
|
export function getResourceText(uri: string): string | null {
|
|
890
43
|
return findResource(uri)?.text ?? null;
|
|
891
44
|
}
|
|
892
|
-
export const PROMPT_NAMES =
|
|
45
|
+
export const PROMPT_NAMES = PLAYBOOKS.map((p) => p.name);
|
|
893
46
|
export const RESOURCE_URIS = RESOURCES.map((r) => r.uri);
|
|
47
|
+
export const GUIDE_NAMES = [...PROMPT_NAMES, ...generated.guides.map((g) => g.uri)];
|
|
894
48
|
export function listResources(): Omit<ResourceDef, "text">[] {
|
|
895
49
|
return RESOURCES.map(({ uri, name, description, mimeType }) => ({ uri, name, description, mimeType }));
|
|
896
50
|
}
|
|
897
51
|
|
|
52
|
+
const READ_GUIDE_TOOL = {
|
|
53
|
+
name: "readGuide",
|
|
54
|
+
description:
|
|
55
|
+
"Read an OmniDimension playbook or guide: the steps the team follows to design, build, change, " +
|
|
56
|
+
"test and roll back agents, run campaigns, build workflows and review calls. Call it before that " +
|
|
57
|
+
"work and follow its steps.\n\n(Tags: Docs)",
|
|
58
|
+
inputSchema: {
|
|
59
|
+
type: "object",
|
|
60
|
+
properties: { name: { type: "string", enum: GUIDE_NAMES, description: "A playbook name or a guide URI." } },
|
|
61
|
+
required: ["name"],
|
|
62
|
+
},
|
|
63
|
+
annotations: { readOnlyHint: true },
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export const READ_GUIDE_INSTRUCTION =
|
|
67
|
+
"Before you design, build or change an agent, launch a call campaign, build a workflow, review calls or " +
|
|
68
|
+
"roll an agent back, call `readGuide` with the matching playbook (" + PROMPT_NAMES.join(", ") + ") and " +
|
|
69
|
+
"follow its steps. If you are unsure which tool fits, read `omnidim://guide/routing` with `readGuide`.";
|
|
70
|
+
|
|
71
|
+
export function isGuideTool(name: string): boolean {
|
|
72
|
+
return name === READ_GUIDE_TOOL.name;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export function addGuideTool(map: Map<string, any>): void {
|
|
76
|
+
map.set(READ_GUIDE_TOOL.name, { ...READ_GUIDE_TOOL, method: "get", pathTemplate: "", executionParameters: [], securityRequirements: [] });
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export function callGuideTool(args: Record<string, unknown>): { content: { type: "text"; text: string }[]; isError?: boolean } {
|
|
80
|
+
const name = String(args.name ?? "");
|
|
81
|
+
const text = getPromptText(name) ?? (GUIDE_NAMES.includes(name) ? getResourceText(name) : null);
|
|
82
|
+
if (text === null) {
|
|
83
|
+
return { content: [{ type: "text", text: `readGuide needs a name from: ${GUIDE_NAMES.join(", ")}` }], isError: true };
|
|
84
|
+
}
|
|
85
|
+
return { content: [{ type: "text", text }] };
|
|
86
|
+
}
|
|
87
|
+
|
|
898
88
|
export function registerProcedures(server: Server): void {
|
|
899
89
|
server.setRequestHandler(ListPromptsRequestSchema, async () => ({
|
|
900
|
-
prompts:
|
|
90
|
+
prompts: PLAYBOOKS.map(({ name, description, arguments: args }) => ({ name, description, arguments: args })),
|
|
901
91
|
}));
|
|
902
92
|
server.setRequestHandler(GetPromptRequestSchema, async (request) => {
|
|
903
|
-
const p =
|
|
93
|
+
const p = PLAYBOOKS.find((x) => x.name === request.params.name);
|
|
904
94
|
if (!p) throw new Error(`Unknown prompt: ${request.params.name}`);
|
|
905
95
|
const args = (request.params.arguments ?? {}) as Record<string, string>;
|
|
906
96
|
return {
|
|
907
97
|
description: p.description,
|
|
908
|
-
messages: [{ role: "user", content: { type: "text", text: p.
|
|
98
|
+
messages: [{ role: "user", content: { type: "text", text: getPromptText(p.name, args) ?? "" } }],
|
|
909
99
|
};
|
|
910
100
|
});
|
|
911
101
|
server.setRequestHandler(ListResourcesRequestSchema, async () => ({
|