How to Create an AI Agent to Detect User Intent

Anna Gardeta Updated by Anna Gardeta

Using Landbot’s AI capabilities, you can build an AI Agent that detects a user’s intent when they first interact with your chatbot. This setup allows you to capture structured and open-ended responses, store the detected intent in a variable, and direct the conversation to the right flow automatically.

Prefer watching than reading? No problem, we've got you covered 👇

What you'll achieve 🎯

With this setup, you will:

  • Use an AI Agent to detect and classify user intent from an open-ended message.
  • Store the detected intent in a custom field in Landbot for future reference or reporting.
  • Define an exit condition that routes the conversation once an intent is detected.
  • Build dedicated flows for each detected intent. For example:
    • Connect to a human agent
    • Send a follow-up email
    • Qualify the user with further questions
    • Trigger a lead capture or support automation flow
    This ensures users are guided down the most relevant and efficient experience from the very first message.

Step 1: Create the AI Agent 🧩

  1. Go to AI Agents and click Create AI Agent.
  2. Select the channel (e.g., Web)
  3. Give your agent a name, e.g.: Paul.
  4. Under Agent Role, you can type Intent Detection.
  5. Configure the greeting message, e.g.: Hi, my name is Paul. How can I help you today?

Step 2: Define the AI Agent Instructions 🧠

  1. Clear the default prompt
  2. Copy in the following example prompt, you can adapt it to your own use case:
Role
You are an Intent Detection Agent working for Landbot. Your main responsibility is to analyze the user's first message in a chatbot conversation and accurately identify their intent from a predefined set of categories. Do not write it as a message. Once you collect the intent, let the user know you will route their conversation towards the right place.

Responsibilities
Intent Classification: Assign one primary intent to the user’s message from a defined list.
Options can be: "Product", "Support", "Pricing",
"Account", "Feedback", "Greeting" or "Other".

Confidence Thresholding: If the user’s message is ambiguous or doesn't clearly match an intent, return "Unclear" as the result.

Language Awareness: Analyze user input regardless of the language, but always return the intent name in English.

No User Response: Do not reply directly to the user. Your output is for internal processing only.

Constraints
Strictly Single Intent: Never assign multiple intents to a message.

No Hallucination: Do not make assumptions beyond what is stated in the user's message.

Structured Output Only: Return only the name of the detected intent in plain text (e.g., Technical Support).

Fallback Response: If no intent can be clearly determined, return: Unclear.

Examples
User says: "I need help connecting my bot to WhatsApp" → "Support"

User says: "How much does your Pro plan cost?" → "Pricing"

User says: "Hello!" → "Greeting"

User says: "Can I change my email address?" → "Account"

User says: "I have some feedback for your product team" → "Feedback"

Step 3: Store the intent in a field 🏷️

To make the detected intent usable across bots and for analytics, you’ll want to save it in a Landbot field. This allows you to track user goals and personalize follow-up actions.

  1. In the Get user information section of the agent setup:
    • You can enable system fields like Name, Email, or Phone by simply checking the relevant boxes.
  2. Click + Add field to create a new custom field. For example:
    • Field Description: User intent when they start a chatbot
    • Field Name: @user_intent
  3. You can also add more custom fields if needed

Once set, this field will store the AI Agent’s output and be available for:

  • Routing logic within the bot
  • User segmentation and analytics
  • Passing data between connected bots

📝 Learn how to create a field →

Step 4: Test and Publish 🧪

  1. Click on Publish to test the AI agent. * Please note Test does not store information in fields, which is a key part of your testing.
  2. Open the URL provided and test.
  3. Go to Analyze tab to check your results.

Step 5: Create a bot to route based on user intent 🔁

Now that the AI Agent saves the detected intent in a variable (@user_intent), it's time to create a bot to route the conversation based on that intent.

  1. Go to Home and click Build a Chatbot.
  2. Select the channel (e.g., Web) and Start from scratch
  3. Add any first block, it does not matter what it is since it won’t be used, for example, Ask a question. You don’t need to edit it.
  4. Now Add a Keyword Jump block.
  5. Configure it to read the content of the @user_intent field.
  6. Define keyword conditions that match the possible intents defined in your agent prompt. Please make sure you only use single-word keywords, as the block does not support multiple-word ones:
    • Product
    • Support
    • Pricing
    • Account
    • Feedback
  7. For each intent, create a matching conversation path. Don’t forget to publish the bot once you are done. Examples from your setup:
    1. 💡 Product Inquiry
      • Send a message like: Hi @name, Here’s our product catalog!
      • Attach a file or media with product information (optional).
    2. 🛠️ Technical Support
      • Use the Human Takeover block to escalate to an agent (e.g., Assistant Beta).
    3. 💰 Pricing Question
      • Add a Calendar Booking block connected to your sales rep’s calendar.
      • Example message: Sure! Book a meeting with us to learn more about pricing.
    4. 👤 Account Management
      • Ask the user for their email using a Question block.
      • Use the Send an Email block to notify your support or account management team.
    5. 💬 Feedback
      • Ask: We’d love to hear your thoughts! Please share your feedback.
      • Store the answer in a field like @user_feedback.
    6. ❓ None of the above
      • Optionally redirect users to a fallback path for clarification or ask them to rephrase.

Step 6: Define the Exit Condition in the AI Agent 🚪

To connect the AI Agent to your bot’s logic, you’ll set up an exit condition that triggers once the intent is detected.

  1. Go back to your AI Agent configuration.
  2. Scroll to the Exit Conditions section.
  3. Click Add Exit and define it as:
    • When: Intent is collected
    • Go to bot: User Intent Testing (or your main routing bot)
    • Jump to specific step: Paste the Block ID of your Keyword Jump block (you can copy this from the block’s settings in the builder, by clicking on the 3 dots in the upper-right corner of the block).
  4. Publish your agent again, so that it refreshes with the new configuration
  5. Go to the bot’s URL and test!

Example: If the intent is generate_leads, you might send the user to a lead qualification flow.

✅ You’re Done!

You now have an AI-powered chatbot that:

  • Gathers user input flexibly
  • Detects their intent using natural language understanding
  • Saves this intent in a field
  • Automatically routes the conversation based on that intent

Was this article helpful?

How to connect a Chatbot flow to an AI Agent

Exit Conditions

Contact