---
title: "Ionic Capacitor SDK: Frontend tools"
description: "Connect AI agent frontend tools to your application with the Gleap Ionic Capacitor SDK. Follow the integration code examples."
url: https://docs.gleap.ai/en/articles/565-ionic-capacitor-sdk-frontend-tools
collection: "Ionic / Capacitor"
updated: 2026-11-01
language: en
---

# Ionic Capacitor SDK: Frontend tools

Connect AI agent frontend tools to your application with the Gleap Ionic Capacitor SDK. Follow the integration code examples.

_Tags_: Ionic, Capacitor

Frontend tools let your AI agent execute actions directly inside your app — initiating a transfer, resetting a password, cancelling an order, etc.

Define the tool under AI agents → your agent → Settings → Tools → Add tool → Frontend tool. Its name, description, parameters and execution mode live there. Your app registers the matching runtime handler. See the linked help guide for the current setup. [Frontend tools setup guide](https://help.gleap.ai/en/articles/251-let-an-agent-run-actions-inside-your-app)

## Register a tool handler

Register the handler for a dashboard-defined Frontend tool with the `registerAgentTool` helper. Use the tool's runtime name shown in the tool editor.

```js
import { registerAgentTool } from "capacitor-gleap-plugin";

await registerAgentTool("send-money", async ({ amount, contact }) => {
  // Run your own logic here.

  // Return a string or JSON — the AI waits for this response.
  return "The transfer was initiated. The user must confirm it in the banking app.";
});
```

**Handler contract**

-   The handler receives the parameters configured in the dashboard, filled with the values the AI collected.
    
-   Return a string or a JSON-serializable 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 promise.
    
-   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 iOS, Android 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 })` has 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 the `registerAgentTool(name, handler)` helper instead. The `tool-execution` event on `setEventCallback` remains available.

## Related

- [Ionic Capacitor SDK setup](https://docs.gleap.ai/en/articles/563-ionic-capacitor-sdk-setup.md)
- [Ionic Capacitor SDK: User identity](https://docs.gleap.ai/en/articles/564-ionic-capacitor-sdk-user-identity.md)
- [Ionic Capacitor SDK: Track events](https://docs.gleap.ai/en/articles/566-ionic-capacitor-sdk-track-events.md)
- [Ionic Capacitor SDK: Track pages](https://docs.gleap.ai/en/articles/567-ionic-capacitor-sdk-track-pages.md)
- [Ionic Capacitor SDK: Forms](https://docs.gleap.ai/en/articles/568-ionic-capacitor-sdk-forms.md)
