@lowdefy/docs-content 0.0.0-experimental-20260710073520
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/LICENSE +201 -0
- package/README.md +20 -0
- package/content/actions/callapi.md +66 -0
- package/content/actions/callmethod.md +41 -0
- package/content/actions/copytoclipboard.md +32 -0
- package/content/actions/displaymessage.md +53 -0
- package/content/actions/downloadcsv.md +89 -0
- package/content/actions/fetch.md +50 -0
- package/content/actions/geolocationcurrentposition.md +56 -0
- package/content/actions/link.md +104 -0
- package/content/actions/login.md +85 -0
- package/content/actions/logout.md +56 -0
- package/content/actions/pdfmake.md +304 -0
- package/content/actions/request.md +67 -0
- package/content/actions/reset.md +27 -0
- package/content/actions/resetvalidation.md +85 -0
- package/content/actions/scrollto.md +85 -0
- package/content/actions/setdarkmode.md +62 -0
- package/content/actions/setfocus.md +33 -0
- package/content/actions/setglobal.md +63 -0
- package/content/actions/setlocale.md +69 -0
- package/content/actions/setstate.md +70 -0
- package/content/actions/throw.md +72 -0
- package/content/actions/validate.md +87 -0
- package/content/actions/wait.md +24 -0
- package/content/agents/agent-endpoint-tools.md +190 -0
- package/content/agents/agent-mcp-tools.md +124 -0
- package/content/agents/agent-multi-agent.md +136 -0
- package/content/agents/agent-properties.md +174 -0
- package/content/agents/agent-server-hooks.md +336 -0
- package/content/agents/agentchat.md +515 -0
- package/content/agents/agentconversations.md +148 -0
- package/content/concepts/ai-agent-docs.md +190 -0
- package/content/concepts/cli.md +213 -0
- package/content/concepts/connections-and-requests.md +7 -0
- package/content/concepts/custom-html.md +3 -0
- package/content/concepts/custom-styling.md +161 -0
- package/content/concepts/events-and-actions.md +271 -0
- package/content/concepts/hosting-files.md +18 -0
- package/content/concepts/i18n.md +320 -0
- package/content/concepts/keyboard-shortcuts.md +218 -0
- package/content/concepts/layout-overview.md +478 -0
- package/content/concepts/lists.md +144 -0
- package/content/concepts/logger.md +43 -0
- package/content/concepts/lowdefy-schema.md +365 -0
- package/content/concepts/menus.md +144 -0
- package/content/concepts/module-authoring.md +564 -0
- package/content/concepts/modules.md +338 -0
- package/content/concepts/operators.md +45 -0
- package/content/concepts/overview.md +19 -0
- package/content/concepts/references-and-templates.md +207 -0
- package/content/concepts/secrets.md +24 -0
- package/content/concepts/selectors.md +143 -0
- package/content/connections/amazonredshift.md +176 -0
- package/content/connections/anthropic.md +232 -0
- package/content/connections/awss3.md +313 -0
- package/content/connections/azureblobstorage.md +133 -0
- package/content/connections/elasticsearch.md +371 -0
- package/content/connections/google.md +228 -0
- package/content/connections/googlecloudstorage.md +139 -0
- package/content/connections/googlesheet.md +313 -0
- package/content/connections/knex.md +206 -0
- package/content/connections/mariadb.md +177 -0
- package/content/connections/mcp.md +134 -0
- package/content/connections/mongodb.md +739 -0
- package/content/connections/mssql.md +191 -0
- package/content/connections/mysql.md +192 -0
- package/content/connections/openai-connection.md +228 -0
- package/content/connections/postgresql.md +200 -0
- package/content/connections/redis.md +116 -0
- package/content/connections/sendgridmail.md +94 -0
- package/content/connections/smtp.md +149 -0
- package/content/connections/sqlite.md +187 -0
- package/content/connections/stripe.md +115 -0
- package/content/container-blocks/affix.md +413 -0
- package/content/container-blocks/alert.md +937 -0
- package/content/container-blocks/badge.md +1222 -0
- package/content/container-blocks/box.md +1453 -0
- package/content/container-blocks/card.md +1200 -0
- package/content/container-blocks/carousel.md +2247 -0
- package/content/container-blocks/collapse.md +1335 -0
- package/content/container-blocks/configprovider.md +1070 -0
- package/content/container-blocks/confirmmodal.md +1159 -0
- package/content/container-blocks/content.md +597 -0
- package/content/container-blocks/descriptions.md +870 -0
- package/content/container-blocks/drawer.md +1379 -0
- package/content/container-blocks/dropdownmenu.md +643 -0
- package/content/container-blocks/flex.md +1510 -0
- package/content/container-blocks/footer.md +380 -0
- package/content/container-blocks/googlemaps.md +546 -0
- package/content/container-blocks/googlemapsheatmap.md +607 -0
- package/content/container-blocks/googlemapsscript.md +61 -0
- package/content/container-blocks/header.md +302 -0
- package/content/container-blocks/label.md +739 -0
- package/content/container-blocks/layout.md +604 -0
- package/content/container-blocks/masonry.md +1090 -0
- package/content/container-blocks/mobilemenu.md +1244 -0
- package/content/container-blocks/modal.md +1180 -0
- package/content/container-blocks/pageheadermenu.md +614 -0
- package/content/container-blocks/pagesidebarlayout.md +438 -0
- package/content/container-blocks/pagesidermenu.md +651 -0
- package/content/container-blocks/popover.md +1421 -0
- package/content/container-blocks/result.md +972 -0
- package/content/container-blocks/sider.md +1064 -0
- package/content/container-blocks/span.md +747 -0
- package/content/container-blocks/spinner.md +267 -0
- package/content/container-blocks/splitter.md +1735 -0
- package/content/container-blocks/tabs.md +1718 -0
- package/content/container-blocks/tooltip.md +1274 -0
- package/content/container-blocks/watermark.md +515 -0
- package/content/controls/for.md +103 -0
- package/content/controls/if.md +107 -0
- package/content/controls/log.md +50 -0
- package/content/controls/parallel.md +71 -0
- package/content/controls/parallel_for.md +36 -0
- package/content/controls/reject.md +56 -0
- package/content/controls/return.md +66 -0
- package/content/controls/set_state.md +98 -0
- package/content/controls/switch.md +90 -0
- package/content/controls/throw.md +79 -0
- package/content/controls/try.md +88 -0
- package/content/deployment/docker.md +149 -0
- package/content/deployment/node-server.md +27 -0
- package/content/deployment/vercel.md +101 -0
- package/content/display-blocks/aggrid.md +1459 -0
- package/content/display-blocks/anchor.md +336 -0
- package/content/display-blocks/avatar.md +1154 -0
- package/content/display-blocks/breadcrumb.md +517 -0
- package/content/display-blocks/button.md +758 -0
- package/content/display-blocks/calendar.md +156 -0
- package/content/display-blocks/dangeroushtml.md +314 -0
- package/content/display-blocks/dangerousmarkdown.md +423 -0
- package/content/display-blocks/diffgit.md +44 -0
- package/content/display-blocks/difflist.md +225 -0
- package/content/display-blocks/diffsidebyside.md +56 -0
- package/content/display-blocks/difftimeline.md +94 -0
- package/content/display-blocks/divider.md +406 -0
- package/content/display-blocks/download.md +60 -0
- package/content/display-blocks/dropdownbutton.md +661 -0
- package/content/display-blocks/echart.md +418 -0
- package/content/display-blocks/floatbutton.md +545 -0
- package/content/display-blocks/html.md +311 -0
- package/content/display-blocks/icon.md +717 -0
- package/content/display-blocks/img.md +479 -0
- package/content/display-blocks/markdown.md +520 -0
- package/content/display-blocks/markdownwithcode.md +730 -0
- package/content/display-blocks/menu.md +1123 -0
- package/content/display-blocks/message.md +941 -0
- package/content/display-blocks/notification.md +1410 -0
- package/content/display-blocks/paragraph.md +643 -0
- package/content/display-blocks/progress.md +818 -0
- package/content/display-blocks/qrcode.md +519 -0
- package/content/display-blocks/s3download.md +240 -0
- package/content/display-blocks/search.md +360 -0
- package/content/display-blocks/skeleton.md +272 -0
- package/content/display-blocks/skeletonavatar.md +222 -0
- package/content/display-blocks/skeletonbutton.md +245 -0
- package/content/display-blocks/skeletoninput.md +223 -0
- package/content/display-blocks/skeletonparagraph.md +201 -0
- package/content/display-blocks/statistic.md +485 -0
- package/content/display-blocks/steps.md +585 -0
- package/content/display-blocks/tag.md +620 -0
- package/content/display-blocks/title.md +654 -0
- package/content/display-blocks/tour.md +2359 -0
- package/content/input-blocks/autocomplete.md +786 -0
- package/content/input-blocks/buttonselector.md +964 -0
- package/content/input-blocks/checkboxselector.md +765 -0
- package/content/input-blocks/checkboxswitch.md +497 -0
- package/content/input-blocks/colorselector.md +884 -0
- package/content/input-blocks/daterangeselector.md +777 -0
- package/content/input-blocks/dateselector.md +693 -0
- package/content/input-blocks/datetimeselector.md +791 -0
- package/content/input-blocks/inputgallery.md +528 -0
- package/content/input-blocks/monthselector.md +717 -0
- package/content/input-blocks/multipleselector.md +1337 -0
- package/content/input-blocks/numberinput.md +855 -0
- package/content/input-blocks/pagination.md +679 -0
- package/content/input-blocks/paragraphinput.md +1664 -0
- package/content/input-blocks/passwordinput.md +480 -0
- package/content/input-blocks/phonenumberinput.md +688 -0
- package/content/input-blocks/radioselector.md +820 -0
- package/content/input-blocks/ratingslider.md +684 -0
- package/content/input-blocks/s3uploadbutton.md +384 -0
- package/content/input-blocks/s3uploaddragger.md +305 -0
- package/content/input-blocks/s3uploadphoto.md +288 -0
- package/content/input-blocks/segmentedselector.md +782 -0
- package/content/input-blocks/selector.md +1162 -0
- package/content/input-blocks/switch.md +552 -0
- package/content/input-blocks/textarea.md +714 -0
- package/content/input-blocks/textinput.md +639 -0
- package/content/input-blocks/tiptapinput.md +226 -0
- package/content/input-blocks/tiptapmentioninput.md +471 -0
- package/content/input-blocks/titleinput.md +1094 -0
- package/content/input-blocks/treeinput.md +144 -0
- package/content/input-blocks/treemultipleselector.md +162 -0
- package/content/input-blocks/treeselector.md +185 -0
- package/content/input-blocks/upload.md +149 -0
- package/content/input-blocks/uploaddragger.md +85 -0
- package/content/input-blocks/uploadphoto.md +84 -0
- package/content/input-blocks/weekselector.md +630 -0
- package/content/list-blocks/controlledlist.md +498 -0
- package/content/list-blocks/list.md +529 -0
- package/content/list-blocks/listselector.md +301 -0
- package/content/list-blocks/masonrylist.md +230 -0
- package/content/migration/upgrade-guide.md +106 -0
- package/content/migration/v4-to-v5.md +589 -0
- package/content/migration/v5-to-v6.md +36 -0
- package/content/operators/_actions.md +58 -0
- package/content/operators/_and.md +76 -0
- package/content/operators/_api.md +254 -0
- package/content/operators/_app.md +114 -0
- package/content/operators/_args.md +65 -0
- package/content/operators/_array.md +331 -0
- package/content/operators/_base64.md +49 -0
- package/content/operators/_boolean.md +33 -0
- package/content/operators/_build.md +166 -0
- package/content/operators/_change_case.md +357 -0
- package/content/operators/_date.md +415 -0
- package/content/operators/_dayjs.md +128 -0
- package/content/operators/_diff.md +61 -0
- package/content/operators/_divide.md +32 -0
- package/content/operators/_eq.md +52 -0
- package/content/operators/_event.md +86 -0
- package/content/operators/_function.md +52 -0
- package/content/operators/_get.md +92 -0
- package/content/operators/_global.md +86 -0
- package/content/operators/_gt.md +50 -0
- package/content/operators/_gte.md +50 -0
- package/content/operators/_hash.md +112 -0
- package/content/operators/_if.md +30 -0
- package/content/operators/_if_none.md +47 -0
- package/content/operators/_index.md +48 -0
- package/content/operators/_input.md +86 -0
- package/content/operators/_intl.md +135 -0
- package/content/operators/_item.md +166 -0
- package/content/operators/_js.md +113 -0
- package/content/operators/_json.md +120 -0
- package/content/operators/_jsonata.md +152 -0
- package/content/operators/_locale.md +65 -0
- package/content/operators/_location.md +40 -0
- package/content/operators/_log.md +22 -0
- package/content/operators/_lt.md +50 -0
- package/content/operators/_lte.md +50 -0
- package/content/operators/_math.md +407 -0
- package/content/operators/_media.md +83 -0
- package/content/operators/_menu.md +62 -0
- package/content/operators/_module.md +340 -0
- package/content/operators/_mql.md +95 -0
- package/content/operators/_ne.md +62 -0
- package/content/operators/_not.md +33 -0
- package/content/operators/_number.md +159 -0
- package/content/operators/_nunjucks.md +117 -0
- package/content/operators/_object.md +253 -0
- package/content/operators/_operator.md +33 -0
- package/content/operators/_or.md +67 -0
- package/content/operators/_product.md +45 -0
- package/content/operators/_random.md +90 -0
- package/content/operators/_ref.md +80 -0
- package/content/operators/_regex.md +69 -0
- package/content/operators/_request.md +35 -0
- package/content/operators/_request_details.md +29 -0
- package/content/operators/_secret.md +56 -0
- package/content/operators/_state.md +134 -0
- package/content/operators/_step.md +98 -0
- package/content/operators/_string.md +327 -0
- package/content/operators/_subtract.md +24 -0
- package/content/operators/_sum.md +45 -0
- package/content/operators/_switch.md +37 -0
- package/content/operators/_t.md +96 -0
- package/content/operators/_theme.md +65 -0
- package/content/operators/_type.md +78 -0
- package/content/operators/_uri.md +49 -0
- package/content/operators/_url_query.md +92 -0
- package/content/operators/_user.md +154 -0
- package/content/operators/_uuid.md +118 -0
- package/content/operators/_var.md +88 -0
- package/content/operators/_yaml.md +96 -0
- package/content/other/introduction.md +39 -0
- package/content/other/next-auth-providers.md +3 -0
- package/content/other/updatesession.md +26 -0
- package/content/plugins/plugins-actions.md +80 -0
- package/content/plugins/plugins-connections.md +98 -0
- package/content/plugins/plugins-dev.md +138 -0
- package/content/plugins/plugins-introduction.md +29 -0
- package/content/plugins/plugins-operators.md +71 -0
- package/content/testing/e2e-auth.md +108 -0
- package/content/testing/e2e-configuration.md +107 -0
- package/content/testing/e2e-getting-started.md +96 -0
- package/content/testing/e2e-introduction.md +53 -0
- package/content/testing/e2e-mocking.md +155 -0
- package/content/testing/e2e-writing-tests.md +214 -0
- package/content/tutorial/tutorial-actions-operators.md +222 -0
- package/content/tutorial/tutorial-add-blocks.md +86 -0
- package/content/tutorial/tutorial-create-page.md +57 -0
- package/content/tutorial/tutorial-display-data-page.md +181 -0
- package/content/tutorial/tutorial-next-steps.md +53 -0
- package/content/tutorial/tutorial-requests-sql.md +22 -0
- package/content/tutorial/tutorial-start.md +71 -0
- package/content/user-authentication/auth-providers.md +15 -0
- package/content/user-authentication/login-and-logout.md +122 -0
- package/content/user-authentication/users-introduction.md +31 -0
- package/index.json +2281 -0
- package/package.json +34 -0
- package/scripts/extractAgentDocs.js +130 -0
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
# Server Hooks
|
|
2
|
+
|
|
3
|
+
Hooks let you run [API endpoints](/lowdefy-api) at specific points during the agent's execution. Use them for logging, saving conversations, generating titles, or any side effect that should happen server-side.
|
|
4
|
+
|
|
5
|
+
## Defining Hooks
|
|
6
|
+
|
|
7
|
+
Hooks are defined in the agent's `hooks` object. Each hook is an array of endpoint `id` strings:
|
|
8
|
+
|
|
9
|
+
```yaml
|
|
10
|
+
agents:
|
|
11
|
+
- id: assistant
|
|
12
|
+
type: ClaudeAgent
|
|
13
|
+
connectionId: anthropic
|
|
14
|
+
properties:
|
|
15
|
+
model: claude-sonnet-4-20250514
|
|
16
|
+
hooks:
|
|
17
|
+
onFinish:
|
|
18
|
+
- save-conversation
|
|
19
|
+
- generate-title
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Hook Types
|
|
23
|
+
|
|
24
|
+
- `hooks: object`:
|
|
25
|
+
- `onStart: string[]`: Before the first model call.
|
|
26
|
+
- `onStepStart: string[]`: Before each step in the tool loop.
|
|
27
|
+
- `onToolCallStart: string[]`: Before a tool is executed.
|
|
28
|
+
- `onToolCallFinish: string[]`: After a tool finishes.
|
|
29
|
+
- `onStepFinish: string[]`: After each step completes.
|
|
30
|
+
- `onFinish: string[]`: After the agent completes. __Awaited__ — the stream stays open. Can return data parts.
|
|
31
|
+
|
|
32
|
+
| Hook | When it fires |
|
|
33
|
+
| --- | --- |
|
|
34
|
+
| `onStart` | Once, before the first model call. |
|
|
35
|
+
| `onStepStart` | Before each step in the tool loop. |
|
|
36
|
+
| `onToolCallStart` | Before each tool is executed. |
|
|
37
|
+
| `onToolCallFinish` | After each tool finishes. |
|
|
38
|
+
| `onStepFinish` | After each step completes. |
|
|
39
|
+
| `onFinish` | Once, after the agent completes its response. |
|
|
40
|
+
|
|
41
|
+
## The onFinish Hook
|
|
42
|
+
|
|
43
|
+
`onFinish` is special in two ways:
|
|
44
|
+
|
|
45
|
+
1. **It is awaited** — the response stream stays open until all `onFinish` endpoints complete. This guarantees the conversation is saved before the client considers the response finished.
|
|
46
|
+
2. **It can return data parts** — endpoints can return `dataParts` that are sent to the [`AgentChat`](/AgentChat) block as `onDataPart` events. This is how you send generated titles and other metadata back to the browser.
|
|
47
|
+
|
|
48
|
+
### onFinish Payload
|
|
49
|
+
|
|
50
|
+
The hook endpoint receives the full turn in `_payload`:
|
|
51
|
+
|
|
52
|
+
| Field | Type | Description |
|
|
53
|
+
| --- | --- | --- |
|
|
54
|
+
| `messages` | array | The full conversation as `UIMessage[]`, **including the agent's latest assistant reply** (with any tool parts). Upsert this by `conversationId` to persist the whole thread. |
|
|
55
|
+
| `steps` | array | One entry per agent step. Each step has `stepNumber`, `text`, `toolCalls`, `toolResults`, and `finishReason`. |
|
|
56
|
+
| `toolResults` | array | Flattened tool results across all steps — convenience for hooks that only care about what tools returned. |
|
|
57
|
+
| `finishReason` | string | Why the agent stopped (e.g. `'stop'`, `'tool-calls'`, `'length'`). |
|
|
58
|
+
| `isAborted` | boolean | `true` if the client cancelled the request. |
|
|
59
|
+
| `usage` | object | Token usage for the turn: `inputTokens`, `outputTokens`, `totalTokens`, `reasoningTokens`, `cacheReadTokens`, `cacheWriteTokens`. |
|
|
60
|
+
| `pageId`, `agentId`, `conversationId`, `userId`, `urlQuery`, `sharedState` | | Context values mirrored from the request, **at the top level** of the payload. |
|
|
61
|
+
|
|
62
|
+
Read these fields at the **top level** of `_payload` (e.g. `_payload: conversationId`, `_payload: usage`) — they are not nested under an `agentContext` key.
|
|
63
|
+
|
|
64
|
+
Use `steps` or `toolResults` to drive agent → page sync — for example, returning a `data-...` part that a form block consumes via `onDataPart`.
|
|
65
|
+
|
|
66
|
+
## Saving Conversations
|
|
67
|
+
|
|
68
|
+
The most common use of `onFinish` is persisting the conversation to a database. The hook endpoint receives the conversation data in its payload:
|
|
69
|
+
|
|
70
|
+
```yaml
|
|
71
|
+
agents:
|
|
72
|
+
- id: assistant
|
|
73
|
+
type: ClaudeAgent
|
|
74
|
+
connectionId: anthropic
|
|
75
|
+
properties:
|
|
76
|
+
model: claude-sonnet-4-20250514
|
|
77
|
+
hooks:
|
|
78
|
+
onFinish:
|
|
79
|
+
- save-conversation
|
|
80
|
+
|
|
81
|
+
api:
|
|
82
|
+
- id: save-conversation
|
|
83
|
+
type: Api
|
|
84
|
+
description: Persist the conversation to MongoDB.
|
|
85
|
+
routine:
|
|
86
|
+
- id: save
|
|
87
|
+
type: MongoDBUpdateOne
|
|
88
|
+
connectionId: app_db
|
|
89
|
+
properties:
|
|
90
|
+
collection: conversations
|
|
91
|
+
filter:
|
|
92
|
+
_id:
|
|
93
|
+
_payload: conversationId
|
|
94
|
+
update:
|
|
95
|
+
$set:
|
|
96
|
+
messages:
|
|
97
|
+
_payload: messages
|
|
98
|
+
userId:
|
|
99
|
+
_payload: userId
|
|
100
|
+
updatedAt:
|
|
101
|
+
_date: now
|
|
102
|
+
$setOnInsert:
|
|
103
|
+
createdAt:
|
|
104
|
+
_date: now
|
|
105
|
+
options:
|
|
106
|
+
upsert: true
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## Generating Titles
|
|
110
|
+
|
|
111
|
+
> **Built-in option:** set the agent's [`generateTitle`](/agent-properties) property to `true` and Lowdefy generates a short title from the first user message automatically, emitting the `data-chat-title` part for you. The manual approach below is only needed when you want custom title logic.
|
|
112
|
+
|
|
113
|
+
Use a `data-chat-title` data part to send a generated title back to the client. The [`AgentChat`](/AgentChat) block fires an `onTitleGenerated` event when it receives this data part.
|
|
114
|
+
|
|
115
|
+
```yaml
|
|
116
|
+
agents:
|
|
117
|
+
- id: assistant
|
|
118
|
+
type: ClaudeAgent
|
|
119
|
+
connectionId: anthropic
|
|
120
|
+
properties:
|
|
121
|
+
model: claude-sonnet-4-20250514
|
|
122
|
+
hooks:
|
|
123
|
+
onFinish:
|
|
124
|
+
- save-conversation
|
|
125
|
+
- generate-title
|
|
126
|
+
|
|
127
|
+
api:
|
|
128
|
+
- id: generate-title
|
|
129
|
+
type: Api
|
|
130
|
+
description: Generate a title and send it to the client.
|
|
131
|
+
routine:
|
|
132
|
+
# Your title generation logic here — could be another
|
|
133
|
+
# model call, a simple extraction, or a database lookup.
|
|
134
|
+
- :return:
|
|
135
|
+
dataParts:
|
|
136
|
+
- type: data-chat-title
|
|
137
|
+
data:
|
|
138
|
+
title:
|
|
139
|
+
_payload: generatedTitle
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
On the client side, handle it with the `onTitleGenerated` event:
|
|
143
|
+
|
|
144
|
+
```yaml
|
|
145
|
+
- id: chat
|
|
146
|
+
type: AgentChat
|
|
147
|
+
properties:
|
|
148
|
+
agentId: assistant
|
|
149
|
+
events:
|
|
150
|
+
onTitleGenerated:
|
|
151
|
+
- id: update_sidebar
|
|
152
|
+
type: SetState
|
|
153
|
+
params:
|
|
154
|
+
conversationTitle:
|
|
155
|
+
_event: title
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
## Custom Data Parts
|
|
159
|
+
|
|
160
|
+
Beyond titles, you can return any custom data from `onFinish` hooks. Each data part has a `type` and `data` field. The [`AgentChat`](/AgentChat) block fires `onDataPart` for every data part received:
|
|
161
|
+
|
|
162
|
+
###### Return dynamic follow-up suggestions:
|
|
163
|
+
```yaml
|
|
164
|
+
api:
|
|
165
|
+
- id: generate-suggestions
|
|
166
|
+
type: Api
|
|
167
|
+
description: Generate follow-up suggestions based on the conversation.
|
|
168
|
+
routine:
|
|
169
|
+
- :return:
|
|
170
|
+
dataParts:
|
|
171
|
+
- type: data-suggestions
|
|
172
|
+
data:
|
|
173
|
+
suggestions:
|
|
174
|
+
- label: Tell me more about this
|
|
175
|
+
- label: What are the alternatives?
|
|
176
|
+
- label: How much does it cost?
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
###### Handle custom data parts on the client:
|
|
180
|
+
```yaml
|
|
181
|
+
events:
|
|
182
|
+
onDataPart:
|
|
183
|
+
- id: handle_analytics
|
|
184
|
+
type: Request
|
|
185
|
+
skip:
|
|
186
|
+
_ne:
|
|
187
|
+
- _event: type
|
|
188
|
+
- data-analytics
|
|
189
|
+
params:
|
|
190
|
+
- track_conversation
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
## Full Example
|
|
194
|
+
|
|
195
|
+
A complete agent setup with conversation persistence, title generation, and the chat UI:
|
|
196
|
+
|
|
197
|
+
```yaml
|
|
198
|
+
connections:
|
|
199
|
+
- id: anthropic
|
|
200
|
+
type: Anthropic
|
|
201
|
+
properties:
|
|
202
|
+
apiKey:
|
|
203
|
+
_secret: ANTHROPIC_API_KEY
|
|
204
|
+
- id: app_db
|
|
205
|
+
type: MongoDBCollection
|
|
206
|
+
properties:
|
|
207
|
+
databaseUri:
|
|
208
|
+
_secret: MONGODB_URI
|
|
209
|
+
collection: products
|
|
210
|
+
|
|
211
|
+
agents:
|
|
212
|
+
- id: support_agent
|
|
213
|
+
type: ClaudeAgent
|
|
214
|
+
connectionId: anthropic
|
|
215
|
+
properties:
|
|
216
|
+
model: claude-sonnet-4-20250514
|
|
217
|
+
instructions: |
|
|
218
|
+
You are a support agent for an online store. Help customers
|
|
219
|
+
find products, check order status, and answer questions.
|
|
220
|
+
Always be friendly and concise.
|
|
221
|
+
maxSteps: 5
|
|
222
|
+
tools:
|
|
223
|
+
- search-products
|
|
224
|
+
- endpointId: create-ticket
|
|
225
|
+
confirm: true
|
|
226
|
+
hooks:
|
|
227
|
+
onFinish:
|
|
228
|
+
- save-conversation
|
|
229
|
+
|
|
230
|
+
api:
|
|
231
|
+
- id: search-products
|
|
232
|
+
type: Api
|
|
233
|
+
description: Search for products by name or category.
|
|
234
|
+
payloadSchema:
|
|
235
|
+
type: object
|
|
236
|
+
properties:
|
|
237
|
+
query:
|
|
238
|
+
type: string
|
|
239
|
+
description: Search term for product name or category.
|
|
240
|
+
required:
|
|
241
|
+
- query
|
|
242
|
+
routine:
|
|
243
|
+
- id: find
|
|
244
|
+
type: MongoDBFind
|
|
245
|
+
connectionId: app_db
|
|
246
|
+
properties:
|
|
247
|
+
query:
|
|
248
|
+
name:
|
|
249
|
+
$regex:
|
|
250
|
+
_payload: query
|
|
251
|
+
$options: i
|
|
252
|
+
options:
|
|
253
|
+
limit: 5
|
|
254
|
+
- :return:
|
|
255
|
+
_step: find
|
|
256
|
+
|
|
257
|
+
- id: create-ticket
|
|
258
|
+
type: Api
|
|
259
|
+
description: Create a support ticket for issues needing human follow-up.
|
|
260
|
+
payloadSchema:
|
|
261
|
+
type: object
|
|
262
|
+
properties:
|
|
263
|
+
subject:
|
|
264
|
+
type: string
|
|
265
|
+
description: Short summary of the issue.
|
|
266
|
+
description:
|
|
267
|
+
type: string
|
|
268
|
+
description: Detailed description.
|
|
269
|
+
required:
|
|
270
|
+
- subject
|
|
271
|
+
- description
|
|
272
|
+
routine:
|
|
273
|
+
- id: insert
|
|
274
|
+
type: MongoDBInsertOne
|
|
275
|
+
connectionId: app_db
|
|
276
|
+
properties:
|
|
277
|
+
doc:
|
|
278
|
+
subject:
|
|
279
|
+
_payload: subject
|
|
280
|
+
description:
|
|
281
|
+
_payload: description
|
|
282
|
+
status: open
|
|
283
|
+
createdAt:
|
|
284
|
+
_date: now
|
|
285
|
+
- :return:
|
|
286
|
+
ticketId:
|
|
287
|
+
_step: insert.insertedId
|
|
288
|
+
|
|
289
|
+
- id: save-conversation
|
|
290
|
+
type: Api
|
|
291
|
+
description: Save the conversation after each response.
|
|
292
|
+
routine:
|
|
293
|
+
- id: save
|
|
294
|
+
type: MongoDBUpdateOne
|
|
295
|
+
connectionId: app_db
|
|
296
|
+
properties:
|
|
297
|
+
collection: conversations
|
|
298
|
+
filter:
|
|
299
|
+
_id:
|
|
300
|
+
_payload: conversationId
|
|
301
|
+
update:
|
|
302
|
+
$set:
|
|
303
|
+
messages:
|
|
304
|
+
_payload: messages
|
|
305
|
+
updatedAt:
|
|
306
|
+
_date: now
|
|
307
|
+
$setOnInsert:
|
|
308
|
+
createdAt:
|
|
309
|
+
_date: now
|
|
310
|
+
options:
|
|
311
|
+
upsert: true
|
|
312
|
+
|
|
313
|
+
pages:
|
|
314
|
+
- id: support
|
|
315
|
+
type: PageHeaderMenu
|
|
316
|
+
properties:
|
|
317
|
+
title: Support
|
|
318
|
+
blocks:
|
|
319
|
+
- id: chat
|
|
320
|
+
type: AgentChat
|
|
321
|
+
properties:
|
|
322
|
+
agentId: support_agent
|
|
323
|
+
welcome:
|
|
324
|
+
title: How can we help?
|
|
325
|
+
description: Ask about products, orders, or returns.
|
|
326
|
+
prompts:
|
|
327
|
+
- label: Find a product
|
|
328
|
+
description: Search our catalog
|
|
329
|
+
- label: I have an issue
|
|
330
|
+
description: Get help with a problem
|
|
331
|
+
messageDisplay:
|
|
332
|
+
toolResultDisplay: summary
|
|
333
|
+
actions:
|
|
334
|
+
copy: true
|
|
335
|
+
feedback: true
|
|
336
|
+
```
|