Artificial Intelligence

Intro to AI Agents in Xano

AI agents are one of the most powerful ways to replace rigid, rule-based logic with something far more flexible and human-like. Instead of writing endless if/else conditions to handle every edge case, you let an AI model reason through the available data and decide what action to take. In this guide, you'll learn how to build a fully functional AI agent inside Xano that intercepts user cancellation requests and intelligently offers personalized retention deals.

What Makes an AI Agent Different

Traditional function stacks follow hard-coded rules — if a user is 30 days old, do this; if they subscribed within 7 days, do that. An AI agent replaces that brittle decision tree with what Xano calls "fuzzy logic." You define the tools and guardrails, and the AI model — in this case Google Gemini — reasons through the data to determine the best course of action for each unique situation.

Setting Up Your Agent

To create an agent, navigate to the AI section in Xano's left-hand menu and select Agents. When adding a new agent, you'll configure:

  • Name and description — give it a clear purpose, like a "Churn Reduction Agent"
  • Model host and model — this example uses Google Generative AI with Gemini 2.5 Flash
  • Max steps — five is a healthy default for most agent workflows
  • System prompt — defines the agent's role and boundaries (e.g., assess eligibility for a retention offer or proceed with cancellation)
  • User prompt — uses template syntax like {{$args.user_message}} to dynamically pass in real user data at runtime
  • API key — stored securely as an environment variable and referenced via {{$environment.google}}
  • Temperature — set to 0.2 for more consistent, focused responses

Connecting Tools to Your Agent

Tools are the functions your agent can call to gather or store data. For the retention agent, you'll connect four tools: get user info, get subscription info, retrieve current retention offers, and create a retention log. Each tool is a simple function stack — usually a single database query — that the AI can invoke as needed. These same tools can also be reused across MCP servers, giving you maximum flexibility.

Calling the Agent from an Endpoint

Once your agent is configured, you trigger it using the Call AI Agent function inside any function stack. Add it to your endpoint, select your agent, and pass in an arguments object — for example, user_message mapped to the incoming user input. That's it. No complex wiring required.

Watching It Work

When a user sends a message like "I'd like to cancel my subscription," the agent queries the user's info, subscription details, and available offers — then responds with a tailored retention pitch, such as offering 10% or 20% off. You can inspect every step taken in the Run & Debug panel and review the full request history from the agent's settings page.

The result is a smarter, faster system that handles cancellations without any manual intervention — and without you needing to anticipate every possible scenario in advance.

Sign up for Xano

Join 100,000+ people already building with Xano.
Start today and scale to millions.