picoflow.io

Lesson 4: Design Hotel Flow


Now we've learnt about Picoflow essence and basics. Let's Recap how to work with Picoflow:

Tip
  • Design your Flow
  • Design your Steps.
    • Design your step prompt
    • Design your step tool
    • Implement tool handler
    • Decide which step to transition

Design hotel reservation bot

We use the experience of reserving a Hotel room on hilton.com to begin with.

The following information are collected from a user.

  1. Place
  2. Date of travel
  3. Minimum and maximum budget per night
  4. Room type
  5. Room amenities
  6. Distance from airport
  7. Distance from city center
  • Once all the information are collected, the bot will do a search on all available hotels that meet the requirements.
  • A user can change information that has been previously captured

In order to simulate realistic search,

  • We collect 32 Hilton hotels in Portland Oregon and SouthWest Washington areas. Example:
{
    "id": "368dedd8-8bd8-4a02-bffa-a46a66e58337",
    "_ts": 1762557263,
    "_rid": "AQAAAAEAAAAAAAAZpgmX3DAAD6E=",
    "name": "The Porter Portland, Curio Collection by Hilton",
    "_etag": "5aa8601a-a7e8-4e57-94fa-304729c5a0f3",
    "_self": "dbs/picoflow/colls/hotels/docs/368dedd8-8bd8-4a02-bffa-a46a66e58337/",
    "level": 120,
    "nearby": {
        "airport": 12.4,
        "cityCenter": 0.5
    },
    "address": "1355 SW 2nd Ave. Portland, Oregon 97201 USA",
    "roomType": [
        "one bed",
        "two beds",
        "suite"
    ],
    "amenities": {
        "boutique": true,
        "freeWiFi": true,
        "digitalKey": true,
        "indoorPool": true,
        "nonSmoking": true,
        "petFriendly": true,
        "roomService": true,
        "fitnessCenter": true,
        "businessCenter": true,
        "onSiteRestaurant": true
    }
}
  • The hotel attributes were obtained from hilton.com website.
  • We devise a simulated pricing engine to account for room types, amenities, original base price, weekdays vs weekends vs Holidays travels, distance from airport and distance from city center.

Hotel comparison

  • once a list of Hotels are presented to a user, allow a user to compare pricing, amenities and other attributes across the date range.
  • allow a user to exit the comparison loop and book a hotel.

Demo

The entirety of this tutorial can be demonstrated in a recorded demo

Github

The code for this tutorial is available on Github

Document DB setup

In order to run this project, you need to decide to use a MongoDB or a CosmoDB. Both have support locally or in the Cloud.

Create 2 collections for your document DB:

hotels
sessions

Upload a hotel database to the collection hotels

hotels-cosmo.json (for Cosmo) 
hotels-mongo.json (for Mongo)

These two json files are under src/myflow/hotel-flow/data

Endpoints

You can go to http://localhost:8000/api#/ai/ChatController_run

Each turn, you want to take the CHAT_SESSION_ID from the response header and use that in the request header for next turn.

Leave CHAT_SESSION_ID blank when you make the first call. A new session and ID will be created and returned.


Wrapping up