NashTech Blog

Akka Agent AI: Secret to Planning a Perfect Trip – Part 2

Table of Contents
Akka Agentic AI

Welcome back to our journey to Akka Agentic AI! In Akka Agentic AI: Our First Hello to Agentic AI System, we got introduced to our first ever Akka AI Agent. The next article, Akka Agent AI: Secret to Planning a Perfect Trip – Part 1, provides a step-by-step guide to get started with Akka Agentic AI.

We saw how Akka Agentic AI can help us plan our trip, suggesting places to visit, and ideal trip duration. However, the AI Agent lacked a hint of personalization in its recommendations. Imagine, the AI Agent suggesting a mountain for hiking to the User, but the User doesn’t like hiking. Also, what if recommendations for 2 or more users gets mixed up, since, AI Models are stateless.

This article will guide us through adding personalized recommendations for Users by:

  • Creating an entity for User preferences
  • Using the preferences from the AI Agent
  • And, including a User Id in the endpoint

Add Preferences Entity

  • Extend EventSourcedEntity, with the type of state this entity represents, and the interface for the events it persists.
  • Annotate the class so Akka can identify it as an event-sourced entity.
  • Define the command handler method to add a preference text.
  • Define another command handler to retrieve all preferences.
  • Updates of the Preferences state is performed from the persisted events.

We also need the Preferences and the PreferencesEvent classes. For this use case, we are using simple text preferences, but you can use any structure.

Preferences

PreferencesEvent

Inject Preferences In Planning Agent

  • Inject ComponentClient.
  • Include user id in the request to the agent.
  • Retrieve the preferences for the given user id.
  • In addition to the original message, include the preferences in the user message to the LLM.

Making AI Agent Aware of User Preferences

The last step of making the Akka AI Agent’s recommendations more personalized is making it aware of User preferences.

It is a 2-step process:

1. Add userId to Planning Endpoint

  • Add userId as a path parameter.
  • Call the agent with the new PlanningAgent.Request record that includes the userId.

2. Provide Preferences via Endpoint

  • Add a method to add a preference.
  • Call the PreferenceEntity for the given userId.

Last Step: Plan a Personalized Trip!

1. Set OpenAI API Key as environment variable

2. Start the service locally

3. Provide your Preferences

4. Plan Trip!

If you take a closer look at the recommendations, it has included more of dinning options in the itinerary.

Next Steps

In future we will take a deeper look at how we can align Planning AI Agent to consider the weather forecast before planning the trip. Also, we will learn more about the EventSourceEntity component to persist not just the current state but all events that led to the current state. This will help us in recovering in case of a failure.

References

Picture of Himanshu Gupta

Himanshu Gupta

Himanshu Gupta is a Principal Architect passionate about building scalable systems, AI‑driven solutions, and high‑impact digital platforms. He enjoys exploring emerging technologies, writing technical articles, and creating accelerators that help teams move faster. Outside of work, he focuses on continuous learning and sharing knowledge with the tech community.

Leave a Comment

Your email address will not be published. Required fields are marked *

Suggested Article

Scroll to Top