Skip to main content

Headless Mode

Now that you have a basic understanding of how modules and events work, let's combine those skills to see how you can use them to run an agent without the UI (AKA Headless Mode) and use your own UI.

Turning off the UI

First thing you need to do is to turn off the UI module. You can do this either from the Agent Settings UI or by using the SDK. For this example, we'll use the SDK.

// Disable the UI
window.Cartesian('module:disable', 'agent-ui');

Handling the 'recommendations:received' event

Now that the UI is disabled, you can subscribe to the 'recommendations:received' event to get the recommendations and display them in your own UI. You can use this to add recommendations to existing bots/agents' UIs that you might have, but for this example we'll just display the recommendations in the console.

window.Cartesian('subscribe', 'recommendations:received', (recommendations) => {
recommendations.forEach((recommendation) => {
console.log(`Product id: ${recommendation.id}
Title: ${recommendation.title}
Description: ${recommendation.descriptionHtml}
Rating: ${recommendation.rating}
Thumbnail: ${recommendation.thumbnailUrl}
`);
});
});

Horray! You've now created a headless agent! 🤘