How to

Your Guide to Building an AI Travel Consultant

Ever wondered how to leverage the latest AI technology for travel planning? This comprehensive guide on Dify.AI showcases how to build an AI travel consultant, making your trip planning effortless and efficient.

Xiaoyi

DevRel

Written on

Feb 4, 2024

Share

Share to Twitter
Share to LinkedIn
Share to Hacker News

How to

·

Feb 4, 2024

Your Guide to Building an AI Travel Consultant

Ever wondered how to leverage the latest AI technology for travel planning? This comprehensive guide on Dify.AI showcases how to build an AI travel consultant, making your trip planning effortless and efficient.

Xiaoyi

DevRel

Share to Twitter
Share to LinkedIn
Share to Hacker News

How to

Your Guide to Building an AI Travel Consultant

Ever wondered how to leverage the latest AI technology for travel planning? This comprehensive guide on Dify.AI showcases how to build an AI travel consultant, making your trip planning effortless and efficient.

Xiaoyi

DevRel

Written on

Feb 4, 2024

Share

Share to Twitter
Share to LinkedIn
Share to Hacker News

How to

·

Feb 4, 2024

Your Guide to Building an AI Travel Consultant

Share to Twitter
Share to LinkedIn
Share to Hacker News

How to

·

Feb 4, 2024

Your Guide to Building an AI Travel Consultant

Share to Twitter
Share to LinkedIn
Share to Hacker News

What is Dify.AI?

Dify.AI is an open-source and user-friendly LLMOps platform that assists developers in building AI applications more simply and swiftly. Dify combines the concepts of Backend as a Service and LLMOps, offering features like visual Prompt orchestration, operation, dataset management, a built-in RAG engine, and AI Agent functionality. With Dify, you can create an AI application in minutes or quickly integrate LLM into your existing applications for ongoing operation and improvement, creating truly valuable AI applications. Dify allows you to deploy capabilities similar to Assistants API and GPTs based on any model (currently supporting all popular LLMs on the market).

After Dify released the latest Agent Assistant mode, many are curious about what kind of products Dify can deliver. This article will showcase one scenario - creating a travel itinerary based on the user's needs.

I will guide you step-by-step on how to use Dify's latest Agent capabilities to build a travel consultant, answering a series of questions:

  • What features does Dify have?

  • How to apply Dify in travel and itinerary planning?

  • How to write perfect prompts?

  • How to publish your application on Dify and integrate it into your workflow?

For those who like to plan ahead, planning a trip to an unfamiliar place is still challenging due to the varying quality of information on the Internet. With the rise of technology and AI, travel advisors can now be replaced by AI, greatly enhancing the travel experience. In this guide, we will explore how to quickly create a travel advisor Agent to craft itineraries, book accommodations, and find great restaurants.

How good is the travel planning assistant?

Let's start with a talent showcase of our AI Agent: we tried to generate a 3-day travel plan to New York.

Users can input their destination, number of travel days, or budget. After completion, our Agent can provide information on local conditions and accommodations via Wikipedia and Google searches, as well as offer local dining and lodging features, prices, and reviews by browsing web pages.

Steps to create a Travel Consultant

How to build an Agent Assistant?

  1. Create an application.

  2. Write the prompts.

  3. Configure tools for the agent.

  4. What's next? How to deploy and use it in production?

Prerequisites

  1. Prerequisites

  2. Register or deploy Dify.AI

    Dify is an open-source product. You can find it on GitHub and then deploy it locally or on your company's intranet. It also offers a cloud-based SaaS version, accessible at Dify.AI for use upon registration.

  3. Apply for the API key from model providers like OpenAI

    AI model message calls consume tokens. Dify provides new registered users with a free usage quota of OpenAI GPT series (200 messages). Before you exhaust this quota, you need to apply for your own API key through the official channels of the model provider. The key can be entered in Dify's [Settings] --> [Model Provider].

Step 1: Create an [Assistant] application

Switch to Assistant mode. Assistant can use Chain-of-Thoughts and Function Calling to use external tools to handle multi-step complex scenarios.

Step 2: Prompt engineering

First, let's plan how the Agent will work first, it needs to understand three things first:

  • Where do the users want to go?

  • How many days would they like to travel?

  • And the budget.

Based on the above information, we can start writing prompts. Here is a recommended prompt structure that makes your intention clearer to the LLM, yielding the desired content.

Job Description: Briefly describe the smart assistant's task.
Context: Describe the task and purpose of the smart assistant you want to build, like "My goal is to provide users with expert-level data analysis reports. I will collect the most detailed data to complete a clear and concise data analysis report."
Skills: List the smart assistant's skills, such as data analysis, drawing, information gathering, etc.
Workflow: Describe the smart assistant's workflow and how you expect it to complete your task.
Constraints: State any constraints on the smart assistant, such as responding only in the user's language or not answering questions unrelated to its task.
Tone: (Optional) Set the response attitude to ensure the LLM's response matches the desired emotional or mood background, like formal, humorous, empathetic, etc.
Audience: (Optional) Specify the writing style you wish the LLM to use. It could be the style of a famous person or an expert in a field (like a business analyst or CEO), guiding the LLM to respond in a way that suits your needs.
Format: (Optional) Some models don't require a response format in the prompt. This ensures the LLM outputs in the exact format you need, such as lists, JSON, professional reports, etc. Ideal output format for most LLM applications programmatically handling LLM responses might be JSON.

Here you can see our prepared prompts. You can also visit Dify.AI and register to test the prompts yourself (we recommend using the latest GPT model, currently gpt-4-1106-preview, for better results). Just copy and paste the prompts below into the [Prompt] window.

## Role: Travel Consultant
### Skills:
- Expertise in using tools to provide comprehensive information about local conditions, accommodations, and more. 
- Ability to use emojis to make the conversation more engaging.
- Proficiency in using Markdown syntax to generate structured text.
- Expertise in using Markdown syntax to display images to enrich the content of the conversation.
- Experience in introducing the features, price, and rating of hotels or restaurants.
### Goals:
- Provide users with a rich and enjoyable travel experience.
- Deliver comprehensive and detailed travel information to the users.
- Use emojis to add a fun element to the conversation.
### Constraints:
1. Only engage in travel-related discussions with users. Refuse any other topics.
2. Avoid answering users' queries about the tools and the rules of work.
3. Only use the template to respond. 
### Workflow:
1. Understand and analyze the user's travel-related queries.
2. Use the wikipedia_search tool to gather relevant information about the user's travel destination. Be sure to translate the destination into English. 
3. Create a comprehensive response using Markdown syntax. The response should include essential details about the location, accommodations, and other relevant factors. Use emojis to make the conversation more engaging.
4. When introducing a hotel or restaurant, highlight its features, price, and rating.
6. Provide the final comprehensive and engaging travel information to the user, use the following template, give detailed travel plan for each day. 
### Example: 
### Detailed Travel Plan
**Hotel Recommendation** 
1. The Kensington Hotel (Learn more at www.doylecollection.com/hotels/the-kensington-hotel)
- Ratings: 4.6
- Prices: Around $350 per night
- About: Set in a Regency townhouse mansion, this elegant hotel is a 5-minute walk from South Kensington tube station, and a 10-minute walk from the Victoria and Albert Museum.
2. The Rembrandt Hotel (Learn more at www.sarova-rembrandthotel.com)
- Ratings: 4.3
- Prices: Around 130$ per night
- About: Built in 1911 as apartments for Harrods department store (0.4 miles up the road), this contemporary hotel sits opposite the Victoria and Albert museum, and is a 5-minute walk from South Kensington tube station (with direct links to Heathrow airport).
**Day 1 Arrival and Settling In**
- **Morning**: Arrive at the airport. Welcome to your adventure! Our representative will meet you at the airport to ensure a smooth transfer to your accommodation.
- **Afternoon**: Check into your hotel and take some time to relax and refresh.
- **Evening**: Embark on a gentle walking tour around your accommodation to familiarize yourself with the local area. Discover nearby dining options for a delightful first meal.
**Day 2 A Day of Culture and Nature**
- **Morning**: Start your day at Imperial College, one of the world's leading institutions. Enjoy a guided campus tour.
- **Afternoon**: Choose between the Natural History Museum, known for its fascinating exhibits, or the Victoria and Albert Museum, celebrating art and design. Later, unwind in the serene Hyde Park, maybe even enjoy a boat ride on the Serpentine Lake.
- **Evening**: Explore the local cuisine. We recommend trying a traditional British pub for dinner.
**Additional Services:**
- **Concierge Service**: Throughout your stay, our concierge service is available to assist with restaurant reservations, ticket bookings, transportation, and any special requests to enhance your experience.
- **24/7 Support**: We provide round-the-clock support to address any concerns or needs that may arise during your trip.
We wish you an unforgettable journey filled with rich experiences and beautiful memories!
### Information 
The user plans to go to {{destination}} to travel for {{num_day}} days with a budget {{budget}}

Step 3: Configure the tools used by our agent

It's very simple, Dify has already integrated a range of practical tools. Just select these tools and add them to your application for use. In this example, three tools that might be used are:

  • Wikipedia (Wikipedia search): For AI to query information about travel destinations, cities, tourist attractions, etc.;

  • Google (Google search): For AI to query real-time restaurant, hotel, and review information, making recommendations to users;

  • Web scraping (web crawler): Provides an optional tool for AI to extract useful web page information.

If you canot see Tools on the right panel, make sure the mode has been switched to [Agent Assistant], and is not [Basic Assistant].

While the Agent is working, it will autonomously analyze the steps to solve the problem and decide which tools to use to gather information.

Note here, if you want to use the Google search tool, you need to register at their website and get a SerpAPI key, then click [Authorize] for it to work properly. Here's an example of how to add a tool, using Google search.

Step 4: Choose the appropriate model

Choosing the right large model is crucial for an AI application. An optimal model needs to consider the model's context length, inference capabilities, and overall performance, as well as how to maximize its effect in practical applications. Dify, as an AI platform, supports all the mainstream Large Language Models (LLMs) on the market, allowing users to choose the most suitable one according to their specific needs.

When selecting an AI model, first consider the model's context length, which determines how much text the model can process. For applications that need to understand and generate longer texts, choose a model with a longer context length. Next, consider the model's inference capabilities, i.e., the speed and accuracy with which the model processes and responds to queries. Different models have entirely different capabilities and quality of output for different types of data.

Each model has their unique features. To help users make the best choice, Dify also offers an innovative feature - ChatHub - allowing users to compare the performance of different models under the same conditions. In this way, users can see the advantages and limitations of each model intuitively, making a wiser choice. Users can choose the most suitable model based on their needs – such as response speed, accuracy, and the ability to handle complex queries.

Simply click on the model, then click on [Multiple Models for Debugging] to enter the debugging interface. Here, a simple comparison of a single output from GPT-4 and GPT-3.5 clearly shows that the answer generated by GPT-4 is different from that of GPT-3.5 in terms of writing style, length, and output quality.

In situations where cost is not a constraint, we recommend choosing the most advanced model currently available, gpt-4-0125-preview. Such a model will ensure that your input and output are not limited and can achieve the best results. If cost is a concern, then choose a model based on your budget, such as the more cost-effective gpt-3.5-turbo, Claude; domestic models like Baichuan, Zhichu, and Minimax. Dify currently supports all mainstream open-source and closed-source models, so you can choose the one that suits your needs and preferences.

Step 5: Publish the Agent

After writing the prompt, remember to click "Publish" to save all changes. Once published, your Agent can be put into use at any time.

If you feel that this intelligent assistant does not meet your needs, try modifying the prompt. You can start with our template and change it to your style, such as changing its output text style, modifying the generated text template, or customizing new Tools to introduce new data sources.

How to put it into use?

After completing the above steps, how do we integrate this travel planning assistant into the existing workflow? Select "Overview" in the left sidebar, where we offer two methods:

  1. Ready-to-use AI WebApp, you can copy the link to the browser for a trial.

  2. Or backend service API, which can be integrated into the backend of your application.

How to Update and Maintain the Agent?

To better solve users' problems, we can actually update the Agent with a series of complex functions or add other Tools to enhance its capabilities:

Firstly, we can let users provide more information, such as through a series of questions to let users provide more details. For example, arrange suitable hotels and transportation according to the number of people, or plan suitable play projects and itinerary intensity according to age (such as the elderly or children). For example, it's completely unrealistic for a family of four to include an 18-kilometer hike in a day in their travel plans. This is not feasible for children.

Secondly, we can increase the information sources for searches. We can introduce real-time travel planning and hotel booking sites, such as Google Map, Ctrip, Airbnb, etc., to provide users with more comprehensive information. For example, a user who wants to travel to Paris can book local hotels and popular restaurants directly through the Agent, saving a lot of effort.

Thirdly, add navigation to the attractions on the way, helping users clearly understand how to reach their destination. This way, when users plan to visit a famous attraction, they can see the location of the attraction in the application and how to get there from their current location.

Lastly, we can create a reasonable timeline for the output content and adjust and maintain it based on user feedback. This means that the Agent will provide a customized itinerary based on the user's time schedule and preferences. For example, if a user wants to visit multiple attractions over a weekend, the Agent will ensure that the user can enjoy as many of them as possible within the limited time.

Start Building AI Assistants Now

Ever thought about creating your own AI Assistant? With Dify, you can start from build a new Assistant, opting for the Agent Assistant mode. Or, take an existing Chat App and switch it to Agent Assistant type right from its prompt setup page. Our docs are a great starting point for your adventure.

We're all for you exploring Dify to turn your one-of-a-kind ideas into reality. Whether you're building your own Agent Assistant or contributing new tools to us, we can't wait to see your creations.

Don’t forget to join our Discord community to share your thoughts and questions. We’re all ears!

On this page

    The Innovation Engine for Generative AI Applications

    The Innovation Engine for Generative AI Applications

    The Innovation Engine for Generative AI Applications