Building Conversational Agents
Creating agents that maintain context in conversations
Conversational agents remember what you’ve said and maintain context throughout the chat.
Quick Start
from praisonaiagents import Agent
# Create a conversational agent with memory
agent = Agent(
instructions="You are a friendly assistant. Remember what users tell you.",
memory=True # Enable conversation memory
)
# Have a conversation
agent.start("Hi! My name is Alex.")
agent.start("What's my name?") # Agent remembers: "Alex"How Memory Works
| Feature | Without Memory | With Memory |
|---|---|---|
| Context | Each message is new | Remembers past messages |
| Personalization | None | Remembers preferences |
| Multi-turn | Limited | Full conversation flow |
Use Cases
Customer Support
Remember customer details and issue history
TutoringTrack learning progress and adapt
Personal AssistantRemember preferences and tasks
CompanionBuild relationship over time
Example: Customer Support Bot
from praisonaiagents import Agent
support_bot = Agent(
name="SupportBot",
instructions="""You are a customer support agent.
- Greet customers warmly
- Ask for details about their issue
- Provide step-by-step solutions
- Remember their name and issue details""",
memory=True
)
# Multi-turn conversation
support_bot.start("Hi, I can't log into my account")
support_bot.start("My email is alex@example.com")
support_bot.start("I tried resetting but no email came")
# Agent remembers all context and provides relevant helpExample: Learning Tutor
from praisonaiagents import Agent
tutor = Agent(
name="MathTutor",
instructions="""You are a patient math tutor.
- Explain concepts step by step
- Use simple language
- Give practice problems
- Remember what the student has learned""",
memory=True
)
# Teaching session
tutor.start("Can you help me with algebra?")
tutor.start("What does 2x + 5 = 13 mean?")
tutor.start("So I subtract 5 first?")
tutor.start("Then divide by 2 to get x = 4?")
# Tutor tracks progress and builds on previous explanationsComplete Example
from praisonaiagents import Agent
# Personal assistant with memory
assistant = Agent(
name="PersonalAssistant",
instructions="""You are a personal assistant.
Remember:
- User's name and preferences
- Tasks they mention
- Topics they're interested in
Be helpful, friendly, and personalized.""",
memory=True
)
# Build a relationship over multiple messages
assistant.start("Hi! I'm Sarah and I love hiking.")
assistant.start("What outdoor activities would you recommend?")
assistant.start("I prefer mountains over beaches.")
assistant.start("What should I do this weekend?")
# Assistant remembers Sarah likes hiking and mountainsBest Practices
Enable Memory
Use memory=True for any multi-turn conversation
Clear Instructions
Tell the agent what to remember in instructions
Consistent Personality
Define a clear personality in instructions
Handle Context
Agent automatically manages conversation history
Next: Building Research Agents
Learn how to create agents that search and gather information.