Skip to main content

Widgets APIs

This section provides information on how to use the Widget SDK to add, remove, and modify widgets on a dashboard. The Widget SDK is a powerful tool that allows you to create and manage widgets with ease.

1. Adding a Widget to a Dashboard

To add a widget to a dashboard, you can use the addWidget method. This method returns the widget ID, which can be used to modify the widget later.

const dashboardData = await dashboard.addWidget(dashboardId, query);

The query is the user's Natural Language query, which is used to generate the widget.

2. Removing a Widget from a Dashboard

To retrieve a widget from a dashboard, you can use the removeWidget method. This method removes the widget from the dashboard.

await dashboard.removeWidget(dashboardId, widgetType, widgetNumber);

3. Training a Widget

To train a widget, you can use the train method.

await dashboard.train(agentName, agentDescription, widgetNumber);

4. Searching for a Widget

To search for a widget, you can use the searchWidget method. This method returns an array of widgets that match the search query.

const widgets:[] = await dashboard.searchWidget(dashboardId, query);

5. Add a Trained Widget to a Dashboard

To add a trained widget to a dashboard, you can use the addWidgetFromTraining method.

await dashboard.addWidgetFromTraining(dashboardId, widgetId);