agent-platform-bm-sdk
is a library designed to facilitate interaction with a platform's agent within a Domain Assistant Tool. It provides a way to report events and errors to the platform, and to invoke side effects.
Add to your Assistant App, the GENIE.PUBLISH_ASSISTANT_SIDE_EFFECT
permission
In the tools execute function use this:
execute: async (params, ctx) => {
const APP_SECRET = ctx.getConfig('app-secret')!
ctx.apiGatewayClient.signWith('<PASTE_APP_DEF_ID>', APP_SECRET)
const signedAspects = await ctx.apiGatewayClient.addServiceIdentitySafe(ctx.aspects)
const data = {
url: 'http://www.wix.com'
}
await ctx.invokeSideEffect(
'your-event-name', //Like 'navigate-to' - must match this regex `^[A-Za-z0-9_-]+$`
data,
signedAspects
)
Add this code to your BM app when you want to receive event on the client (like navigate)
import { useAssistantEffect } from '@wix/agent-platform-bm-sdk';
// ...
useAssistantEffect<{url: string}>(
({url}) => {
console.log({url});
window.open(url);
},
'your-app-def-id',
'your-event-name', //like 'navigate-to'
);
- In
Advanced Assistant Configuration
(initial screen) register a side effect listener. - In chat trigger side effect from the tool or widget.
- Expect browser alert with emitted side effect data.