Making Chatbots is Phidata

Hello,
I want to create a chatbot capable of handling multiple agents. The chatbot needs to collect essential information from users, such as their name, age, email, and phone number. Only after all the required details are provided should the chatbot proceed to the next function. Also according to the details acquired I will be performing to next tool or Agent accordingly and also the data should be stored in database. Can this be implemented using Phidata?

Hi @Ajay
Thank you for reaching out and using Phidata! I’ve tagged the relevant engineers to assist you with your query. We aim to respond within 48 hours.
If this is urgent, please feel free to let us know, and we’ll do our best to prioritize it.
Thanks for your patience!

Hi @Ajay
for sure! I would suggest using workflows for this

Hi @Dirk,

Thank you for your response. I am currently working on building a chatbot for an appointment booking use case, where the goal is to collect user information using agents. I aim to create a multi-agent system that gathers user data, manages the process of fetching locations, and handles a more complex flow. This flow includes:

  • Editing the acquired information (e.g., name, age, etc.).
  • Confirming appointment details.
  • Managing payments after confirmation.
  • Handling appointment cancellations.

The chatbot should be capable of efficiently guiding users through these tasks. However, I have tried building the chatbot using phidata but I have encountered several challenges in the development process. For instance:

  1. The chatbot occasionally considers random information without explicitly asking the user for it.
  2. It sometimes selects a location or other options on its own without asking the user for input.

Additionally, I attempted to build this chatbot using phidata but couldn’t find relevant articles or examples for chatbot use cases on the phidata website. If you have any resources, articles, or guidance on building chatbots with phidata, it would be incredibly helpful.

Hi @Ajay

Did you manage to create a workflow for this use case instead of just having a single agent?
Some code snippets of your setup would be beneficial to assist us in better understanding where the issues stem from.

Hi @WillemdeJongh
Here is the code:

master_agent = Agent(
name=“master_travel_agent”,
model= llm,
description=“”"
You are a travel agent you task is to :
1. Answer the user query related to travelling.
2. If there are any queries related to flights you will use ‘flight_agent’.
“”",
instructions=[“You should STRICTLY need to use the agent according to the availability”, “You are not allowed to hallucinate.”,“You should not deviate out of the travel queries.”],
team=[flight_agent],
add_chat_history_to_messages=True,
num_history_responses=5,
prevent_hallucinations=True,
debug_mode=True,
)

gathering_details_agent = Agent(
name=“gather_user_details_agent”,
description=“”"
You are a flight booking agent responsible to book flights:
You are responsible for collecting user data step by step:
- Ask for destinations city.
- Ask for departure city and departure date.

""",
instructions=["Use should not hallucinate user details."],
# tools=[search_flights],
add_chat_history_to_messages=True,
num_history_responses=5,
prevent_hallucinations=True,
debug_mode=True,

)
flight_agent = Agent(
name=“flight_agent”,
model=llm,
description=“”"
You are a flight booking agent responsible to book flights:
STEP: 1 - You are responsible for collecting user data:
- Ask for departure_city and departure_date.

STEP: 2 - After collecting all the user details you should search for flights using 'search_flights'.
STEP: 3 - After user choosing the 'flight_name' use 'ask_confirmation' tool for flight details confirmation. 
STEP: 4 - After user confirming the details proceed for payment 'proceed_payment' tool.

 
""",
instructions=[
    "Use should not hallucinate user details like destination_city, departure_city, departure_time, flight_name, flgiht_time",
    "Use should collect the above mentioned user information step by step."],
# team=[gathering_details_agent],
tools=[search_flights, ask_confirmation, proceed_payment],
add_chat_history_to_messages=True,
num_history_responses=5,
prevent_hallucinations=True,
debug_mode=True

)
import time
while 1:
user_input = input("Input: ")
start_time = time.time()
response1 = master_agent.print_response(user_input)

# print(response1.content)
end_time = time.time()

print(f"Time Taken:{end_time-start_time}")

Please check the above code.

Hi @Ajay

It looks like you are still trying to use agent teams instead of workflows.
Workflows are much more deterministic than agent teams.
Which model are you using? You could try with OpenAI’s o3-mini. It should reduce the hallucinations.