@omnidim-ai/mcp-server 0.13.1 → 0.14.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/src/procedures.ts CHANGED
@@ -386,6 +386,193 @@ the account.
386
386
  - **The name is stable across a rename**, so it is safe for a user to store.
387
387
  `;
388
388
 
389
+ const WORKFLOWS_GUIDE = `# Building workflows
390
+
391
+ A workflow is a graph: one trigger node, then action and flow nodes joined by
392
+ edges. It runs on OmniDimension's servers each time its trigger fires.
393
+
394
+ ## The tools, in the order you use them
395
+
396
+ 1. \`listWorkflowNodeTypes\` (with \`q\`, e.g. "whatsapp") to find node types.
397
+ 2. \`getWorkflowNodeType\` (\`detail: minimal\`) for the fields one type needs.
398
+ Ask for \`detail: full\` only when you need the examples.
399
+ 3. \`listWorkflowFieldOptions\` for any field of type \`ref\` (a number, an
400
+ integration, a template, an agent). Never guess an id. If it returns
401
+ \`no_options\`, ask the user for the value.
402
+ 4. \`createWorkflow\` with a \`name\`. It starts with one node, \`trigger\`. You may
403
+ pass a complete first \`graph\` instead, in the same shape \`getWorkflow\`
404
+ returns under \`draft\` (node \`config\`, edges with \`from\`, \`to\`, \`handle\`).
405
+ 5. \`editWorkflow\` with the \`revision\` from the last read and a list of \`ops\`.
406
+ 6. \`validateWorkflow\`, then fix what it reports with another \`editWorkflow\`.
407
+ 7. \`testWorkflow\` only after the user agrees (see "Test runs are real").
408
+ 8. \`publishWorkflow\`. That makes the draft live and real events run it. You do not need \`activateWorkflow\` after it.
409
+
410
+ \`getWorkflow\` with \`view: structure\` shows nodes and edges without config.
411
+ Use it to orient in a large workflow. Use \`view: full\` before you edit config.
412
+
413
+ ## Lifecycle
414
+
415
+ - You always edit the **draft**. A published workflow is never changed in place.
416
+ - \`publishWorkflow\` copies the draft to the live version and leaves a fresh draft
417
+ for the next round of edits. It refuses while \`validateWorkflow\` has errors.
418
+ - \`deactivateWorkflow\` pauses the live version. \`activateWorkflow\` resumes it. Use them only to
419
+ pause and resume, not to go live.
420
+ - Every edit needs the current \`revision\`. On \`409 revision_conflict\`, someone
421
+ (often the user in the dashboard) saved first. Call \`getWorkflow\` and retry.
422
+
423
+ ## Do not break a workflow that is already running
424
+
425
+ Most harm comes from changing a workflow the user did not ask you to touch.
426
+
427
+ - Default to creating a NEW workflow. Edit an existing one only when the user names it.
428
+ - Call \`getWorkflow\` first and read what it does before any edit. Keep its \`revision\`.
429
+ - Your edits land on the draft and change nothing live until you publish.
430
+ - \`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.
431
+ - Never publish, activate, deactivate, delete or test a workflow as a side effect of another task.
432
+
433
+ ## Entry: the trigger
434
+
435
+ Every workflow has exactly one trigger node. Its output is the event payload,
436
+ which later nodes read as \`{{ context.<trigger id>.<field> }}\`.
437
+
438
+ | Trigger type | Fires when | How it is attached |
439
+ |---|---|---|
440
+ | \`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\` |
441
+ | \`whatsapp_inbound\` | A WhatsApp message arrives | Its \`phone_number_id\` |
442
+ | \`twilio_sms_inbound\` | An SMS arrives | Its Twilio integration |
443
+ | \`email_event_trigger\` | A sent email is opened, clicked, replied to, or bounces | The source workflow or campaign |
444
+ | \`omnidim_crm_trigger\`, \`leadsquared_trigger\`, \`shopify_trigger\`, \`instantly_event_trigger\` | An event in that system | Its integration |
445
+
446
+ \`getWorkflowNodeType\` shows each trigger's \`output_example\`. The post-call
447
+ trigger carries \`customer_number\`, \`call_status\`, \`summary\`, \`sentiment\`,
448
+ \`extracted_variables\` and the transcript.
449
+
450
+ ## Connecting nodes
451
+
452
+ An edge runs from one node's **output** to the next node. Plain nodes have one
453
+ output, \`default\`. Branching nodes have named outputs, and you must say which.
454
+ \`getWorkflowNodeType\` lists each type's outputs; this table is a summary:
455
+
456
+ | Node | Outputs |
457
+ |---|---|
458
+ | \`conditional\` | \`True\`, \`False\` |
459
+ | \`switch_condition\` | each case \`id\`, plus \`else\` |
460
+ | \`time_condition\` | \`Yes\`, \`No\` |
461
+ | \`photo_analyzer\` | \`pass\`, \`fail\` |
462
+ | \`voice_ai\` | \`Completed\`, \`Not Completed\` |
463
+ | \`zoho_bigin\` | \`Created\`, \`Found\`, \`Ambiguous\`, \`Failed\`, \`Success\` |
464
+
465
+ - One output can feed several nodes. They all run.
466
+ - \`add_node\` with \`after\` and \`handle\` places and connects a node in one step.
467
+ - To rewire, send \`disconnect\` and \`connect\` in the same batch.
468
+ - Every node except notes must be reachable from the trigger.
469
+
470
+ ## Exit
471
+
472
+ There is no end node. A branch ends at a node with no outgoing edge, and the
473
+ run finishes when every branch has ended. \`wait\`, \`wait_for_time\`, \`voice_ai\`
474
+ and \`send_email\` pause the run and resume it later. \`sub_workflow\` starts
475
+ another workflow and continues at once. The target must be published and active, or the run fails
476
+ with "Target workflow has no published version".
477
+
478
+ ## Passing data
479
+
480
+ \`{{ context.<node id>.<field> }}\` reads an earlier node's output. The engine
481
+ also provides \`{{ context.webhook }}\` (the trigger payload) and
482
+ \`{{ context.execution_link }}\`. Only nodes that run earlier have output. A
483
+ reference to a later node renders empty, and \`validateWorkflow\` warns about it.
484
+
485
+ Node ids appear in these references, so pick readable ones: \`check_interest\`,
486
+ \`wa_followup\`, \`notify_sales\`. Use lowercase letters, digits and underscores.
487
+ These names are taken: \`webhook\`, \`execution_id\`, \`execution_link\`, \`get\`,
488
+ \`items\`, \`keys\`, \`values\`.
489
+
490
+ Id fields (a number, template, integration, agent) always hold a literal id.
491
+ A \`{{ }}\` template there is refused, because it could resolve to a record in
492
+ another workspace.
493
+
494
+ ## Moving things around
495
+
496
+ - \`move_node\` sets \`{x, y}\` on the dashboard canvas.
497
+ - \`add_node\` without a \`position\` lands to the right of its parent, below any
498
+ siblings, so the canvas stays readable for the user.
499
+
500
+ ## Notes
501
+
502
+ A \`notes\` node holds \`note_text\` for people reading the canvas. It is never
503
+ connected and never runs. Add one that says what the workflow is for, so the
504
+ next person to open it in the dashboard understands it.
505
+
506
+ ## Ops
507
+
508
+ | Op | Fields |
509
+ |---|---|
510
+ | \`add_node\` | \`id\`, \`type\`, \`config?\`, \`label?\`, \`position?\`, \`after?\`, \`handle?\` |
511
+ | \`update_node\` | \`id\`, \`config\` (merged; \`null\` removes a key), \`label?\` |
512
+ | \`move_node\` | \`id\`, \`position {x, y}\` |
513
+ | \`delete_node\` | \`id\` (its edges go too) |
514
+ | \`connect\` | \`from\`, \`to\`, \`handle?\` (default \`default\`) |
515
+ | \`disconnect\` | \`from\`, \`to\`, \`handle?\` |
516
+
517
+ A batch applies completely or not at all. A failing op returns
518
+ \`422 invalid_op\` with its \`op_index\`.
519
+
520
+ ## Credentials
521
+
522
+ Never put secrets in config when an integration exists. Pick integrations,
523
+ numbers and templates from \`listWorkflowFieldOptions\`. Secret fields (a Slack
524
+ webhook URL, API headers) read back as \`********\`. Send \`********\` back
525
+ unchanged and the stored value is kept. If the user has no matching
526
+ integration, tell them to connect one in the dashboard first.
527
+
528
+ ## Test runs are real
529
+
530
+ \`testWorkflow\` runs the draft once with your \`payload\` as the trigger data.
531
+ **Every node runs for real**: WhatsApp messages, SMS, emails and calls go out,
532
+ and CRM records change. Before you call it, tell the user what will happen and
533
+ get a yes. Use their own phone number or email in the payload.
534
+
535
+ \`testWorkflow\` is async. It returns 202 with an \`execution_id\`. Poll \`getWorkflowExecution\`
536
+ until \`state\` is \`completed\`, \`failed\` or \`cancelled\`, then read each node's status, output and error.
537
+
538
+ ## Errors you will see
539
+
540
+ | Error | Meaning | What to do |
541
+ |---|---|---|
542
+ | \`422 validation_failed\` with \`not_found\` | An id is not in this workspace | Pick from \`listWorkflowFieldOptions\` |
543
+ | \`422 validation_failed\` on publish | Missing fields, an unconnected node, a bad handle | Fix each one, then publish again |
544
+ | \`422 invalid_op\` | An op is malformed | Fix the op at \`op_index\` |
545
+ | \`409 revision_conflict\` | The draft changed since you read it | \`getWorkflow\`, then retry |
546
+ | \`409 no_draft\` | The workflow has no draft to edit, test or publish | \`getWorkflow\`, then make an edit to start a new draft |
547
+ | \`400 no_options\` | The field holds an id from another system | Ask the user for the value |
548
+ | \`422\` with \`templated_ref\` | An id field holds a \`{{ }}\` template | Put a literal id from \`listWorkflowFieldOptions\` |
549
+
550
+ ## Worked example
551
+
552
+ "After a call, if the lead is interested, send our follow-up WhatsApp template
553
+ and tell #sales in Slack."
554
+
555
+ 1. \`createWorkflow { name: "Interested lead follow-up" }\` gives you \`trigger\`
556
+ and a \`revision\`.
557
+ 2. \`listWorkflowFieldOptions\` for \`whatsapp.phone_number_id\`, then for
558
+ \`whatsapp.template_id\` with \`depends\` set to that number. Confirm both with
559
+ the user.
560
+ 3. One \`editWorkflow\` batch:
561
+ - \`add_node { id: "check_interest", type: "conditional", after: "trigger",
562
+ config: { conditions: [{ variable: "{{ context.trigger.extracted_variables.interested }}",
563
+ operator: "==", value: "yes" }] } }\`
564
+ - \`add_node { id: "wa_followup", type: "whatsapp", after: "check_interest",
565
+ handle: "True", config: { phone_number_id: <id>, message_type: "template",
566
+ template_id: <id>, to_number: "{{ context.trigger.customer_number }}" } }\`
567
+ - \`add_node { id: "notify_sales", type: "slack", after: "wa_followup",
568
+ config: { slack_webhook_url: "<from the user>",
569
+ message: "Follow-up sent to {{ context.trigger.customer_number }}" } }\`
570
+ - \`add_node { id: "about", type: "notes", config: { note_text: "Follows up
571
+ interested leads after a call." } }\`
572
+ 4. \`validateWorkflow\`, fix anything reported, then \`publishWorkflow\`.
573
+ 5. Tell the user to point the agent's post-call action at this workflow.
574
+ `;
575
+
389
576
  const RESOURCES: ResourceDef[] = [
390
577
  {
391
578
  uri: "omnidim://guide/routing",
@@ -436,9 +623,45 @@ const RESOURCES: ResourceDef[] = [
436
623
  mimeType: "text/markdown",
437
624
  text: VERSIONING_GUIDE,
438
625
  },
626
+ {
627
+ uri: "omnidim://guide/workflows",
628
+ name: "Building workflows",
629
+ 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.",
630
+ mimeType: "text/markdown",
631
+ text: WORKFLOWS_GUIDE,
632
+ },
439
633
  ];
440
634
 
441
635
  const PROMPTS: PromptDef[] = [
636
+ {
637
+ name: "build_workflow",
638
+ 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.",
639
+ arguments: [
640
+ { 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 },
641
+ ],
642
+ build: (a) => {
643
+ const goal = a.goal || "(describe what should happen, and when)";
644
+ return `Build an OmniDimension workflow for this goal:
645
+
646
+ "${goal}"
647
+
648
+ Read the \`omnidim://guide/workflows\` resource first. It explains triggers, outputs, ops and errors.
649
+
650
+ 1. Pick the trigger, then find each node type with \`listWorkflowNodeTypes\` and read its fields with
651
+ \`getWorkflowNodeType\`.
652
+ 2. For every field that takes an id (a number, template, integration or agent), list real choices with
653
+ \`listWorkflowFieldOptions\` and confirm them with the user. Never guess an id.
654
+ 3. \`createWorkflow\`, then build it with \`editWorkflow\` batches. Use readable node ids, wire branches with
655
+ \`after\` and \`handle\`, and add a notes node that says what the workflow is for.
656
+ 4. \`validateWorkflow\` and fix every error.
657
+ 5. A test run happens for real: messages, calls and CRM writes go out. Only call \`testWorkflow\` after the
658
+ user says yes, with their own phone number or email in the payload. Then poll \`getWorkflowExecution\` until \`state\` is \`completed\`, \`failed\` or \`cancelled\`.
659
+ 6. Show the user the finished flow, then \`publishWorkflow\` when they approve.
660
+ 7. Prefer creating a new workflow. Never publish, activate, deactivate, delete or test an existing workflow
661
+ without the user's explicit yes, after reading it first.
662
+ `;
663
+ },
664
+ },
442
665
  {
443
666
  name: "provision_agent",
444
667
  description: "Create a working voice agent end to end: configure it, give it a number, and verify it can place a call and speak.",
@@ -57,10 +57,37 @@ const TOOL_TITLES: Record<string, string> = {
57
57
  searchPhoneNumbers: "Search available phone numbers",
58
58
  purchasePhoneNumber: "Buy phone number",
59
59
  releasePhoneNumber: "Release phone number",
60
+ getAccountBalance: "Get account balance",
61
+ listClonedVoices: "List cloned voices",
62
+ createClonedVoice: "Clone a voice",
63
+ getClonedVoice: "Get cloned voice",
64
+ updateClonedVoice: "Update cloned voice",
65
+ deleteClonedVoice: "Delete cloned voice",
66
+ getClonedVoiceSample: "Get cloned voice sample",
67
+ regenerateClonedVoiceSample: "Regenerate cloned voice sample",
68
+ listWorkflowNodeTypes: "List workflow node types",
69
+ getWorkflowNodeType: "Get workflow node type",
70
+ listWorkflowFieldOptions: "List choices for a workflow field",
71
+ listWorkflows: "List workflows",
72
+ createWorkflow: "Create workflow",
73
+ getWorkflow: "Get workflow",
74
+ editWorkflow: "Edit workflow draft",
75
+ deleteWorkflow: "Delete workflow",
76
+ validateWorkflow: "Validate workflow",
77
+ publishWorkflow: "Publish workflow",
78
+ activateWorkflow: "Turn workflow on",
79
+ deactivateWorkflow: "Turn workflow off",
80
+ testWorkflow: "Test workflow (runs for real)",
81
+ getWorkflowExecution: "Get workflow run",
82
+ listPostCallActions: "List post-call actions",
83
+ addPostCallAction: "Add a post-call action",
84
+ deletePostCallAction: "Delete a post-call action",
85
+ updatePostCallAction: "Update a post-call action",
86
+ listIntegrations: "List integrations",
60
87
  };
61
88
 
62
89
  // POST tools that only validate or preview, with no state change.
63
- const READ_ONLY_TOOLS = new Set(["canUploadFile"]);
90
+ const READ_ONLY_TOOLS = new Set(["canUploadFile", "validateWorkflow"]);
64
91
 
65
92
  // Irreversible removals, overwrites of live config, plus tools that place
66
93
  // real outbound calls.
@@ -70,10 +97,13 @@ const DESTRUCTIVE_TOOLS = new Set([
70
97
  "cancelBulkCall", "dispatchCall", "createBulkCall", "addBulkCallContact",
71
98
  "addBulkCallContacts", "startBulkCall", "retryBulkCall",
72
99
  "purchasePhoneNumber", "releasePhoneNumber",
100
+ "deleteClonedVoice", "deleteWorkflow", "publishWorkflow", "activateWorkflow",
101
+ "deactivateWorkflow", "testWorkflow", "deletePostCallAction",
73
102
  ]);
74
103
 
75
104
  // Tools that reach the external phone network (a carrier, not just our API).
76
105
  const OPEN_WORLD_TOOLS = new Set([
106
+ "testWorkflow",
77
107
  "dispatchCall", "createBulkCall", "addBulkCallContact",
78
108
  "addBulkCallContacts", "startBulkCall", "retryBulkCall",
79
109
  "purchasePhoneNumber", "releasePhoneNumber",