Setting the file. One moment.
Subchapter 2.79
references/service-plugin/TOOLS_PROVIDER.mdMarkdown2 KBView on GitHub
The Tools Provider SPI lets your app handle tool invocations from the Wix AI assistant. Implement the runTool handler — it receives the tool’s methodName and a JSON payload, runs your business logic, and returns a response the AI assistant uses to answer the user.
This is the execution side of the App Tools feature. The declaration side lives in the APP_TOOLS extension. See APP_TOOLS.md for the full picture.
Before implementing, call ReadFullDocsMethodSchema on the docs URL to get the full request/response types.
import { toolsProvider } from '@wix/app-tools/service-plugins';
toolsProvider.provideHandlers({
runTool: async ({ request, metadata }) => {
const { methodName, payload } = request;
switch (methodName) {
case 'get-order-status': {
const orderId = payload?.['orderId'];
if (typeof orderId !== 'string' || !orderId) {
throw new Error('orderId is required');
}
// fetch order status...
return {
response: {
status: 'shipped',
trackingNumber: 'TRACK123'
}
};
}
default:
throw new Error(`Unknown tool: ${methodName}`);
}
}
});methodName — use a switch or map to dispatch to the right handler logicrequestSchema is advisory for the AI assistant; Wix does not validate the payload before calling your handlermethodName with activated: true in your APP_TOOLS declaration; unhandled names should throw a clear errorauth.elevate from @wix/essentials