Skip to main content
Version: 5.1

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 and select Create under Create a Project.
  2. Set Project name to AI-Integrations and choose a Location.
  3. Under What do you want to build?, keep Integration selected.
  4. Set Integration name to HotelFinder.
  5. Select Create.
Create a Project form with Project name set to AI-Integrations, the Integration option selected, and Integration name set to HotelFinderCreate a Project form with Project name set to AI-Integrations, the Integration option selected, and Integration name set to HotelFinder

Step 2: Add and configure an AI chat agent​

The integration opens on the Design tab with the WSO2 Integrator Copilot. Bypass it for this quick start and create the artifact manually.

  1. Select Add Artifact manually.

  2. On the Artifacts page, select Chat Agent Service under AI Integration.

  3. Set Role to HotelFinderAssistant.

  4. 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.
  5. Keep Model as Default WSO2 Model Provider.

Create Chat Agent Service form with Role and Instructions filled in and Model set to Default WSO2 Model ProviderCreate Chat Agent Service form with Role and Instructions filled in and Model set to Default WSO2 Model Provider
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).

  1. Leave Maximum Iterations, Verbose, Tool Loading Strategy, and Execute Tool Calls In Parallel at their defaults.
  2. Set Agent Name to HotelFinderAssistant.
  3. Set Service Base Path to expose the chat service, for example /hotel-finder-assistant.
  4. Select Create.
Bottom of the Create Chat Agent Service form with Agent Name set to HotelFinderAssistant and Service Base Path set to /hotel-finder-assistantBottom of the Create Chat Agent Service form with Agent Name set to HotelFinderAssistant and Service Base Path set to /hotel-finder-assistant

This creates an AI Agent Service with a POST /chat resource and a chatAgentListener, plus the HotelFinderAssistant agent under Agents. Select HotelFinderAssistant under Agents to open its canvas: the AI Agent node is connected to the model provider, with a + button at its bottom-right corner for adding tools.

AI Agent node for HotelFinderAssistant connected to the model provider, with an Add Memory button and a + icon for adding toolsAI Agent node for HotelFinderAssistant connected to the model provider, with an Add Memory button and a + icon for adding tools

Step 3: Add the searchHotels tool​

Create the searchHotels tool​

  1. Select the + button at the bottom-right corner of 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 Custom Tool form, with Kind set to Record and Name set to Hotel, showing all six fieldsCreate New Type dialog open over the Create Custom 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. Optionally 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 shows 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 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
note

The visual designer currently leaves the placeholder panic error("not implemented") statement in place after the node you add. It becomes unreachable once your Return is in the flow, so it's safe to delete from the pro-code view; leaving it in doesn't affect the build.

Step 4: Add the checkAvailability tool​

Create the checkAvailability tool​

  1. Navigate back to the HotelFinderAssistant agent canvas.

  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 Tool.

Completed checkAvailability tool form showing hotelId, checkIn, checkOut parameters, Availability return type, and return description, with searchHotels already connected to the agentCompleted checkAvailability tool form showing hotelId, checkIn, checkOut parameters, Availability return type, and return description, with searchHotels already connected to the agent

Build the checkAvailability logic​

Open the tool's flow. 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 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. Once the integration compiles and starts, select Chat on the chat resource.
  3. Type Show me hotels in Paris to check if it works.

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.

Agent Chat panel showing the user asking for hotels in Paris, with the agent responding with Grand Plaza Hotel and City Center Inn and asking for check-in and check-out datesAgent Chat panel showing the user asking for hotels in Paris, with the agent responding with Grand Plaza Hotel and City Center Inn and asking 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