May 28, 2025
Appsmith is an open-source platform that helps developers quickly create internal apps. It features a framework for dynamic interfaces, intuitive drag-and-drop functionality, and easy widget and API integration, streamlining complex application development. This flexibility accelerates development and enhances user experience with customized, interactive modules.
While Appsmith has great components for building from the ground, Weavy can enhance this experience with power components for AI, chat, collaboration, file sharing and notifications. These components provides extensive functionality powered by a complete, yet customizable UI together with a turn-key backend.
For this example we'll take a look at how to bring in the AI copilot as a Custom Widget in an app, complete with user authentication, styling and connection to any dynamic and interactive data you might have. Weavy provides a built-in AI Agent, but you may configure it to use your own agent using Google Gemini, OpenAI ChatGPT, Anthropic Claude or Kapa.ai.
Assuming you are somewhat familiar with Appsmith, let's start by adding a new app. For this guide we're creating an empty app to keep things clear. You may of course adapt this guide to any existing app you already have, but let's start simple. Once you have created an app and opened it in edit mode, we can move on to start adding Weavy to it.
To get started with Weavy components we first need to set up Authentication for the components. This is always handled securely on the server side. To achieve this we need a datasource that the queries can use in the app. Once you have created the datasource, you can reuse it for all your Weavy queries.
Content-Type
and set the value to application/json
Bearer token
and copy/paste your Weavy API key into the Bearer token field.To be able to authenticate in the Weavy component we are creating, we need to fetch a user access token for the current user.
POST
method and set the URL to /api/users/{{appsmith.user.email}}/tokens
GetWeavyToken
. We will reference this name later.On page load
. This will make the query run asap when the app is starting.To get a more useful experience in the Weavy components, we need to provide some more data about the Appsmith user to Weavy. This way we can get synced names, user details and avatars between Weavy and Appsmith.
/api/users/{{ appsmith.user.email }}
to call the Upsert user endpoint. This endpoint will create or update the user with user data.{
"email": {{ appsmith.user.email }},
"name": {{ appsmith.user.name }},
"picture":
}
On page load
.To have more fun and enhance the AI experience of the Weavy Copilot, we'll create a table with data for the copilot to play with. All contextual Weavy components can take advantage of other components and data in the context surrounding them to enhance their AI powers.
movies
datasource from Sample Datasources. Table
to your canvas.movies
datasource.movies
.title
.MovieTable
.We now have the whole authentication configuration in place and it's time for the more fun part; creating the Weavy component! For this example we are creating an AI copilot which can answer questions about the movie table. You can easily modify the component into a files, posts, chat, comments or messenger component instead.
WeavyCopilot
.[WEAVY_URL]
with the URL to your Weavy environment.{
"url": "[WEAVY_URL]",
"access_token": "{{ GetWeavyToken.data.access_token}}",
"agent": "assistant",
"data": "",
"suggestions": [
"Which movie has the largest revenue?",
"How old is the current movie?"
]
}
onRefresh
.GetWeavyToken
query. This will make the user access token refresh whenever it has expired.appsmith.onReady(async () => {
const { Weavy, WeavyComponents } = await import(appsmith.model.url + "/uikit-web/weavy.esm.js");
// Create a weavy instance
const weavy = new Weavy({
url: appsmith.model.url,
});
const updateFromModel = () => {
// Configure authentication
weavy.tokenFactory = async (refresh) => {
if (refresh) {
appsmith.triggerEvent("onRefresh");
}
return appsmith.model.access_token;
};
// Configure copilot
const copilot = document.querySelector("wy-copilot");
copilot.agent = appsmith.model.agent;
copilot.data = [appsmith.model.data];
// Clear before appending buttons
copilot.innerHTML = "";
// Create a reset button
const resetButton = new WeavyComponents.WyButton();
resetButton.kind = "icon";
resetButton.slot = "actions";
resetButton.onclick = () => copilot.reset();
// Create a reset icon for the button
const resetIcon = new WeavyComponents.WyIcon();
resetIcon.name = "stars";
resetButton.append(resetIcon);
// Add the button
copilot.append(resetButton);
// Set suggestions
appsmith.model.suggestions?.map((suggestion) => {
const sButton = new WeavyComponents.WyButton();
sButton.className = "suggestion";
sButton.slot = "suggestions";
sButton.innerText = suggestion;
copilot.append(sButton);
})
};
updateFromModel()
appsmith.onModelChange((model, prevModel) => {
updateFromModel();
});
});
html, body {
margin: 0;
padding: 0;
}
body {
height: calc(var(--appsmith-ui-height) * 1px);
width: calc(var(--appsmith-ui-width) * 1px);
display: flex;
--wy-theme-color: var(--appsmith-theme-primaryColor);
--wy-border-radius: var(--appsmith-theme-borderRadius);
font-family: system-ui;
}
<wy-copilot></wy-copilot>
Now you have a full Weavy powered copilot in your app, connected to your dynamic data with realtime updates! The users can now analyze the data they are working with using AI in realtime. To further extend the knowledge, other sources of data can be added, and you can provide the AI Agent detailed instructions. Multiple tailored copilots can now easily be placed in any app you have.
Play around with it and try creating other Weavy components, such as chat, files, feeds, comments or a fully featured messenger!
To access live chat with our developer success team you need a Weavy account.