
A step-by-step guide to building a production-ready customer support chatbot using GPT-4o's function calling and knowledge retrieval.
Vamsi Tallapudi
Manager, Architect Technology at Cognizant
Customer support is one of the best use cases for AI. In this guide, we'll build a bot that can answer questions, escalate to humans, and learn from feedback.
A chatbot that:
pip install openai python-dotenv
Create a .env file:
OPENAI_API_KEY=sk-...
Store your FAQs in a JSON file:
{
"faq": [
{ "q": "What are your hours?", "a": "We're open 9am-6pm IST, Monday to Friday." },
{ "q": "How do I reset my password?", "a": "Click 'Forgot password' on the login page." }
]
}
from openai import OpenAI
import json
client = OpenAI()
def chat_with_bot(user_message: str, history: list) -> str:
system_prompt = """You are a helpful customer support agent for Coderefer.
Answer questions based on the FAQ. If you can't help, say: 'Let me connect you with a human agent.'
"""
messages = [{"role": "system", "content": system_prompt}] + history + [
{"role": "user", "content": user_message}
]
response = client.chat.completions.create(
model="gpt-4o",
messages=messages
)
return response.choices[0].message.content
You now have a basic support bot. Next steps: add a vector database for larger knowledge bases, and integrate with WhatsApp or Slack. OpenAI's new ChatGPT Work mode can now handle multi-step customer interactions automatically, so also consider whether an agentic approach fits your use case. See our full list of AI tools replacing manual work in 2026 for more options.
New AI tools, automation workflows, and course drops — straight to your inbox. Join 2,400+ builders.