Skip to main content
Version: 1.0-beta

Build a Hotel Finder Agent

Time: 10 minutes | What you'll build: A conversational agent that helps users find hotels in a specific city and check availability through natural conversation, with session-scoped memory so the user can refer back to earlier messages.

Step 1: Create the agentic integration​

  1. Open WSO2 Agent Builder and select Create under Start Building your Agent.
  2. Set Project name to AI-Integrations and choose a Location.
  3. Under What do you want to build?, keep Agentic Integration selected.
  4. Set Agentic integration name to HotelFinder.
  5. Select Create Agentic Integration.
Create a Project form with Project name set to AI-Integrations, the Agentic Integration option selected, and Agentic integration name set to HotelFinderCreate a Project form with Project name set to AI-Integrations, the Agentic Integration option selected, and Agentic integration name set to HotelFinder

Step 2: Create the agent​

The integration opens with the WSO2 Agent Builder Copilot, which asks What should your agent do? Skip it for this guide and build the agent manually.

  1. Under Or start from scratch, select Add Agent.
HotelFinder integration home page showing the WSO2 Agent Builder Copilot prompt, example agents, and the Add Agent and Add MCP Server buttons under Or start from scratchHotelFinder integration home page showing the WSO2 Agent Builder Copilot prompt, example agents, and the Add Agent and Add MCP Server buttons under Or start from scratch
  1. In the Add Agent dialog, select Create Agent under Create New.
Add Agent dialog showing the Create Agent, Create Durable Agent, and Create Agent Definition options, and a list of pre-built agentsAdd Agent dialog showing the Create Agent, Create Durable Agent, and Create Agent Definition options, and a list of pre-built agents
  1. Set Role to HotelFinderAssistant.

  2. Set Instructions to:

    You are a friendly hotel finder assistant.

    Your responsibilities:
    - Help users find hotels and check availability through natural conversation.
    - Ask clarifying questions when information is missing.

    Tool usage:
    - Use searchHotels when the user mentions a city or destination.
    - Use checkAvailability when the user wants to verify dates and pricing.

    Presentation:
    - Show hotels clearly with price, rating, and key amenities.
Create Agent form with Role set to HotelFinderAssistant and the hotel finder instructions filled inCreate Agent form with Role set to HotelFinderAssistant and the hotel finder instructions filled in
  1. Keep the model as the Default WSO2 Model Provider, and leave the remaining agent settings at their defaults.
  2. Set Agent Name to HotelFinderAssistant.
  3. Select Create Agent.
Bottom of the Create Agent form with Agent Name set to HotelFinderAssistant and the Create Agent buttonBottom of the Create Agent form with Agent Name set to HotelFinderAssistant and the Create Agent button
Default model provider

By default, the agent uses the WSO2 model provider, so no third-party API key is required. Sign in to WSO2 Agent Builder if prompted.

To use a different LLM instead, see Model providers for the full list of supported providers (OpenAI, Anthropic, Azure OpenAI, and others).

The agent canvas for HotelFinderAssistant opens. The AI Agent node is connected to Default WSO2 Model Provider, with Add Trigger on its left and Add Tool at its bottom-right corner.

AI Agent canvas for HotelFinderAssistant connected to the Default WSO2 Model Provider, with Add Trigger, Add Memory, and Add Tool optionsAI Agent canvas for HotelFinderAssistant connected to the Default WSO2 Model Provider, with Add Trigger, Add Memory, and Add Tool options

Step 3: Add the searchHotels tool​

Create the searchHotels tool​

  1. Select Add Tool at the bottom-right corner of the AI Agent node.
  2. In the Add Tool panel, select Create Custom Tool.
Add Tool panel listing Use Connection, Use Function, Use Agent, Use MCP Server, Use Knowledge Base, and Create Custom ToolAdd Tool panel listing Use Connection, Use Function, Use Agent, Use MCP Server, Use Knowledge Base, and Create Custom Tool
  1. Set Name to searchHotels.

  2. Set Description to Searches for hotels in a city.

  3. Under Parameters, select + Add Parameter, add the following parameter, and select Add:

    TypeNameDescription
    stringcityCity name, e.g. "Paris" or "New York"
  4. Select the Return Type field and choose Create New Type. The Create New Type dialog opens:

    a. Keep Kind as Record and set Name to Hotel.

    b. Select + next to Fields to add each of the following fields:

    NameType
    hotelIdstring
    namestring
    citystring
    pricePerNightdecimal
    ratingfloat
    amenitiesstring[]

    c. Select Save.

Create New Type dialog with Kind set to Record and Name set to Hotel, showing all six fieldsCreate New Type dialog with Kind set to Record and Name set to Hotel, showing all six fields
  1. Set Return Type to Hotel[].
  2. Set Description (return value) to Hotels available in the city.
  3. Leave Requires Approval unchecked. Enabling it pauses the tool before it runs and waits for human approval.
  4. Select Create Tool.
Completed Create Custom Tool form for searchHotels showing the city parameter, Hotel[] return type, and return descriptionCompleted Create Custom Tool form for searchHotels showing the city parameter, Hotel[] return type, and return description

Build the searchHotels logic​

The tool now appears as a node connected to the agent. Select it to open its flow. New tools open with a placeholder: Start connected to a Panic node (error("not implemented")). Replace it with the real logic:

  1. Select + on the connector between Start and Panic, then select Declare Variable under Statement. Set Name to allHotels and Type to Hotel[]. Set the Expression to the following hotel array and select Save:

    [
    {hotelId: "HTL-001", name: "Grand Plaza Hotel", city: "Paris", pricePerNight: 199.99, rating: 4.5, amenities: ["WiFi", "Pool", "Gym"]},
    {hotelId: "HTL-002", name: "City Center Inn", city: "Paris", pricePerNight: 129.99, rating: 4.0, amenities: ["WiFi", "Breakfast"]},
    {hotelId: "HTL-003", name: "Luxury Suites", city: "New York", pricePerNight: 349.99, rating: 4.8, amenities: ["WiFi", "Pool", "Spa", "Restaurant"]}
    ]
    note

    This uses hardcoded sample data. In a real scenario, you would call an external hotel API, query a database, or connect an MCP tool.

Declare Variable panel with Name set to allHotels, Type set to Hotel[], and the hotel array set as the ExpressionDeclare Variable panel with Name set to allHotels, Type set to Hotel[], and the hotel array set as the Expression
  1. Select + below the allHotels node and select Declare Variable under Statement. Set Name to hotels and Type to Hotel[]. Set the Expression to the following and select Save:

    allHotels.filter(h => h.city == city)
Declare Variable panel with Name set to hotels, Type set to Hotel[], and the filter expression set as the ExpressionDeclare Variable panel with Name set to hotels, Type set to Hotel[], and the filter expression set as the Expression
  1. Select + below the hotels node and select Return under Control. Set Expression to hotels and select Save.
Return panel with Expression set to hotelsReturn panel with Expression set to hotels
  1. The placeholder Panic node is now unreachable. Select the ⋮ menu on the Panic node and select Delete.
Completed searchHotels flow with Start, the allHotels and hotels Declare Variable nodes, and the Return nodeCompleted searchHotels flow with Start, the allHotels and hotels Declare Variable nodes, and the Return node

Step 4: Add the checkAvailability tool​

Create the checkAvailability tool​

  1. Select the back arrow to return to the HotelFinderAssistant agent canvas.

  2. Select Add Tool on the AI Agent node and choose Create Custom Tool.

  3. Set Name to checkAvailability.

  4. Set Description to Checks whether a hotel has rooms available between two dates.

  5. Under Parameters, select + Add Parameter and add each of the following parameters:

    TypeNameDescription
    stringhotelIdHotel identifier returned from searchHotels
    stringcheckInCheck-in date in YYYY-MM-DD format
    stringcheckOutCheck-out date in YYYY-MM-DD format
  6. Select the Return Type field and choose Create New Type. The Create New Type dialog opens:

    a. Keep Kind as Record and set Name to Availability.

    b. Select + next to Fields to add each of the following fields:

    NameType
    hotelIdstring
    hotelNamestring
    availableboolean
    totalPricedecimal
    nightsint

    c. Select Save.

Create New Type dialog with Kind set to Record and Name set to Availability, showing all five fieldsCreate New Type dialog with Kind set to Record and Name set to Availability, showing all five fields
  1. Make sure Return Type is set to Availability.
  2. Set Description (return value) to Availability result with total price and nights.
  3. Select Create Tool.
Completed checkAvailability tool form showing the hotelId, checkIn, and checkOut parameters, the Availability return type, and the return descriptionCompleted checkAvailability tool form showing the hotelId, checkIn, and checkOut parameters, the Availability return type, and the return description

Build the checkAvailability logic​

  1. Select the checkAvailability node to open its flow.

  2. Select + on the connector between Start and Panic, select Return under Control, set Expression to the following, and select Save:

    {
    hotelId,
    hotelName: "Grand Plaza Hotel",
    available: true,
    totalPrice: 599.97,
    nights: 3
    }
    note

    This returns hardcoded sample data. In a real scenario, you would query a booking system, call an availability API, or connect an MCP tool.

Return panel for checkAvailability with the hardcoded Availability record set as the ExpressionReturn panel for checkAvailability with the hardcoded Availability record set as the Expression
  1. Select the ⋮ menu on the Panic node and select Delete.

Return to the agent canvas. The agent now shows both tools connected.

HotelFinderAssistant agent canvas showing the AI Agent node connected to the Default WSO2 Model Provider and to the searchHotels and checkAvailability toolsHotelFinderAssistant agent canvas showing the AI Agent node connected to the Default WSO2 Model Provider and to the searchHotels and checkAvailability tools

Step 5: Add a chat trigger​

A trigger connects the agent to a channel that calls it. Add an Agent Chat trigger to expose the agent as a chat endpoint.

  1. Select Add Trigger on the left of the AI Agent node.
  2. Under Chat Channels, select Agent Chat.
Add Trigger dialog showing Chat Channels such as Agent Chat, Google Chat, Telegram, and WhatsApp Business, the HTTP API endpoint, and event sourcesAdd Trigger dialog showing Chat Channels such as Agent Chat, Google Chat, Telegram, and WhatsApp Business, the HTTP API endpoint, and event sources
  1. Keep Service Path as /hotel-finder-assistant.
  2. Select Create.
Agent Chat trigger form with Service Path set to /hotel-finder-assistantAgent Chat trigger form with Service Path set to /hotel-finder-assistant

This creates an AI Agent Services entry point with a POST chat resource and an agentChatListener. The agent canvas now shows the Agent Chat trigger connected to the agent.

Completed HotelFinderAssistant agent canvas with the /hotel-finder-assistant Agent Chat trigger, the model provider, and both tools connectedCompleted HotelFinderAssistant agent canvas with the /hotel-finder-assistant Agent Chat trigger, the model provider, and both tools connected

Step 6: Run and test​

  1. Select Run Integration at the top-right corner of the editor. Wait until the terminal shows Running executable.
  2. Under Entry Points, expand AI Agent Services - /hotel-finder-assistant and select the chat resource. The Chat Agent Service flow opens, showing the agent : run call to HotelFinderAssistant and the Return node.
  3. Select Chat to open the Agent Chat panel.
  4. Type Show me hotels in Paris and send it.

The agent calls searchHotels and returns the matching Paris options (Grand Plaza Hotel and City Center Inn, not Luxury Suites, which is in New York). Continue the conversation in the same chat session to check availability.

Chat Agent Service flow for the chat resource next to the Agent Chat panel, where the user asks for hotels in Paris and the agent responds with Grand Plaza Hotel and City Center Inn and asks for check-in and check-out datesChat Agent Service flow for the chat resource next to the Agent Chat panel, where the user asks for hotels in Paris and the agent responds with Grand Plaza Hotel and City Center Inn and asks for check-in and check-out dates

How it works​

This example demonstrates two patterns you will reuse in production agents:

  1. Session-scoped memory: ai:Listener keeps a short history of messages per sessionId, so the LLM sees recent turns on every call.
  2. Sequential tool calls: The agent calls searchHotels and then checkAvailability, using each result to inform the next step. The chaining is driven entirely by the LLM's reasoning.

What's next​

  • Creating an agent — Full reference for agent configuration
  • Tools — Advanced tool patterns, including connection-backed tools and MCP servers
  • Memory — Custom memory strategies beyond the default session store