Skip to content

Commit 3970165

Browse files
authored
feat(ai-agents/flow-builder): Add target attribute in buttons coming from AI Agent (#3188)
## Description Add a new target attribute in the textWithButtons output schema in the AI Agent plugin and make them reach the render of the FlowButton in Flow Builder plugin so an URL button can open the link within the same window if stated in the AI Agent prompt. ## Context Through the AI Agent prompt there was no way to make a URL button to open the website within the same window as the webchat. ## Testing The pull request has unit tests.
1 parent bab2e9d commit 3970165

File tree

12 files changed

+62
-11
lines changed

12 files changed

+62
-11
lines changed

package-lock.json

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

packages/botonic-core/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ All notable changes to Botonic will be documented in this file.
2525
### Added
2626

2727
- [PR-3186](https://github.com/hubtype/botonic/pull/3186) Make some AI Agents types generic to allow adding new output message types.
28+
- [PR-3188](https://github.com/hubtype/botonic/pull/3188) Add `target` attribute in `Button` interface.
2829

2930
## [0.46.0] - 2026-03-17
3031

packages/botonic-core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@botonic/core",
3-
"version": "0.46.0",
3+
"version": "0.46.1",
44
"license": "MIT",
55
"description": "Build Chatbots using React",
66
"main": "./lib/cjs/index.js",

packages/botonic-core/src/models/ai-agents.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export interface Button {
1414
text: string
1515
payload?: string
1616
url?: string
17+
target?: string
1718
}
1819
export interface ButtonWithPayload {
1920
text: string

packages/botonic-plugin-ai-agents/CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ All notable changes to Botonic will be documented in this file.
2424

2525
### Added
2626

27-
- [PR-3186](https://github.com/hubtype/botonic/pull/3186) Make output schemas extendable
27+
- [PR-3186](https://github.com/hubtype/botonic/pull/3186) Make output schemas extendable.
28+
- [PR-3188](https://github.com/hubtype/botonic/pull/3188) Add `target` attribute in buttons of `TextWithButtonsSchema`.
2829

2930
## [0.46.0] - 2026-03-17
3031

packages/botonic-plugin-ai-agents/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@botonic/plugin-ai-agents",
3-
"version": "0.46.0",
3+
"version": "0.46.1",
44
"main": "./lib/cjs/index.js",
55
"module": "./lib/esm/index.js",
66
"description": "Use AI Agents to generate your contents",
@@ -14,7 +14,7 @@
1414
"format": "biome format --write src/ tests/"
1515
},
1616
"dependencies": {
17-
"@botonic/core": "^0.46.0",
17+
"@botonic/core": "^0.46.1",
1818
"@openai/agents": "^0.3.9",
1919
"axios": "^1.13.6",
2020
"openai": "^6.0.0",

packages/botonic-plugin-ai-agents/src/structured-output/text-with-buttons.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@ export const TextWithButtonsSchema = z
1212
z.object({
1313
text: z.string(),
1414
url: z.string().nullable().optional(),
15+
target: z
16+
.enum(['_blank', '_self'])
17+
.default('_blank')
18+
.nullable()
19+
.optional()
20+
.describe(
21+
'The target of the button when it has an url. If not provided, it will default to _blank.'
22+
),
1523
})
1624
),
1725
}),

packages/botonic-plugin-flow-builder/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ All notable changes to Botonic will be documented in this file.
2525
### Added
2626

2727
- [PR-3186](https://github.com/hubtype/botonic/pull/3186) Allow AI Agent to return Flow Builder contents directly.
28+
- [PR-3188](https://github.com/hubtype/botonic/pull/3188) Allow `target` attribute in buttons coming from AI Agent responses.
2829

2930
## [0.46.1] - 2026-03-18
3031

packages/botonic-plugin-flow-builder/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@botonic/plugin-flow-builder",
3-
"version": "0.46.1",
3+
"version": "0.46.2",
44
"main": "./lib/cjs/index.js",
55
"module": "./lib/esm/index.js",
66
"description": "Use Flow Builder to show your contents",

packages/botonic-plugin-flow-builder/src/content-fields/flow-button.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,13 @@ export class FlowButton extends ContentFieldsBase {
9292
text: string
9393
payload?: string
9494
url?: string
95+
target?: string
9596
}): FlowButton {
9697
const newButton = new FlowButton(button.id)
9798
newButton.text = button.text
9899
if (button.url) {
99100
newButton.url = button.url
101+
newButton.target = button.target
100102
} else {
101103
newButton.payload = button.payload
102104
}

0 commit comments

Comments
 (0)