Skip to content

Commit f107c25

Browse files
committed
feat(ai-agents,core,flow-builder): add new optional attribute named 'target' in buttons generated by AI Agents to be able to specify the target of URL buttons (_blank or _self)
1 parent 88a52ee commit f107c25

4 files changed

Lines changed: 12 additions & 0 deletions

File tree

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/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/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
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ export class FlowText extends ContentFieldsBase {
5757
id: `${id}-button-${buttonIndex}`,
5858
text: button.text,
5959
url: button.url,
60+
target: button.target,
6061
payload:
6162
button.payload ||
6263
`${EMPTY_PAYLOAD}${SOURCE_INFO_SEPARATOR}${buttonIndex}`,

0 commit comments

Comments
 (0)