Register a tool handler
Register the handler for a dashboard-defined Frontend tool. Use the tool’s runtime name shown in the tool editor.- The handler receives the parameters configured in the dashboard as a map, filled with the values the AI collected.
- Return a
Stringor a JSON-encodable object (objects are stringified). The result is sent back to the AI, which uses it to reply. - Async handlers are fully supported — the AI waits for the returned future.
- Thrown errors are caught and reported to the AI automatically.
- If no handler is registered for a tool, the AI is informed so it can respond accordingly.
- Works on Android, iOS and Web.
Execution modes
Set per tool in the dashboard:Auto— the handler runs immediately when the AI calls the tool.Ask before final execution— the AI adds a confirmation button to its reply; the handler only runs after the user confirms.
Migrating from setAiTools
Gleap.setAiTools(tools: ...) and the AITool / AIToolParams classes have been removed. Tools defined via setAiTools could only return a static response to the AI — Frontend tools execute real code and return live results. Define your tools on the AI agent in the dashboard and register their handlers via Gleap.registerAgentTool(name:, handler:) instead. The toolExecution listener remains available.