Skip to content

Commit 2837e51

Browse files
committed
Add new tool with improved examples
1 parent 7c5420c commit 2837e51

14 files changed

Lines changed: 1015 additions & 119 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ dist/
55
skills-lock.json
66
.agents/
77
.pnpm-store
8+
*.dev.ts

bin/deploy-runner.js

Lines changed: 65 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

servers/genesys-cloud-architect-mcp.js

Lines changed: 48 additions & 48 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

skills/write-flow/SKILL.md

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,15 @@ trigger:
77
- build a flow
88
- architect flow
99
- inbound call flow
10-
- inbound chat flow
1110
- inbound email flow
1211
- inbound message flow
1312
- IVR flow
14-
- chat flow
1513
- email flow
14+
- test a bot flow
15+
- test bot flow
1616
- SMS flow
1717
- workflow flow
18+
- bot flow
1819
- digital bot flow
1920
- deploy a flow
2021
---
@@ -40,7 +41,7 @@ If the user already has a flow file and just wants to deploy it, skip straight t
4041
### 1. Understand the requirement
4142

4243
Ask the user:
43-
- **Flow type**: inbound call, inbound chat, inbound email, inbound message (SMS), or workflow
44+
- **Flow type**: inbound call, bot flow, digital bot flow, inbound email, inbound message (SMS), or workflow
4445
- **What it should do**: routing, menus, greetings, queue transfers, data lookups, etc.
4546
- **Flow name**: what to name the flow in Architect
4647

@@ -55,8 +56,9 @@ Before writing any flow code, read these reference files from this skill:
5556
3. **Always read**: `references/action-reference.md` — available action types
5657
4. **Read when the flow uses expressions**: `references/expression-reference.md` — expression language syntax, functions, operators, data types, and common patterns. Read this whenever the flow involves conditional logic, dynamic text, variable manipulation, date/time calculations, or any `setExpression()` / expression property usage.
5758
5. **Read the matching example** from `references/examples/`:
59+
- `bot-flow.md` — bot flow with NLU intent detection, slot filling, and testing
60+
- `digital-bot-flow.md` — digital bot with menu, free-text fallback, and exit
5861
- `inbound-call.md` — IVR with menus and queue transfers
59-
- `inbound-chat.md` — chat greeting and queue transfer
6062
- `inbound-email.md` — auto-reply and queue transfer
6163
- `inbound-message.md` — SMS auto-reply and queue transfer
6264
- `workflow.md` — callback workflow
@@ -115,3 +117,31 @@ The tool spawns an isolated process that:
115117
3. Returns success/failure with SDK logs
116118

117119
If deployment fails, read the error logs carefully — the SDK has three error channels (logging callback, TRACE lines, HTTP errors) and the deploy runner captures all of them.
120+
121+
**Bot flows — publish before testing:** The `deploy_flow` tool checks in the flow but does not publish it. To test a bot flow or digital bot flow with the `test_bot_flow` tool (step 6), the flow must be published first. Replace `flow.checkInAsync()` with `flow.publishAsync()` in the `buildFlow` function — do not call both, because `checkInAsync` releases the lock and `publishAsync` will fail with a 409:
122+
123+
```typescript
124+
return await flow.publishAsync();
125+
```
126+
127+
### 6. Test (bot flows and digital bot flows)
128+
129+
After deploying and publishing a bot flow or digital bot flow, test it using the `test_bot_flow` MCP tool. The deploy result includes the flow ID.
130+
131+
**Start a session:**
132+
```
133+
Tool: test_bot_flow
134+
Input: { "flowId": "<flow-id-from-deploy>" }
135+
```
136+
137+
The tool returns the bot's opening messages and a `sessionId`. Each turn includes `nextActionType`:
138+
- `WaitForInput` — the bot is waiting for a user message
139+
- `Disconnect` / `Exit` — the conversation has ended
140+
141+
**Send a message:**
142+
```
143+
Tool: test_bot_flow
144+
Input: { "sessionId": "<session-id>", "message": "Billing" }
145+
```
146+
147+
Walk through the flow's conversation paths to verify the bot responds correctly. If the bot behaves unexpectedly, update the flow file, re-deploy, re-publish, and test again.

skills/write-flow/references/action-reference.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ reply.setBodyByLiteralString("Thank you for your email.");
6464
### Communicate
6565
```typescript
6666
const comm = actionFactory.addActionCommunicate(container, "Greeting");
67-
comm.communicationExpression.setExpression('"Hello! How can I help?"');
67+
comm.communication.setExpression('"Hello! How can I help?"');
6868
```
6969
Note: use quoted strings inside the expression, NOT `ToAudioTTS()`.
7070

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
# Example: Bot Flow
2+
3+
Bot flow with NLU intent detection, slot filling, and confirmation. Bot flows use `AskForIntent` and `AskForSlot` for natural language conversations — the Genesys Dialog Engine handles intent matching and entity extraction at runtime. After deploying and publishing, use the `test_bot_flow` MCP tool to simulate a text conversation and verify the NLU behaves as expected.
4+
5+
```typescript
6+
import type { ArchitectScripting } from "purecloud-flow-scripting-api-sdk-javascript";
7+
8+
const nluCreationData = {
9+
nluDomainVersion: {
10+
language: "en-us",
11+
intents: [
12+
{
13+
name: "CheckBalance",
14+
utterances: [
15+
{ segments: [{ text: "I want to check my balance" }] },
16+
{ segments: [{ text: "What is my account balance" }] },
17+
{ segments: [{ text: "How much do I owe" }] },
18+
],
19+
},
20+
{
21+
name: "MakePayment",
22+
utterances: [
23+
{ segments: [{ text: "I want to make a payment" }] },
24+
{ segments: [{ text: "Pay my bill" }] },
25+
{ segments: [{ text: "I need to pay" }] },
26+
],
27+
},
28+
],
29+
},
30+
};
31+
32+
export async function buildFlow(scripting: ArchitectScripting) {
33+
const { archFactoryFlows, archFactoryActions, archFactoryTasks } =
34+
scripting.factories;
35+
36+
const flow = await archFactoryFlows.createFlowBotAsync(
37+
"Example Bot Flow",
38+
"Bot flow with NLU intent detection, slot filling, and task routing",
39+
undefined,
40+
undefined,
41+
undefined,
42+
nluCreationData,
43+
);
44+
45+
const initialState = flow.startUpObject;
46+
47+
// Greet the user — bot flows use Communicate with plain string expressions
48+
const greeting = archFactoryActions.addActionCommunicate(
49+
initialState,
50+
"Greeting",
51+
);
52+
greeting.communication.setExpression(
53+
'"Hello! How can I help you today?"',
54+
);
55+
56+
// AskForIntent — the Dialog Engine matches user input to configured intents
57+
const askIntent = archFactoryActions.addActionAskForIntent(
58+
initialState,
59+
"Detect Intent",
60+
);
61+
62+
// Create tasks for each intent — then associate them in botFlowSettings
63+
const balanceTask = archFactoryTasks.addTask(flow, "Check Balance");
64+
const balanceReply = archFactoryActions.addActionCommunicate(
65+
balanceTask,
66+
"Balance Response",
67+
);
68+
balanceReply.communication.setExpression(
69+
'"Let me look up your balance. One moment please."',
70+
);
71+
archFactoryActions.addActionExitBotFlow(balanceTask, "Done");
72+
73+
const paymentTask = archFactoryTasks.addTask(flow, "Make Payment");
74+
const paymentReply = archFactoryActions.addActionCommunicate(
75+
paymentTask,
76+
"Payment Response",
77+
);
78+
paymentReply.communication.setExpression(
79+
'"I can help you make a payment. Let me transfer you to an agent."',
80+
);
81+
archFactoryActions.addActionExitBotFlow(paymentTask, "Done");
82+
83+
// Associate intents with tasks via botFlowSettings
84+
const balanceIntent =
85+
flow.botFlowSettings.getIntentSettingsByIntentName("CheckBalance");
86+
if (balanceIntent) {
87+
balanceIntent.confirmation.setExpression(
88+
'"I think you want to check your balance, is that correct?"',
89+
);
90+
balanceIntent.associateWithTask(balanceTask);
91+
}
92+
93+
const paymentIntent =
94+
flow.botFlowSettings.getIntentSettingsByIntentName("MakePayment");
95+
if (paymentIntent) {
96+
paymentIntent.confirmation.setExpression(
97+
'"You want to make a payment, is that correct?"',
98+
);
99+
paymentIntent.associateWithTask(paymentTask);
100+
}
101+
102+
// Handle no intent detected
103+
const noIntentPath = askIntent.outputNoIntent;
104+
const fallback = archFactoryActions.addActionCommunicate(
105+
noIntentPath,
106+
"No Intent",
107+
);
108+
fallback.communication.setExpression(
109+
'"I\'m sorry, I didn\'t understand that. Could you try rephrasing?"',
110+
);
111+
112+
return await flow.publishAsync();
113+
}
114+
```
115+
116+
## Testing with `test_bot_flow`
117+
118+
Bot flows must be **published** before testing. The example above uses `publishAsync()` which validates, saves, and publishes in one call.
119+
120+
**Start a test session** with the flow ID returned by `deploy_flow`:
121+
```
122+
Tool: test_bot_flow
123+
Input: { "flowId": "<flow-id>" }
124+
```
125+
126+
The bot responds with its greeting and waits for input. Send a message to trigger intent detection:
127+
```
128+
Tool: test_bot_flow
129+
Input: { "sessionId": "<session-id>", "message": "I want to check my balance" }
130+
```
131+
132+
The response includes:
133+
- **Text segments** — the bot's reply (greeting, confirmation, slot prompts)
134+
- **RichMedia segments** — quick reply buttons (e.g. Yes/No for intent confirmation)
135+
- **`nextActionType`**`WaitForInput` (send another message), `Disconnect`/`Exit` (conversation ended)
136+
137+
Walk through each conversation path to verify intent detection, slot filling, and task routing work correctly. The Genesys Cloud UI does not expose this testing capability for Bot Flows.
138+
139+
Key differences from Digital Bot Flows:
140+
- **`createFlowBotAsync`** — creates a bot flow with NLU support via Genesys Dialog Engine
141+
- **`AskForIntent`** — lets the Dialog Engine match user input to configured intents (vs `DigitalMenu` with explicit choices)
142+
- **`AskForSlot`** — prompts for and extracts slot values using NLU entity recognition
143+
- **`botFlowSettings.getIntentSettingsByIntentName()`** — configures confirmation prompts and associates intents with reusable tasks
144+
- **`settingsPrompts`** — bot flows have prompt settings (not available on digital bot flows)

0 commit comments

Comments
 (0)