Last week, we announced new integrations to empower developers to deploy Holiday Planning AI Agents. The holiday-integrations example on our Github provides a demo of how these integrations can ease the holiday booking experience for the user. You can try this demo for yourself, and execute it in five simple steps.
Let’s dive into the repo and discover the future of personalized travel!
Before starting, you'll need the following:
Clone the repository using:
git clone https://github.com/fetchai/uAgents-examples.git
Once it’s done, we will navigate to the holiday-integrations folder and use Poetry to install required dependencies:
cd uAgents-examples/holiday-integrations poetry install
To run the demo, you need API keys from:
Note that if you’ve run out of OpenAI credits, you will not be able to get results for this example.
Once you have all three keys, create a .env file in the holiday-integrations/src directory.
export RAPIDAPI_API_KEY='REPLACE_THIS_WITH_YOUR_RAPIDAPI_KEY' export OPENAI_API_KEY='REPLACE_THIS_WITH_YOUR_OPENAI_KEY' export SERPAPI_API_KEY='REPLACE_THIS_WITH_YOUR_SERPAPI_KEY'
Navigate to the src directory and start the main.py script:
cd src poetry run python main.py
You need to look for the following output in the logs:
Adding top destinations agent to Bureau: {top_dest_address}
Copy the {top_dest_address} value and paste it somewhere safe. You will need it in the next step.
Now that we have set up the integrations, let’s run a client script that will showcase the ‘top destinations’. To do this, create a new Python file in the src folder called top_dest_py, and paste the following:
from messages import TopDestinations, UAgentResponse from uagents import Agent, Context from uagents.setup import fund_agent_if_low import os TOP_DESTINATIONS_CLIENT_SEED = os.getenv("TOP_DESTINATIONS_CLIENT_SEED", "top_destinations_client really secret phrase :)") top_dest_client = Agent( name="top_destinations_client", port=8008, seed=TOP_DESTINATIONS_CLIENT_SEED, endpoint=["http://127.0.0.1:8008/submit"], ) fund_agent_if_low(top_dest_client.wallet.address()) top_dest_request = TopDestinations(preferences="new york") @top_dest_client.on_interval(period=10.0) async def send_message(ctx: Context): await ctx.send("REPLACE_THIS_WITH_YOUR_TOP_DEST_ADDRESS", top_dest_request) @top_dest_client.on_message(model=UAgentResponse) async def message_handler(ctx: Context, _: str, msg: UAgentResponse): ctx.logger.info(f"Received top destination options from: {msg.options}") if __name__ == "__main__": top_dest_client.run()
Remember to replace the address in ctx.send with the value you received in the previous step.
This code sends a request to get the top destinations (in this example, in New York). To do this, it sends a request to the ‘TopDestinations agent’ every 10 seconds and displays the options in the console.
Open a new terminal (let the previous one be as is), and navigate to the src folder to run the client.
cd src poetry shell python top_dest_client.py
Once you hit enter, a request will be sent to the top destinations agent every 10 seconds, and you will be able to see your results in the console!