Skip to main content

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 integration

  1. Open WSO2 Integrator.
  2. Select Create in the Create New Integration card.
  3. Set Integration Name to HotelFinder.
  4. Set Project Name as AI-Integrations.
  5. Select Create Integration.
Create Integration form with Integration Name set to HotelFinder and Project Name set to AI-IntegrationsCreate Integration form with Integration Name set to HotelFinder and Project Name set to AI-Integrations

Step 2: Add an AI chat agent

  1. In the design view, select + Add Artifact.
  2. Select AI Chat Agent under AI Integration.
  3. Set Name to HotelFinderAssistant.
  4. Select Create.
AI Chat Agent wizard with Name set to HotelFinderAssistantAI Chat Agent wizard with Name set to HotelFinderAssistant
Default model provider

By default, the agent is created with the WSO2 model provider. If you have not signed in to WSO2 Integrator Copilot yet, sign in when prompted. No third-party API key is required.

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

Step 3: Configure the agent

  1. Select the AI Agent node in the design canvas.

  2. Set Role to HotelFinderAssistant.

  3. 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.
  4. Select Save.

AI Agent configuration panel with Role and Instructions filled inAI Agent configuration panel with Role and Instructions filled in

Step 4: Add the searchHotels tool

Create the searchHotels tool

  1. Select the + button on the AI Agent node.

  2. Select Create Custom Tool.

  3. Set Name to searchHotels.

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

  5. Under Parameters, select + Add Parameter and add:

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

    a. Set Kind to Record and Name to Hotel.

    b. Add the following fields:

    NameType
    hotelIdstring
    namestring
    citystring
    pricePerNightdecimal
    ratingfloat
    amenitiesstring[]

    c. Select Save.

Create New Type dialog open over the Create New Agent Tool form, with Kind set to Record and Name set to Hotel, showing all six fieldsCreate New Type dialog open over the Create New Agent Tool form, 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. Select Create.

Completed Create New Agent Tool form for searchHotels showing the city parameter, Hotel[] return type, and return descriptionCompleted Create New Agent Tool form for searchHotels showing the city parameter, Hotel[] return type, and return description

Build the searchHotels logic

The tool's visual flow opens. Add the logic:

  1. Select the + button and 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 node configured with Name set to allHotels, Type set to Hotel[], and the hotel array set as the ExpressionDeclare Variable node configured with Name set to allHotels, Type set to Hotel[], and the hotel array set as the Expression
  1. Select + 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 node configured with Name set to hotels, Type set to Hotel[], and the filter expression set as the ExpressionDeclare Variable node configured with Name set to hotels, Type set to Hotel[], and the filter expression set as the Expression
  1. Select + and select Return under Control. Set Expression to hotels and select Save.
Return node configuration panel with Expression set to hotelsReturn node configuration panel with Expression set to hotels

Step 5: Add the checkAvailability tool

Create the checkAvailability tool

  1. Navigate back to the AI Chat Agent view.

  2. Select + 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:

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

    a. Set Kind to Record and Name to Availability.

    b. Add the following fields:

    NameType
    hotelIdstring
    hotelNamestring
    availableboolean
    totalPricedecimal
    nightsint

    c. Select Save.

Create New Type dialog open over the checkAvailability form, with Kind set to Record and Name set to Availability, showing all five fieldsCreate New Type dialog open over the checkAvailability form, with Kind set to Record and Name set to Availability, showing all five fields
  1. Set Return Type to Availability.

  2. Set Description (return value) to Availability result with total price and nights.

  3. Select Create.

Completed checkAvailability tool form showing hotelId, checkIn, checkOut parameters, Availability return type, and return descriptionCompleted checkAvailability tool form showing hotelId, checkIn, checkOut parameters, Availability return type, and return description

Build the checkAvailability logic

In the tool's visual flow, select + and 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 node configuration panel for checkAvailability with the hardcoded Availability record set as the ExpressionReturn node configuration panel for checkAvailability with the hardcoded Availability record set as the Expression

After both tools are created, the agent shows them connected in the design canvas.

AI Chat Agent design view showing the agent node connected to searchHotels and checkAvailability tools with the system prompt visibleAI Chat Agent design view showing the agent node connected to searchHotels and checkAvailability tools with the system prompt visible

Step 6: Run and test

  1. Select Run.
  2. Select Chat.
  3. Type Show me hotels in Paris to check if it works.

The agent calls searchHotels and returns matching options. Continue the conversation using the same session to check availability.

Agent Chat panel showing the user asking for hotels in Paris, with the agent responding with Grand Plaza Hotel, City Center Inn, and Luxury Suites optionsAgent Chat panel showing the user asking for hotels in Paris, with the agent responding with Grand Plaza Hotel, City Center Inn, and Luxury Suites options

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