A WebSocket-powered AI agent that provides accurate and competitive pricing quotes based on data from a Notion pricing database. This agent leverages OpenAI's GPT-4o model and integrates with external APIs to deliver real-time pricing information.
The system consists of two main components:
The agent is built using the openai-agents library and provides:
git clone <repository-url>
cd quotation-agent
pip install -r requirements.txt
OPENAI_API_KEY=your_openai_api_key
API_KEY=your_api_security_key
NOTION_API_KEY=your_notion_api_key
NOTION_PAGE_ID=your_notion_page_id
EXCHANGE_RATE_API_KEY=your_exchange_rate_api_key
uvicorn main:app --host 0.0.0.0 --port 8000
Connect to the WebSocket endpoint:
ws://localhost:8000/ws/chat
Send messages as JSON with the following structure:
{
"session_id": "unique-session-id",
"message": "I need a quote for my project requirements",
"user_id": "user123",
"timestamp": "2024-01-01T10:00:00Z",
"message_type": "chat"
}
Receive responses in the following format:
{
"session_id": "unique-session-id",
"message": "Based on your requirements...",
"sender": "agent",
"timestamp": "2024-01-01T10:00:01Z",
"message_type": "response",
"success": true,
"error": null
}
"/clear" or set message_type: "clear" to reset conversation historyThe agent has access to several function tools:
get_pricing_from_notioncurrency_conversionWebSearchTool()GET /
Returns API status (requires API key authentication)
POST /clear-chat
Clears the global conversation history
The project includes a Dockerfile for containerized deployment:
# Build the image
docker build -t quotation-agent .
# Run the container
docker run -p 8000:8000 --env-file .env quotation-agent
{
"session_id": "session123",
"message": "I need a quote for my project requirements",
"message_type": "chat"
}
{
"session_id": "session123",
"message": "What would this cost in USD?",
"message_type": "chat"
}
{
"session_id": "session123",
"message": "Can you break down the pricing for each deliverable?",
"message_type": "chat"
}
An optional Streamlit frontend is provided for testing:
streamlit run frontend.py
Access the web interface at http://localhost:8501
The agent works with pricing data from pricing.txt as its source of information. This document contains structured pricing information that the agent uses to generate accurate quotes.
Key configuration options in main.py:
This project is licensed under the MIT License.
Built with ❤️ by Tom Shaw
$ claude mcp add quotation-agent \
-- python -m otcore.mcp_server <graph>