@ema.co/mcp-toolkit 0.2.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.
Files changed (50) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +321 -0
  3. package/config.example.yaml +32 -0
  4. package/dist/cli/index.js +333 -0
  5. package/dist/config.js +136 -0
  6. package/dist/emaClient.js +398 -0
  7. package/dist/index.js +109 -0
  8. package/dist/mcp/handlers-consolidated.js +851 -0
  9. package/dist/mcp/index.js +15 -0
  10. package/dist/mcp/prompts.js +1753 -0
  11. package/dist/mcp/resources.js +624 -0
  12. package/dist/mcp/server.js +4723 -0
  13. package/dist/mcp/tools-consolidated.js +590 -0
  14. package/dist/mcp/tools-legacy.js +736 -0
  15. package/dist/models.js +8 -0
  16. package/dist/scheduler.js +21 -0
  17. package/dist/sdk/client.js +788 -0
  18. package/dist/sdk/config.js +136 -0
  19. package/dist/sdk/contracts.js +429 -0
  20. package/dist/sdk/generation-schema.js +189 -0
  21. package/dist/sdk/index.js +39 -0
  22. package/dist/sdk/knowledge.js +2780 -0
  23. package/dist/sdk/models.js +8 -0
  24. package/dist/sdk/state.js +88 -0
  25. package/dist/sdk/sync-options.js +216 -0
  26. package/dist/sdk/sync.js +220 -0
  27. package/dist/sdk/validation-rules.js +355 -0
  28. package/dist/sdk/workflow-generator.js +291 -0
  29. package/dist/sdk/workflow-intent.js +1585 -0
  30. package/dist/state.js +88 -0
  31. package/dist/sync.js +416 -0
  32. package/dist/syncOptions.js +216 -0
  33. package/dist/ui.js +334 -0
  34. package/docs/advisor-comms-assistant-fixes.md +175 -0
  35. package/docs/api-contracts.md +216 -0
  36. package/docs/auto-builder-analysis.md +271 -0
  37. package/docs/data-architecture.md +166 -0
  38. package/docs/ema-auto-builder-guide.html +394 -0
  39. package/docs/ema-user-guide.md +1121 -0
  40. package/docs/mcp-tools-guide.md +149 -0
  41. package/docs/naming-conventions.md +218 -0
  42. package/docs/tool-consolidation-proposal.md +427 -0
  43. package/package.json +98 -0
  44. package/resources/templates/chat-ai/README.md +119 -0
  45. package/resources/templates/chat-ai/persona-config.json +111 -0
  46. package/resources/templates/dashboard-ai/README.md +156 -0
  47. package/resources/templates/dashboard-ai/persona-config.json +180 -0
  48. package/resources/templates/voice-ai/README.md +123 -0
  49. package/resources/templates/voice-ai/persona-config.json +74 -0
  50. package/resources/templates/voice-ai/workflow-prompt.md +120 -0
@@ -0,0 +1,1121 @@
1
+ # Ema Platform: New User Guide
2
+
3
+ > **Version:** 1.0 | **Last Updated:** January 2026
4
+ > **Audience:** New users (technical and business)
5
+ > **Scope:** Complete guide to Ema's Agentic AI platform concepts, terminology, and usage patterns
6
+
7
+ ---
8
+
9
+ ## Table of Contents
10
+
11
+ 1. [One-Page Quick Reference](#one-page-quick-reference)
12
+ 2. [Glossary (Alphabetical)](#glossary)
13
+ 3. [Concept Map](#concept-map)
14
+ 4. [Deep Dive Sections](#deep-dive-sections)
15
+ 5. [Decision Tables](#decision-tables)
16
+ 6. [End-to-End Examples](#end-to-end-examples)
17
+ 7. [Troubleshooting & Gotchas](#troubleshooting--gotchas)
18
+ 8. [Version & Documentation References](#version--documentation-references)
19
+
20
+ ---
21
+
22
+ ## One-Page Quick Reference
23
+
24
+ ### What is Ema?
25
+
26
+ **Ema** is a **Universal AI Employee** platform that creates autonomous AI agents capable of completing entire workflows—not just answering questions. Unlike chatbots or copilots, Ema's AI Employees can own tasks from start to finish.
27
+
28
+ ### Core Technology Stack
29
+
30
+ | Component | Purpose |
31
+ |-----------|---------|
32
+ | **EmaFusion™** | Routes queries to optimal models from 100+ LLMs |
33
+ | **Generative Workflow Engine™ (GWE)** | Builds workflows from natural language |
34
+ | **Agent Mesh** | Network of specialized agents working together |
35
+ | **Actions/Connectors** | 200+ enterprise integrations (Salesforce, ServiceNow, Workday, etc.) |
36
+
37
+ ### Key Concepts at a Glance
38
+
39
+ | Term | One-Line Definition |
40
+ |------|---------------------|
41
+ | **AI Employee** | A complete autonomous agent with a role, knowledge, and capabilities |
42
+ | **Workflow** | A sequence of agents/actions orchestrated to complete a task |
43
+ | **Agent** | A specialized capability (search, respond, classify, etc.) |
44
+ | **Action** | A discrete operation an agent can perform |
45
+ | **Trigger** | What initiates a workflow (chat, email, voice, scheduled, etc.) |
46
+ | **HITL** | Human-in-the-Loop approval/verification step |
47
+
48
+ ### Quick Start Flow
49
+
50
+ ```
51
+ 1. Create AI Employee → Choose template (Chat, Email, Voice, Dashboard)
52
+ 2. Configure Trigger → Define how work arrives
53
+ 3. Build Workflow → Add agents and connect them
54
+ 4. Add Knowledge → Upload documents, connect integrations
55
+ 5. Test → Use preview/playground
56
+ 6. Deploy → Activate and monitor
57
+ ```
58
+
59
+ ---
60
+
61
+ ## Glossary
62
+
63
+ ### A
64
+
65
+ #### **Action**
66
+ **Definition:** A discrete operation performed by an agent—the smallest unit of work in a workflow.
67
+
68
+ **Aliases/Related Terms:**
69
+ - Tool (often used interchangeably)
70
+ - Step (workflow context)
71
+ - Connector operation (when involving integrations)
72
+
73
+ **Where It Appears:** Workflow Builder UI, API action definitions, execution logs
74
+
75
+ **Example Actions:**
76
+ - `search` — Retrieve documents from knowledge base
77
+ - `call_llm` — Generate a response using an LLM
78
+ - `send_email` — Dispatch email via integration
79
+ - `create_ticket` — Create ServiceNow/Zendesk ticket
80
+
81
+ ---
82
+
83
+ #### **Agent**
84
+ **Definition:** A specialized AI capability that performs a specific function within a workflow. Agents are the building blocks that compose AI Employee behaviors.
85
+
86
+ **Aliases/Related Terms:**
87
+ - Node (workflow visualization context)
88
+ - Workflow step
89
+ - NOT the same as "AI Employee" (see disambiguation below)
90
+
91
+ **Common Agent Types:**
92
+ | Agent Type | Purpose |
93
+ |------------|---------|
94
+ | `chat_categorizer` | Classifies user intent |
95
+ | `search` | Retrieves relevant documents |
96
+ | `respond_with_sources` | Generates answer with citations |
97
+ | `external_action_caller` | Invokes external APIs/tools |
98
+ | `call_llm` | Custom LLM response generation |
99
+ | `generate_document` | Creates Word/PDF documents |
100
+
101
+ **Where It Appears:** Workflow Builder canvas, Agent library, Execution traces
102
+
103
+ ---
104
+
105
+ #### **Agent Mesh**
106
+ **Definition:** The network of specialized agents that collaborate to complete complex tasks. Instead of a single monolithic AI, Ema uses multiple specialized agents working together.
107
+
108
+ **How It Works:**
109
+ 1. User request arrives at trigger
110
+ 2. Orchestration layer routes to appropriate agents
111
+ 3. Agents may call other agents or external tools
112
+ 4. Results flow back and are synthesized
113
+ 5. Final response delivered
114
+
115
+ **Why It Matters:** Better accuracy, specialization, auditability, and fault isolation than single-agent approaches.
116
+
117
+ ---
118
+
119
+ #### **AI Employee**
120
+ **Definition:** A complete, configured instance of an autonomous AI agent with:
121
+ - A defined role and purpose
122
+ - A workflow (series of agents)
123
+ - Access to specific knowledge/documents
124
+ - Configured integrations and permissions
125
+ - A trigger type (how it receives work)
126
+
127
+ **Aliases/Related Terms:**
128
+ - Persona (internal API term)
129
+ - Bot/Assistant (casual usage—but less accurate)
130
+
131
+ **NOT the same as:**
132
+ - Agent (an AI Employee *contains* agents)
133
+ - Action (actions are what agents perform)
134
+
135
+ **Where It Appears:**
136
+ - Ema Builder UI: "AI Employees" menu
137
+ - API: `persona` endpoints
138
+ - Workspace dashboard
139
+
140
+ ---
141
+
142
+ #### **Agentic AI**
143
+ **Definition:** AI systems that autonomously plan, reason, and execute multi-step tasks—completing workflows from start to finish rather than just assisting.
144
+
145
+ **Evolution Context:**
146
+ | Generation | Type | Capability |
147
+ |------------|------|------------|
148
+ | Gen 1 | Rule-based systems | Follow scripts |
149
+ | Gen 2 | Chatbots | Answer FAQs |
150
+ | Gen 3 | Copilots | Assist humans |
151
+ | Gen 4 | **Agentic AI** | Complete workflows autonomously |
152
+
153
+ **Key Differentiators:**
154
+ - **Goal-oriented:** Works toward outcomes, not just responses
155
+ - **Autonomous:** Makes decisions without constant human input
156
+ - **Tool-using:** Interacts with external systems
157
+ - **Accountable:** Traceable and auditable actions
158
+
159
+ ---
160
+
161
+ ### C
162
+
163
+ #### **Connector**
164
+ **Definition:** A pre-built integration that enables agents to interact with external enterprise systems.
165
+
166
+ **Aliases/Related Terms:**
167
+ - Integration
168
+ - Tool (when used as an action)
169
+ - External action
170
+
171
+ **Examples:**
172
+ - ServiceNow connector → Create/update tickets
173
+ - Salesforce connector → Query/update CRM records
174
+ - Workday connector → Access HR data
175
+ - Email connector → Send/receive emails
176
+
177
+ **Where Configured:** Builder UI → Integrations section, or via API
178
+
179
+ ---
180
+
181
+ #### **Conversation**
182
+ **Definition:** A multi-turn interaction session between a user and an AI Employee, maintaining context across messages.
183
+
184
+ **Key Characteristics:**
185
+ - Persists context across multiple messages
186
+ - Tracked by `conversation_id`
187
+ - Contains history of user messages and AI responses
188
+ - Used for chat and voice-based AI Employees
189
+
190
+ **Accessing Conversation Data in Workflows:**
191
+ - `{{trigger.user_query}}` — Returns only the **last/current user message**
192
+ - `{{trigger.chat_conversation}}` — Returns the **complete conversation history** (all messages)
193
+ - **Conversation Summarizer agent** — Allows **configurable history depth** (specify how many turns to include)
194
+
195
+ **See:** [Query vs Conversation decision table](#query-vs-conversation), [Trigger Agents](#1-trigger-agents)
196
+
197
+ ---
198
+
199
+ ### E
200
+
201
+ #### **EmaFusion™**
202
+ **Definition:** Ema's proprietary model orchestration technology that combines 100+ LLMs to route queries to the optimal model(s) for each task.
203
+
204
+ **How It Works:**
205
+ 1. Incoming query is analyzed
206
+ 2. EmaFusion determines which model(s) are best suited
207
+ 3. Query is routed to selected model(s)
208
+ 4. Results may be synthesized from multiple models
209
+ 5. Best answer returned
210
+
211
+ **Benefits:**
212
+ - Higher accuracy than single-model approaches
213
+ - Cost optimization (use expensive models only when needed)
214
+ - Reduced hallucinations through consensus
215
+ - Automatic model updates without workflow changes
216
+
217
+ **Configuration:** In Builder UI, select "EmaFusion™ Model" widget or limit to specific models.
218
+
219
+ ---
220
+
221
+ ### G
222
+
223
+ #### **Generative Workflow Engine™ (GWE)**
224
+ **Definition:** The core engine that enables building AI workflows using natural language instructions—no coding required.
225
+
226
+ **Key Capabilities:**
227
+ - Natural language workflow definition
228
+ - Visual workflow builder
229
+ - Automatic agent orchestration
230
+ - Execution and monitoring
231
+
232
+ **Where It Appears:** Builder UI (workflow canvas), API (workflow definitions)
233
+
234
+ ---
235
+
236
+ ### H
237
+
238
+ #### **Human-in-the-Loop (HITL)**
239
+ **Definition:** A workflow pattern where human approval or verification is required before proceeding with an action.
240
+
241
+ **When to Use:**
242
+ - High-stakes decisions (financial approvals, legal actions)
243
+ - Sensitive operations (PII handling, terminations)
244
+ - Low-confidence situations
245
+ - Compliance requirements
246
+
247
+ **Configuration:**
248
+ ```yaml
249
+ humanInteractionConfig:
250
+ alwaysPauseForHumanInteraction: true
251
+ message: "Please confirm the action"
252
+ confirmationButtonName: "Confirm"
253
+ cancelButtonName: "Cancel"
254
+ ```
255
+
256
+ **Where It Appears:** Agent configuration in Builder, execution flow in runtime
257
+
258
+ ---
259
+
260
+ ### K
261
+
262
+ #### **Knowledge Base**
263
+ **Definition:** The collection of documents, policies, and data sources an AI Employee can search and reference.
264
+
265
+ **Supported Sources:**
266
+ - Local file uploads (PDF, DOCX, TXT, etc.)
267
+ - Connected integrations (Google Drive, SharePoint, Confluence)
268
+ - Structured databases
269
+ - Web content
270
+
271
+ **Features:**
272
+ - Vector search (semantic similarity)
273
+ - Keyword search
274
+ - Automatic chunking and embedding
275
+ - Source citation in responses
276
+
277
+ ---
278
+
279
+ ### Q
280
+
281
+ #### **Query**
282
+ **Definition:** A single, stateless request to an AI system—does not maintain conversation context.
283
+
284
+ **Key Characteristics:**
285
+ - One-shot interaction
286
+ - No history awareness
287
+ - Typically used for API calls or single-turn interactions
288
+ - Lower overhead than conversations
289
+
290
+ **See:** [Query vs Conversation decision table](#query-vs-conversation)
291
+
292
+ ---
293
+
294
+ ### T
295
+
296
+ #### **Task**
297
+ **Definition:** A unit of work to be completed by an AI Employee, triggered by an event and executed through a workflow.
298
+
299
+ **Lifecycle:**
300
+ 1. **Triggered** — Event arrives (chat message, email, schedule)
301
+ 2. **Queued** — Task enters processing queue
302
+ 3. **Executing** — Workflow runs through agents
303
+ 4. **Awaiting** — Paused for HITL or external response
304
+ 5. **Completed** — Successfully finished
305
+ 6. **Failed** — Error occurred
306
+
307
+ **Where It Appears:** Execution logs, task dashboard, API responses
308
+
309
+ ---
310
+
311
+ #### **Trigger**
312
+ **Definition:** The event or condition that initiates an AI Employee's workflow.
313
+
314
+ **Trigger Types:**
315
+ | Type | ID | Description |
316
+ |------|----|----|
317
+ | Chat | 1, 4 | Web chat widget interaction |
318
+ | Email | 2 | Incoming email to monitored inbox |
319
+ | Ticket | 3 | ServiceNow/Zendesk ticket event |
320
+ | Voice | 1 | Phone/voice interaction |
321
+ | Schedule | 5 | Time-based automation |
322
+ | Dashboard | 2 | Manual dashboard trigger |
323
+ | API | - | Programmatic invocation |
324
+
325
+ ---
326
+
327
+ #### **Tool**
328
+ **Definition:** An external capability that agents can invoke to perform specific operations.
329
+
330
+ **Aliases/Related Terms:**
331
+ - Action (internal context)
332
+ - Connector (when referring to integration)
333
+ - External action
334
+
335
+ **Tool Categories:**
336
+ - **Internal tools:** Search, respond, classify
337
+ - **External tools:** Third-party API calls, integrations
338
+ - **Custom tools:** User-defined API endpoints
339
+
340
+ ---
341
+
342
+ ### W
343
+
344
+ #### **Workflow**
345
+ **Definition:** A directed graph of agents and their connections that defines how an AI Employee processes work from trigger to response.
346
+
347
+ **Components:**
348
+ 1. **Trigger node** — Entry point
349
+ 2. **Agent nodes** — Processing steps
350
+ 3. **Conditional branches** — Decision points
351
+ 4. **Result nodes** — Output definitions
352
+
353
+ **Example Structure:**
354
+ ```
355
+ Trigger → Categorizer → [Branch by Intent]
356
+ ├─→ Search → Respond (FAQ)
357
+ ├─→ External Tool → Respond (Action)
358
+ └─→ Escalate (Unknown)
359
+ ```
360
+
361
+ ---
362
+
363
+ ## Concept Map
364
+
365
+ ```
366
+ ┌─────────────────────────────────────────────────────────────────┐
367
+ │ EMA PLATFORM ARCHITECTURE │
368
+ ├─────────────────────────────────────────────────────────────────┤
369
+ │ │
370
+ │ ┌─────────────────┐ ┌─────────────────┐ │
371
+ │ │ AI EMPLOYEE │────▶│ WORKFLOW │ │
372
+ │ │ (Persona) │ │ │ │
373
+ │ │ │ │ ┌───────────┐ │ │
374
+ │ │ • Name/Role │ │ │ TRIGGER │ │ │
375
+ │ │ • Description │ │ │(Chat/Email│ │ │
376
+ │ │ • Status │ │ │ /Voice) │ │ │
377
+ │ │ • Access Level │ │ └─────┬─────┘ │ │
378
+ │ └─────────────────┘ │ │ │ │
379
+ │ │ ▼ │ │
380
+ │ │ ┌───────────┐ │ ┌──────────────┐ │
381
+ │ │ │ AGENT │──┼─▶│ ACTION │ │
382
+ │ │ │ (Node) │ │ │ │ │
383
+ │ │ │ │ │ │ • search │ │
384
+ │ │ │ • Type │ │ │ • call_llm │ │
385
+ │ │ │ • Inputs │ │ │ • send_email │ │
386
+ │ │ │ • Config │ │ │ • api_call │ │
387
+ │ │ └─────┬─────┘ │ └──────────────┘ │
388
+ │ │ │ │ │
389
+ │ │ ▼ │ │
390
+ │ │ ┌───────────┐ │ ┌──────────────┐ │
391
+ │ │ │ RESULTS │──┼─▶│ CONNECTORS/ │ │
392
+ │ │ │ │ │ │ TOOLS │ │
393
+ │ │ └───────────┘ │ │ │ │
394
+ │ │ │ │ • Salesforce │ │
395
+ │ └─────────────────┘ │ • ServiceNow │ │
396
+ │ │ • Workday │ │
397
+ │ └──────────────┘ │
398
+ │ │
399
+ │ ┌─────────────────┐ ┌─────────────────┐ │
400
+ │ │ EMAFUSION™ │ │ KNOWLEDGE BASE │ │
401
+ │ │ │ │ │ │
402
+ │ │ • Model routing │ │ • Documents │ │
403
+ │ │ • 100+ LLMs │ │ • Integrations │ │
404
+ │ │ • Optimization │ │ • Tags/Filters │ │
405
+ │ └─────────────────┘ └─────────────────┘ │
406
+ │ │
407
+ └─────────────────────────────────────────────────────────────────┘
408
+ ```
409
+
410
+ ### Disambiguation Relationships
411
+
412
+ ```
413
+ ┌────────────────────────────────────────────────────────────────┐
414
+ │ COMMON CONFUSIONS CLARIFIED │
415
+ ├────────────────────────────────────────────────────────────────┤
416
+ │ │
417
+ │ AI EMPLOYEE ≠ AGENT ≠ AGENT MESH │
418
+ │ ═══════════ ═════ ══════════ │
419
+ │ │
420
+ │ AI Employee: The complete deployed instance │
421
+ │ │ (has role, workflow, knowledge) │
422
+ │ │ │
423
+ │ └──contains──▶ Workflow │
424
+ │ │ │
425
+ │ └──contains──▶ Agents (plural) │
426
+ │ │ │
427
+ │ └──work within──▶ │
428
+ │ Agent Mesh │
429
+ │ │
430
+ │ ANALOGY: │
431
+ │ • AI Employee = Complete Employee with job description │
432
+ │ • Agents = Individual skills/capabilities │
433
+ │ • Agent Mesh = The team collaboration pattern │
434
+ │ • Workflow = The process they follow │
435
+ │ │
436
+ ├────────────────────────────────────────────────────────────────┤
437
+ │ │
438
+ │ ACTION vs TOOL vs STEP │
439
+ │ ══════ ════ ════ │
440
+ │ │
441
+ │ Action: Platform's term for discrete operation │
442
+ │ Tool: External action (API call, connector) │
443
+ │ Step: Workflow position (visual/sequential context) │
444
+ │ │
445
+ │ All three can refer to the same thing depending on context! │
446
+ │ │
447
+ ├────────────────────────────────────────────────────────────────┤
448
+ │ │
449
+ │ QUERY vs CONVERSATION │
450
+ │ ═════ ════════════ │
451
+ │ │
452
+ │ Query: Single request, no context │
453
+ │ Conversation: Multi-turn, context preserved │
454
+ │ │
455
+ │ See Decision Table below for when to use each │
456
+ │ │
457
+ └────────────────────────────────────────────────────────────────┘
458
+ ```
459
+
460
+ ---
461
+
462
+ ## Deep Dive Sections
463
+
464
+ ### AI Employees
465
+
466
+ #### What They Are
467
+
468
+ An **AI Employee** is a fully configured, deployable autonomous agent. Think of it as a digital team member with:
469
+
470
+ 1. **Identity** — Name, description, icon
471
+ 2. **Role** — What it does (HR support, customer service, document processing)
472
+ 3. **Capabilities** — Workflow defining its behaviors
473
+ 4. **Knowledge** — Documents and data it can access
474
+ 5. **Integrations** — External systems it can interact with
475
+ 6. **Access Controls** — Who can use/edit it
476
+
477
+ #### How They Work
478
+
479
+ ```
480
+ ┌─────────────────────────────────────────────────────────────┐
481
+ │ AI EMPLOYEE EXECUTION │
482
+ ├─────────────────────────────────────────────────────────────┤
483
+ │ │
484
+ │ 1. TRIGGER RECEIVED │
485
+ │ └─▶ Chat message / Email / Voice call / Schedule │
486
+ │ │
487
+ │ 2. WORKFLOW INITIATED │
488
+ │ └─▶ Trigger node activates │
489
+ │ │
490
+ │ 3. AGENT SEQUENCE EXECUTES │
491
+ │ └─▶ Each agent processes inputs, produces outputs │
492
+ │ └─▶ Conditional routing based on agent outputs │
493
+ │ │
494
+ │ 4. EXTERNAL CALLS (if needed) │
495
+ │ └─▶ API calls to connectors │
496
+ │ └─▶ HITL pauses if configured │
497
+ │ │
498
+ │ 5. RESULTS DELIVERED │
499
+ │ └─▶ Response to user / Document created / Action taken │
500
+ │ │
501
+ │ 6. LOGGING & ANALYTICS │
502
+ │ └─▶ Execution trace captured │
503
+ │ └─▶ Metrics updated │
504
+ │ │
505
+ └─────────────────────────────────────────────────────────────┘
506
+ ```
507
+
508
+ #### Configuration Locations
509
+
510
+ | Setting | Builder UI | API |
511
+ |---------|------------|-----|
512
+ | Name/Description | AI Employee Settings | `persona.name`, `persona.description` |
513
+ | Status (Active/Inactive) | Toggle in header | `enabled_by_user` |
514
+ | Workflow | Workflow Builder canvas | `workflow_def` |
515
+ | Knowledge | File Upload widgets | `proto_config.widgets` |
516
+ | Integrations | Integrations panel | Connector configurations |
517
+ | EmaFusion Model | Model selector widget | `fusionModel` config |
518
+
519
+ #### Debugging AI Employees
520
+
521
+ 1. **Execution Traces** — View step-by-step agent execution
522
+ 2. **Logs** — Detailed input/output for each node
523
+ 3. **Preview Mode** — Test without affecting production
524
+ 4. **Playground** — Interactive testing environment
525
+
526
+ ---
527
+
528
+ ### Workflows & Agents
529
+
530
+ #### Workflow Architecture
531
+
532
+ A workflow is a **directed acyclic graph (DAG)** where:
533
+ - **Nodes** are agents performing operations
534
+ - **Edges** define data flow between agents
535
+ - **Conditions** enable branching logic
536
+
537
+ #### Core Agent Types
538
+
539
+ ##### 1. Trigger Agents
540
+ Start the workflow when an event occurs.
541
+
542
+ ```yaml
543
+ # Chat Trigger Example
544
+ name: "trigger"
545
+ action: "triggers.emainternal.chat_trigger"
546
+ outputs:
547
+ - chat_conversation # Full conversation history
548
+ - user_query # Latest user message
549
+ ```
550
+
551
+ **Trigger Output Details:**
552
+
553
+ | Output | Description |
554
+ |--------|-------------|
555
+ | `user_query` | The **last/most recent user question** only. Use this when you only need the current request without history context. |
556
+ | `chat_conversation` | The **complete conversation history** including all previous messages. Contains the full context of the interaction. |
557
+ | `additional_context` | **Integration-specific context** passed from upstream systems via API. Available when integrated with platforms like Microsoft Teams (via Graph API), Slack, or other enterprise systems. |
558
+
559
+ **Additional Context from Integrations:**
560
+
561
+ When the AI Employee is integrated with upstream platforms, the trigger may receive `additional_context` containing platform-specific information:
562
+
563
+ | Integration | Context May Include |
564
+ |-------------|---------------------|
565
+ | **Microsoft Teams** (Graph API) | User profile, team/channel info, tenant details, message metadata |
566
+ | **Slack** | Workspace info, channel context, user details, thread information |
567
+ | **Email** | Sender info, headers, attachments metadata, thread references |
568
+ | **Custom API** | Any context your integration passes through |
569
+
570
+ This additional context enables richer personalization and routing decisions based on where and how the user is interacting with the AI Employee.
571
+
572
+ > ⚠️ **Critical: Workflow Execution Model**
573
+ >
574
+ > Each `user_query` (user message) **triggers a new workflow execution**. This means:
575
+ > - The workflow runs **once per user message**, not once per conversation
576
+ > - Each subsequent question is its own `user_query` that invokes the workflow again
577
+ > - `chat_conversation` accumulates across executions, but each execution starts fresh
578
+ >
579
+ > **Design Implications:**
580
+ > - **Avoid duplicate actions:** If a user asks a follow-up question, the workflow runs again. Design your workflow to check context before performing actions (e.g., don't create a new ticket if one was just created in the previous turn)
581
+ > - **Use conversation history for context:** Check `chat_conversation` to understand what actions were already taken in previous turns
582
+ > - **Conditional logic:** Use `runIf` conditions to skip redundant operations based on conversation state
583
+ >
584
+ > **Example Anti-Pattern:**
585
+ > ```
586
+ > User: "Create a ticket for my laptop issue" → Workflow creates ticket ✓
587
+ > User: "Add my phone number to it" → Workflow runs again - might create ANOTHER ticket ✗
588
+ > ```
589
+ >
590
+ > **Correct Pattern:**
591
+ > ```
592
+ > Use chat_conversation to detect if a ticket was already created in this conversation,
593
+ > then route to "update ticket" instead of "create ticket"
594
+ > ```
595
+
596
+ **Trigger Outputs vs Conversation Summarizer:**
597
+
598
+ Both `chat_conversation` and the **Conversation Summarizer** agent provide conversation context, but with key differences:
599
+
600
+ | Approach | History Scope | Use Case |
601
+ |----------|---------------|----------|
602
+ | `{{trigger.chat_conversation}}` | **All history** — complete conversation from start | When you need full context and don't want to lose any information |
603
+ | `{{trigger.user_query}}` | **Last message only** — just the current question | Simple queries where history doesn't matter |
604
+ | **Conversation Summarizer** agent | **Configurable** — specify how many turns/how far back | When you need to limit context window or summarize long conversations |
605
+
606
+ **When to Use Each:**
607
+
608
+ - **Use `user_query`** for single-turn interactions or when previous context isn't needed
609
+ - **Use `chat_conversation`** when you need complete history and context window size isn't a concern
610
+ - **Use Conversation Summarizer** when:
611
+ - Conversations are long and you need to manage token limits
612
+ - You want to control exactly how many turns of history to include
613
+ - You need a condensed summary rather than raw message history
614
+
615
+ > **Note:** You may still need to use **Conversation Summarizer in conjunction with `chat_conversation`**. Some downstream agents specifically require the Conversation Summarizer's output format. Additionally, even when using `chat_conversation`, you may need to add a Conversation Summarizer to reduce conversation size due to LLM context window limits on long conversations.
616
+
617
+ ##### 2. Classification Agents
618
+ Categorize inputs to route to appropriate handlers.
619
+
620
+ ```yaml
621
+ # Intent Classifier Example
622
+ name: "chat_categorizer"
623
+ action: "actions.emainternal.chat_categorizer"
624
+ inputs:
625
+ conversation: "{{trigger.chat_conversation}}"
626
+ typeArguments:
627
+ categories:
628
+ - name: "Fallback"
629
+ description: "General policy questions"
630
+ examples: ["What are the benefits?", "Tell me about leave policy"]
631
+ - name: "Leave Management"
632
+ description: "Leave requests and balance"
633
+ examples: ["Apply for vacation", "Check my leave balance"]
634
+ - name: "IT Tickets"
635
+ description: "Technical support requests"
636
+ examples: ["Create a ticket", "I can't login"]
637
+ ```
638
+
639
+ ##### 3. Search Agents
640
+ Retrieve relevant information from knowledge bases.
641
+
642
+ ```yaml
643
+ # Knowledge Base Search Example
644
+ name: "search"
645
+ action: "actions.emainternal.search"
646
+ inputs:
647
+ query: "{{categorizer.summarized_conversation}}"
648
+ datastore_configs: ["policy_documents"]
649
+ page_size: 15
650
+ max_sources: 15
651
+ outputs:
652
+ - search_results
653
+ ```
654
+
655
+ ##### 4. Response Agents
656
+ Generate answers using LLMs.
657
+
658
+ ```yaml
659
+ # Response Generation Example
660
+ name: "respond_with_sources"
661
+ action: "actions.emainternal.respond_with_sources"
662
+ inputs:
663
+ query: "{{search.query}}"
664
+ search_results: "{{search.search_results}}"
665
+ user_instructions: |
666
+ You are an HR assistant. Answer questions using only
667
+ the provided documents. Cite your sources.
668
+ model_config:
669
+ selectedModels: ["gpt-4o"]
670
+ ```
671
+
672
+ ##### 5. External Action Agents
673
+ Call external APIs and tools.
674
+
675
+ ```yaml
676
+ # External API Call Example
677
+ name: "external_action_caller"
678
+ action: "actions.emainternal.external_action_caller"
679
+ tools:
680
+ - action: "tools.external.servicenow_Create_Ticket"
681
+ inputs:
682
+ ShortDescription: "{{llm_inferred}}"
683
+ Description: "{{llm_inferred}}"
684
+ UserId: "user@company.com"
685
+ humanInteractionConfig:
686
+ alwaysPauseForHumanInteraction: true
687
+ message: "Please confirm ticket creation"
688
+ ```
689
+
690
+ #### Conditional Execution
691
+
692
+ Agents can have `runIf` conditions:
693
+
694
+ ```yaml
695
+ runIf:
696
+ lhs: "{{categorizer.category}}"
697
+ operator: EQUALS # 1 = EQUALS
698
+ rhs: "Leave Management"
699
+ ```
700
+
701
+ ---
702
+
703
+ ### Actions & Tools
704
+
705
+ #### Action Anatomy
706
+
707
+ Every action has:
708
+
709
+ | Component | Description |
710
+ |-----------|-------------|
711
+ | **Name** | Unique identifier |
712
+ | **Namespace** | Category (actions.emainternal, tools.external, etc.) |
713
+ | **Version** | API version (v0, v1, etc.) |
714
+ | **Inputs** | Required and optional parameters |
715
+ | **Outputs** | What the action produces |
716
+
717
+ #### Tool Invocation Flow
718
+
719
+ ```
720
+ ┌───────────────────────────────────────────────────────────────┐
721
+ │ TOOL INVOCATION FLOW │
722
+ ├───────────────────────────────────────────────────────────────┤
723
+ │ │
724
+ │ 1. Agent receives inputs │
725
+ │ └─▶ Query, context, configuration │
726
+ │ │
727
+ │ 2. LLM analyzes which tool(s) to call │
728
+ │ └─▶ Based on query intent and available tools │
729
+ │ │
730
+ │ 3. LLM extracts/infers parameters │
731
+ │ └─▶ From conversation context or hardcoded values │
732
+ │ │
733
+ │ 4. HITL check (if configured) │
734
+ │ └─▶ Present parameters for human approval │
735
+ │ └─▶ Wait for confirmation/cancellation │
736
+ │ │
737
+ │ 5. Tool executed │
738
+ │ └─▶ API call made with extracted parameters │
739
+ │ │
740
+ │ 6. Results processed │
741
+ │ └─▶ Response formatted and returned to workflow │
742
+ │ │
743
+ └───────────────────────────────────────────────────────────────┘
744
+ ```
745
+
746
+ #### Connector Categories
747
+
748
+ Based on observed AI Employees:
749
+
750
+ | Category | Examples |
751
+ |----------|----------|
752
+ | **ITSM** | ServiceNow, Zendesk, Jira |
753
+ | **CRM** | Salesforce, HubSpot |
754
+ | **HR** | Workday, BambooHR, ADP |
755
+ | **Communication** | Email, Slack, Teams |
756
+ | **Documents** | Google Drive, SharePoint, Box |
757
+ | **Custom APIs** | Any REST API endpoint |
758
+
759
+ ---
760
+
761
+ ### Human-in-the-Loop (HITL)
762
+
763
+ #### When to Use HITL
764
+
765
+ | Scenario | HITL Recommended? | Rationale |
766
+ |----------|-------------------|-----------|
767
+ | Creating tickets | ✅ Yes | Verify details before submission |
768
+ | Querying information | ❌ No | Low risk, user can clarify |
769
+ | Sending emails | ✅ Yes | Prevent incorrect communications |
770
+ | Financial actions | ✅ Yes | Compliance and accuracy |
771
+ | Document generation | ⚠️ Sometimes | Depends on sensitivity |
772
+ | Knowledge lookup | ❌ No | Read-only, reversible |
773
+
774
+ #### Configuration Options
775
+
776
+ ```yaml
777
+ humanInteractionConfig:
778
+ alwaysPauseForHumanInteraction: true # Always require approval
779
+ shouldVerifyParamsPreExecution: true # Show params before executing
780
+ message: "Please review and confirm" # Custom message
781
+ confirmationButtonName: "Approve" # Custom button text
782
+ cancelButtonName: "Reject" # Custom cancel text
783
+ hiddenParams: ["internal_id"] # Hide sensitive params
784
+ paramEditingDisabled: false # Allow param editing
785
+ ```
786
+
787
+ ---
788
+
789
+ ## Decision Tables
790
+
791
+ ### Query vs Conversation
792
+
793
+ | Criteria | Use Query | Use Conversation |
794
+ |----------|-----------|------------------|
795
+ | **Interaction Type** | Single request | Multi-turn dialogue |
796
+ | **Context Needed** | No history required | History important |
797
+ | **API Pattern** | Stateless call | Session-based |
798
+ | **Use Case** | Document processing, batch jobs | Chat, voice support |
799
+ | **Overhead** | Lower | Higher (state management) |
800
+ | **Example** | "Process this invoice" | "What's my leave balance?" → "Apply for next Monday" |
801
+
802
+ #### Conversation Example
803
+
804
+ ```json
805
+ {
806
+ "conversation_id": "conv_abc123",
807
+ "messages": [
808
+ {"role": "user", "content": "What's my leave balance?"},
809
+ {"role": "assistant", "content": "You have 12 days of PTO remaining."},
810
+ {"role": "user", "content": "I'd like to take next Monday off"},
811
+ {"role": "assistant", "content": "I'll submit a leave request for Monday. Please confirm."}
812
+ ]
813
+ }
814
+ ```
815
+
816
+ #### Query Example
817
+
818
+ ```json
819
+ {
820
+ "query": "Extract invoice number and total from attached PDF",
821
+ "attachments": ["invoice_2024_001.pdf"]
822
+ }
823
+ ```
824
+
825
+ ---
826
+
827
+ ### Actions vs Conversational Orchestration
828
+
829
+ | Scenario | Approach | Why |
830
+ |----------|----------|-----|
831
+ | **User asks a question** | Conversational | Need to understand intent, search knowledge |
832
+ | **Automated document processing** | Actions pipeline | No user interaction, deterministic flow |
833
+ | **IT ticket creation** | Conversational → Action | Gather info conversationally, then act |
834
+ | **Scheduled report generation** | Actions pipeline | No user in loop |
835
+ | **Complex multi-system workflow** | Action orchestration | Predictable, auditable execution |
836
+ | **Ambiguous user request** | Conversational | Need clarification |
837
+
838
+ ---
839
+
840
+ ### When to Use What
841
+
842
+ | Need | Solution |
843
+ |------|----------|
844
+ | Answer employee questions from policy docs | Chat AI Employee with search + respond agents |
845
+ | Process incoming emails automatically | Email-triggered AI Employee with classification + routing |
846
+ | Create IT tickets from chat | Chat AI Employee with external_action_caller to ServiceNow |
847
+ | Generate documents on demand | Document AI Employee with generate_document agent |
848
+ | Voice-based password reset | Voice AI Employee with verification workflow |
849
+ | Scheduled data extraction | Dashboard AI Employee with schedule trigger |
850
+
851
+ ---
852
+
853
+ ## End-to-End Examples
854
+
855
+ ### Example 1: Simple HR Policy Q&A Bot
856
+
857
+ **Objective:** Answer employee questions about company policies.
858
+
859
+ #### 1. Create AI Employee
860
+ - Template: Chat AI Employee
861
+ - Name: "HR Policy Assistant"
862
+ - Trigger: Chat
863
+
864
+ #### 2. Configure Workflow
865
+
866
+ ```
867
+ [Chat Trigger]
868
+
869
+
870
+ [Conversation Summarizer] ─── Extracts user query and context
871
+
872
+
873
+ [Knowledge Search] ─── Searches uploaded policy documents
874
+
875
+
876
+ [Respond with Sources] ─── Generates answer with citations
877
+ ```
878
+
879
+ #### 3. Add Knowledge
880
+ - Upload: Employee Handbook PDF, Leave Policy DOCX, Benefits Guide PDF
881
+ - Enable tagging by location/department if needed
882
+
883
+ #### 4. Configure Response Agent
884
+
885
+ ```yaml
886
+ user_instructions: |
887
+ You are an HR assistant for ACME Inc.
888
+ Answer questions using ONLY the provided documents.
889
+ Always cite your sources.
890
+ If you don't know the answer, say so and suggest contacting HR.
891
+ Keep responses concise but complete.
892
+ ```
893
+
894
+ #### 5. Test & Deploy
895
+ - Use preview mode with sample questions
896
+ - Verify source citations are correct
897
+ - Activate when satisfied
898
+
899
+ ---
900
+
901
+ ### Example 2: Enterprise IT Support with Ticket Creation
902
+
903
+ **Objective:** Triage IT requests, answer from knowledge base or create ServiceNow tickets.
904
+
905
+ #### 1. Create AI Employee
906
+ - Template: Chat AI Employee
907
+ - Name: "IT Support Assistant"
908
+ - Trigger: Chat (embed in intranet)
909
+
910
+ #### 2. Configure Workflow
911
+
912
+ ```
913
+ [Chat Trigger]
914
+
915
+
916
+ [Intent Classifier] ───┬──── "Knowledge Question" ───▶ [Search] → [Respond]
917
+
918
+ ├──── "Ticket Request" ───▶ [Create Ticket] → [Confirm]
919
+
920
+ └──── "Unknown" ───▶ [Escalate/Create Ticket]
921
+ ```
922
+
923
+ #### 3. Configure Intent Categories
924
+
925
+ ```yaml
926
+ categories:
927
+ - name: "Knowledge Question"
928
+ description: "Questions about IT policies, how-to guides"
929
+ examples:
930
+ - "How do I connect to VPN?"
931
+ - "What's the password policy?"
932
+
933
+ - name: "Ticket Request"
934
+ description: "Request for IT help or action"
935
+ examples:
936
+ - "My laptop is broken"
937
+ - "I need software installed"
938
+ - "I can't access the shared drive"
939
+
940
+ - name: "Status Check"
941
+ description: "Check on existing tickets"
942
+ examples:
943
+ - "What's the status of my ticket?"
944
+ - "Has my request been resolved?"
945
+ ```
946
+
947
+ #### 4. Configure ServiceNow Integration
948
+
949
+ ```yaml
950
+ tools:
951
+ - action: "tools.external.servicenow_Create_Ticket"
952
+ inputs:
953
+ ShortDescription: "{{llm_inferred}}"
954
+ Description: "{{llm_inferred}}"
955
+ Urgency: "{{llm_inferred}}"
956
+ Impact: "{{llm_inferred}}"
957
+ UserId: "{{user.email}}"
958
+ humanInteractionConfig:
959
+ alwaysPauseForHumanInteraction: true
960
+ message: "Please confirm ticket details before submission"
961
+ ```
962
+
963
+ #### 5. Test Scenarios
964
+ - "How do I reset my password?" → Should answer from KB
965
+ - "My laptop screen is cracked" → Should create ticket (with approval)
966
+ - "Check ticket INC0012345" → Should lookup and return status
967
+
968
+ ---
969
+
970
+ ### Example 3: Voice Password Reset
971
+
972
+ **Objective:** Enable employees to reset passwords via phone with identity verification.
973
+
974
+ #### 1. Create AI Employee
975
+ - Template: Voice AI Employee
976
+ - Name: "Password Reset Assistant"
977
+ - Trigger: Voice/Phone
978
+
979
+ #### 2. Configure Workflow
980
+
981
+ ```
982
+ [Voice Trigger]
983
+
984
+
985
+ [Greeting Agent] ─── "Hi, I'm the IT assistant. I can help reset your password."
986
+
987
+
988
+ [Identity Verification 1] ─── "What's your employee ID?"
989
+
990
+
991
+ [Identity Verification 2] ─── "What are the last 4 digits of your SSN?"
992
+
993
+
994
+ [Verification Check] ───┬──── Success ───▶ [Send Reset Link] → [Confirm]
995
+
996
+ └──── Failure ───▶ [Transfer to Human Agent]
997
+ ```
998
+
999
+ #### 3. Configure Voice Settings
1000
+ - Voice: Select appropriate TTS voice
1001
+ - Conversational style: Professional, clear, helpful
1002
+ - Error handling: Graceful transfer to human on failures
1003
+
1004
+ ---
1005
+
1006
+ ## Troubleshooting & Gotchas
1007
+
1008
+ ### Common Mistakes
1009
+
1010
+ | Mistake | Problem | Solution |
1011
+ |---------|---------|----------|
1012
+ | **Not testing with edge cases** | Unexpected failures in production | Test with empty inputs, long inputs, multilingual |
1013
+ | **Overloading workflows** | Slow execution, timeouts | Keep workflows focused; split complex ones |
1014
+ | **Missing HITL on sensitive actions** | Unintended actions taken | Add HITL for any action with external side effects |
1015
+ | **Vague agent instructions** | Inconsistent responses | Be specific about tone, format, boundaries |
1016
+ | **Not citing sources** | Trust issues | Enable `use_citation_based_filtering` |
1017
+ | **Ignoring confidence scores** | Bad answers served confidently | Implement confidence thresholds |
1018
+
1019
+ ### Debugging Checklist
1020
+
1021
+ When an AI Employee isn't working correctly:
1022
+
1023
+ 1. **Check Status** — Is the AI Employee active/ready?
1024
+ 2. **Review Trigger** — Is the trigger correctly configured?
1025
+ 3. **Trace Execution** — Where does the workflow fail?
1026
+ 4. **Inspect Inputs** — Are inputs reaching agents correctly?
1027
+ 5. **Check Integrations** — Are connectors authenticated?
1028
+ 6. **Review Logs** — What errors appear?
1029
+ 7. **Test Isolation** — Does the agent work in isolation?
1030
+
1031
+ ### Known Limitations
1032
+
1033
+ | Limitation | Workaround |
1034
+ |------------|------------|
1035
+ | **Long document processing** | Split into chunks, use async processing |
1036
+ | **Real-time data needs** | Use external action callers with live APIs |
1037
+ | **Complex calculations** | Use code execution tools or external services |
1038
+ | **Multi-language in single workflow** | Detect language early, route appropriately |
1039
+
1040
+ ### Error Handling Patterns
1041
+
1042
+ ```yaml
1043
+ # Graceful degradation example
1044
+ runIf:
1045
+ condition: "{{search.search_results.length}} > 0"
1046
+ onTrue: "respond_with_sources"
1047
+ onFalse: "fallback_response"
1048
+
1049
+ # Fallback configuration
1050
+ fallback_response:
1051
+ action: "call_llm"
1052
+ inputs:
1053
+ instructions: |
1054
+ The knowledge base doesn't have relevant information.
1055
+ Apologize and offer to create a ticket for human follow-up.
1056
+ ```
1057
+
1058
+ ---
1059
+
1060
+ ## Version & Documentation References
1061
+
1062
+ ### Documentation URLs
1063
+
1064
+ | Resource | URL | Notes |
1065
+ |----------|-----|-------|
1066
+ | **Developer Docs** | https://developer.ema.co/ | API reference, SDK guides |
1067
+ | **Builder Docs** | https://builder.ema.co/ | UI guides, tutorials |
1068
+ | **Ema Website** | https://ema.co | Product overview, use cases |
1069
+ | **Knowledge Base** | https://emaunlimited.atlassian.net/wiki/spaces/KB/overview | Internal knowledge articles |
1070
+
1071
+ ### API Environments
1072
+
1073
+ | Environment | URL | Purpose |
1074
+ |-------------|-----|---------|
1075
+ | **Demo** | https://api.demo.ema.co | Testing, demos |
1076
+ | **Dev** | https://api.dev.ema.co | Development |
1077
+ | **Production** | https://api.ema.co | Live deployments |
1078
+
1079
+ ### Version Information
1080
+
1081
+ - **Guide Version:** 1.0
1082
+ - **Platform Version:** As of January 2026
1083
+ - **Last Reviewed:** January 5, 2026
1084
+
1085
+ ### Areas Where Documentation is Unclear
1086
+
1087
+ Based on analysis, the following areas could benefit from clearer documentation:
1088
+
1089
+ 1. **Action Categories** — Complete list of available actions and their parameters
1090
+ 2. **Workflow Schema** — Full JSON schema for workflow definitions
1091
+ 3. **Error Codes** — Comprehensive error code reference
1092
+ 4. **Rate Limits** — API rate limiting documentation
1093
+ 5. **MCP/A2A Protocols** — If/how these are implemented
1094
+
1095
+ ### Feedback
1096
+
1097
+ For documentation feedback or corrections, contact:
1098
+ - Internal: Ema Documentation Team
1099
+ - External: docs@ema.co
1100
+
1101
+ ---
1102
+
1103
+ ## Appendix: Template IDs Reference
1104
+
1105
+ Common template IDs observed in the platform:
1106
+
1107
+ | Template ID | Type |
1108
+ |-------------|------|
1109
+ | `00000000-0000-0000-0000-000000000001` | Basic Chat |
1110
+ | `00000000-0000-0000-0000-000000000007` | Conversational Chat |
1111
+ | `00000000-0000-0000-0000-00000000000a` | Email/Dashboard |
1112
+ | `00000000-0000-0000-0000-00000000000b` | Document Writer |
1113
+ | `00000000-0000-0000-0000-00000000000e` | Ticket Handler |
1114
+ | `00000000-0000-0000-0000-000000000014` | Auto Builder |
1115
+ | `00000000-0000-0000-0000-00000000001e` | Voice AI Employee |
1116
+ | `10d38c96-e4fb-4aa6-9586-aad0bfbc2f0d` | Dashboard Workflow |
1117
+
1118
+ ---
1119
+
1120
+ *This guide is maintained by the Ema Platform team. For the latest updates, always refer to the official documentation at https://developer.ema.co/*
1121
+