AI agents
Advanced topics
Use Answers components in AI agents

Use Answers components in AI agents

This page explains how to use components as tools in AI agents and provides best practices for configuring them.

Answers components

Components are reusable blocks that perform tasks such as retrieving information, answering FAQs, or performing actions. Example: Check booking availability, make a reservation, or retrieve end user information.

Components can be added as tools for AI agents. They can also integrate with AI assistant to query knowledge bases, enabling retrieval-augmented generation (RAG).

For the features, advantages, and setup instructions, refer to the Answers Components documentation.

Why components are used in AI agents

Using components reduces the number of tool calls the agent must make, improving performance and reliability.

Components are not limited to single API calls. They can do the following:

  • Manage complex logic: Components can have multiple dialogs and manage complex conditional logic
  • Process API results: If LLM-driven insight is needed to interpret an API result, you can add a Custom prompt element after the API call to process the data and return meaningful information to the AI agent.
  • Sequence multiple operations: Group sequential API calls into a single component to minimize response time and simplify agent decision-making.

Use components with AI agents

Components need clear descriptions that tell the LLM when and how to use them. Refer to the best practices sections for components and the input attributes that are used in the components.

Integrate components with knowledge bases (AI assistant)

Components can integrate with AI assistants to access knowledge bases. This enables your AI agent to retrieve company-specific documentation using retrieval-augmented generation (RAG).

How it works

  1. Create an AI Assistant in AI Hub and upload your knowledge base. Example: Documentation, FAQs, support articles.
  2. Create a component in Answers.
  3. Add the AI Assistant element to your component.
  4. Configure the component as a tool for your AI agent.

When the AI agent calls this component, it queries the knowledge base and returns relevant information to answer end user questions.

Use cases

  • Answer product-specific questions from internal documentation
  • Provide support based on company policies and procedures
  • Retrieve information from technical manuals or knowledge bases

For detailed setup instructions, refer to the AI Assistant documentation.

Component description best practices

When creating components to use as tools in AI agents, you need to provide clear descriptions that tell the LLM when to use this tool and what it does. The description defines the tool's role in the agent's list of available actions.

Why use component descriptions

The description helps with the following:

  • It helps the LLM decide when this component is the correct choice for the end user's request.
  • Without this information, the agent may not know when to call this component or may choose the wrong one.
  • It ensures correct intent recognition and reduces confusion between similar components.

Best practices for component descriptions

  1. Start with a clear purpose

    Example: Use this tool to record a new expense when the end user mentions spending money.

  2. Describe common use cases / user intents

    Example: Call this tool when the end user says something like 'Add 20 USD for lunch today' or 'I paid rent yesterday.'

  3. Specify key inputs

    Example: This tool takes amount, category, date, and description.

  4. Explain output purpose

    Example: Returns a confirmation message after the expense is added.

  5. Use clear, short sentences

    Use 1–2 concise paragraphs.

Example component description

Use this tool to record a new expense. Call it when the end user mentions paying for something, such as "Add 30 dollars for groceries today."
 
Takes amount, category, date, and description as inputs, and returns a confirmation message after the expense is recorded.

Input attribute description

Components receive input through input attributes. It is important to provide a clear description for these attributes that tells the LLM what information it needs to fill in that field. It explains the format and meaning, and provides examples of what is expected.

Why use input attribute descriptions

  • The model uses this text to know what to extract from the end user's message.
  • It prevents formatting errors such as wrong date, currency, or text format.
  • It ensures consistency by mapping the same kind of data to the same field each time.

Best practices

  1. Start with what the attribute represents

    Example: The date when the expense occurred

  2. Explain required format or unit

    Example: Use DD-MM-YYYY format. Convert 'today' or 'yesterday' to actual dates.

  3. Add examples

    Example: Example: 15-09-2025

  4. Specify how to manage ambiguous input

    Example: If the end user does not specify a category, map it to 'Other'.

  5. Be concise but specific

    Use a maximum of 3 lines for each attribute.

Example input attribute description

The date when the expense occurred. Use DD-MM-YYYY format.
Example: "12-10-2025". Convert natural language inputs ("today", "yesterday") into actual dates.

Input format field for input attributes

The Input format field validates input data before the tool runs. It ensures that each input follows a specific structure or format. Example: A valid date, number, or keyword.

Validation uses regular expressions (regex), which are text patterns that describe what is allowed as input and what is not.

Why validate input format

Without validation, the agent might do one or more of the following:

  • Sends incorrect data. Example: Writes twenty dollars as text instead of the number 20.
  • Tries to call the tool without all the required inputs, or with only partial information.
  • Uses inconsistent formats. Example: 2025/11/03 instead of 03-11-2025.
  • Causes the tool to fail if the input is in the wrong format or contains unexpected values.

Regex validation prevents these issues by checking inputs before the tool runs. This safety step ensures the tool only works with correctly formatted data. If the input does not match the allowed format, the agent cannot run the tool until the input is corrected.

How regex validation works

Each input attribute can have its own Input format field where you define a regex pattern describing what a valid input looks like.

When the AI agent extracts a value from the end user's message and sends it to the tool, the following happens:

  • If the value matches the regex pattern, the tool executes.
  • If the value does not match the pattern, the system asks for clarification or stops execution.

How to create and test regex patterns

Use online regex testers that enable you to do the following:

  • Create and test patterns interactively
  • Get explanations of each regex part
  • Verify that it matches only what you expect

Example use cases for input format validation

Date validation

  • Goal: Only allow valid dates in DD-MM-YYYY format.
  • Regex: ^(0[1-9]|[12][0-9]|3[01])-(0[1-9]|1[0-2])-(19|20)\d\d$
  • Valid examples: 05-11-2025
  • Invalid examples: 2025-11-05, 5/11/25, tomorrow
  • Benefit: Keeps all dates consistent across tools and summaries.

Numeric amount

  • Goal: Accept only positive numbers (integer or decimal).
  • Regex: ^\d+(\.\d{1,2})?$
  • Valid examples: 20, 19.99
  • Invalid examples: $20, twenty, 19,99
  • Benefit: Prevents invalid symbols or words being saved as amounts.

Category names

  • Goal: Limit allowed values to known categories.
  • Regex: ^(Food & Groceries|Transport|Housing|Entertainment|Shopping|Health|Travel|Other)$
  • Valid examples: Transport, Health
  • Invalid examples: Bills, Groceries, Fun
  • Benefit: Ensures category consistency for summaries and reports.

Time period

  • Goal: Allow only predefined time periods or date ranges.
  • Regex: ^(day|week|month|year|today|this week|this month|this year|[0-3]?\d-[0-3]?\d{4}\s*(to|-)\s*[0-3]?\d-[0-3]?\d{4})$
  • Valid examples: month, this week, 01-09-2025 to 30-09-2025
  • Invalid examples: weekly, current month
  • Benefit: Prevents unpredictable phrasing and keeps reporting stable.

Need assistance

Explore Infobip Tutorials

Encountering issues

Contact our support

What's new? Check out

Release Notes

Unsure about a term? See

Glossary
Service status

Copyright @ 2006-2026 Infobip ltd.

Service Terms & ConditionsPrivacy policyTerms of use