A FastAPI-based chatbot designed to help users with Wi-Fi issues and generate support reports for administrators. The bot provides sarcastic and humorous responses while collecting valuable troubleshooting information.
Base URL: https://email-agent-api-16z6.onrender.com
- Interactive Chat: Sarcastic Wi-Fi support chatbot powered by Groq's Llama model
- Session Management: Maintains conversation history per session
- Report Generation: Summarizes conversations for admin review
- Email Integration: Sends reports via email using SMTP
- CORS Enabled: Ready for frontend integration
- FastAPI - Modern web framework for building APIs
- Groq - LLM API for chat responses
- Pydantic - Data validation and serialization
- aiosmtplib - Async email sending
- python-dotenv - Environment variable management
chat_bot/
├── main.py # FastAPI application and endpoints
├── client.py # Groq API integration
├── config.py # Configuration and API key loading
├── mailer.py # Email functionality
├── summarizer.py # Chat summarization logic
├── requirements.txt # Python dependencies
├── render.yaml # Render deployment configuration
├── .env # Environment variables (not in repo)
└── .gitignore # Git ignore rules
git clone <repository-url>
cd chat_botpip install -r requirements.txtCreate a .env file in the root directory:
GROQ_API_KEY=your_groq_api_key_here
EMAIL_USER=your_smtp_email@gmail.com
EMAIL_PASS=your_app_password
EMAIL_TO=admin@company.comuvicorn main:app --reloadThe API will be available at http://localhost:8000
https://email-agent-api-16z6.onrender.com
POST /chat
Start or continue a conversation with the Wi-Fi support bot.
Request Body:
{
"session_id": "string",
"user_message": "string"
}Response:
{
"reply": "string",
"session_id": "string"
}Example Request:
curl -X POST "https://email-agent-api-16z6.onrender.com/chat" \
-H "Content-Type: application/json" \
-d '{
"session_id": "",
"user_message": "My Wi-Fi is not working"
}'Example Response:
{
"reply": "Oh wow, another genius who can't figure out Wi-Fi. Let me guess - have you tried the ancient art of turning it off and on again? But seriously, what exactly is 'not working'? No connection? Slow speeds? Or did your router just decide to take a vacation?",
"session_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
}POST /submit-report
Generate a summary of the conversation and optionally send it via email.
Request Body:
{
"session_id": "string",
"userEmail": "user@example.com",
"sendEmail": true
}Response:
{
"summary": "string",
"sent": true
}Example Request:
curl -X POST "https://email-agent-api-16z6.onrender.com/submit-report" \
-H "Content-Type: application/json" \
-d '{
"session_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"userEmail": "user@example.com",
"sendEmail": true
}'Example Response:
{
"summary": "User reported Wi-Fi connectivity issues. Bot suggested basic troubleshooting steps including router restart and checking cable connections. User confirmed trying basic steps. Issue appears to be intermittent connection drops.",
"sent": true
}400 Bad Request:
{
"detail": "Validation error message"
}404 Not Found:
{
"detail": "No conversation found"
}500 Internal Server Error:
{
"detail": "Error message"
}- Start Chat: Send a POST request to
/chatwith an emptysession_idto start a new conversation - Continue Chat: Use the returned
session_idfor subsequent messages in the same conversation - Generate Report: When ready, send a POST request to
/submit-reportwith thesession_idto get a summary - Email Report: Set
sendEmail: truein the report request to email the summary to administrators
The application is deployed on Render using the render.yaml configuration file.
Set these in your Render dashboard:
GROQ_API_KEYEMAIL_USEREMAIL_PASSEMAIL_TO
Visit the deployed API documentation:
- Swagger UI:
https://email-agent-api-16z6.onrender.com/docs - ReDoc:
https://email-agent-api-16z6.onrender.com/redoc
import requests
base_url = "https://email-agent-api-16z6.onrender.com"
# Start a conversation
chat_response = requests.post(f"{base_url}/chat", json={
"session_id": "",
"user_message": "My internet is slow"
})
session_id = chat_response.json()["session_id"]
# Continue conversation
requests.post(f"{base_url}/chat", json={
"session_id": session_id,
"user_message": "I already tried restarting the router"
})
# Generate report
report_response = requests.post(f"{base_url}/submit-report", json={
"session_id": session_id,
"userEmail": "user@example.com",
"sendEmail": False
})
print(report_response.json()["summary"])- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
For support and questions, please open an issue in the GitHub repository.