Building an AI Customer Support Chatbot with Google Gemini 2.0 for Nigerian SMEs
Step-by-step guide to integrating Google Gemini 2.0 Flash into a Next.js API route to build a context-aware AI customer support chatbot — with Nigerian business context baked in.
Why AI Chatbots Make Sense for Nigerian SMEs in 2026
Nigeria's SME sector is booming, but most small and medium businesses can't afford 24/7 customer support staff. An AI chatbot trained on your product knowledge can handle 60–80% of routine customer queries automatically — FAQs, order status, pricing inquiries, delivery timelines.
In 2026, Google Gemini 2.0 Flash is the best choice for Nigerian deployments: it's fast (sub-500ms responses), affordable ($0.075 per million input tokens), and handles Nigerian English and pidgin reasonably well.
Architecture Overview
User → Next.js API Route → Google Gemini 2.0 Flash API → Streamed Response
↕
PostgreSQL (conversation history)
Setting Up the Gemini API Client
// lib/gemini.ts
import { GoogleGenAI } from '@google/genai';
const ai = new GoogleGenAI({ apiKey: process.env.GEMINI_API_KEY! });
export async function generateChatResponse(
userMessage: string,
conversationHistory: Array<{ role: string; content: string }>,
systemContext: string
): Promise<string> {
const model = ai.models.generateContent;
const contents = [
...conversationHistory.map(msg => ({
role: msg.role as 'user' | 'model',
parts: [{ text: msg.content }],
})),
{
role: 'user' as const,
parts: [{ text: userMessage }],
},
];
const response = await ai.models.generateContent({
model: 'gemini-2.0-flash',
contents,
config: {
systemInstruction: systemContext,
temperature: 0.3, // Lower temp for factual customer support
maxOutputTokens: 500,
},
});
return response.text ?? 'I apologize, I could not process your request.';
}
System Prompt for Nigerian Business Context
const SYSTEM_PROMPT = `
You are a helpful customer support assistant for [Business Name],
a Nigerian [business type] company based in [City], Nigeria.
Key information:
- We accept payment via Paystack, bank transfer, and cash on delivery
- Delivery within Lagos: 1-2 business days
- Delivery outside Lagos: 3-5 business days via GIG Logistics or DHL
- Business hours: Monday-Friday 9am-6pm WAT, Saturday 10am-3pm WAT
- For order inquiries, ask for the customer's order number or phone number used to place the order
- Prices are in Nigerian Naira (₦)
Guidelines:
- Be friendly and professional
- If you cannot answer something, direct the customer to call +234 xxx xxx xxxx
- Respond in the same language the customer uses (English, Pidgin, etc.)
- Do not make promises about delivery dates you cannot confirm
`;
Next.js API Route
// app/api/chat/route.ts
import { NextRequest, NextResponse } from 'next/server';
import { generateChatResponse } from '@/lib/gemini';
import { prisma } from '@/lib/prisma';
export async function POST(req: NextRequest) {
const { message, sessionId } = await req.json();
// Fetch conversation history from DB
const history = await prisma.chatMessage.findMany({
where: { sessionId },
orderBy: { createdAt: 'asc' },
take: 10, // Last 10 messages for context
});
const response = await generateChatResponse(
message,
history.map(h => ({ role: h.role, content: h.content })),
SYSTEM_PROMPT
);
// Save message and response
await prisma.chatMessage.createMany({
data: [
{ sessionId, role: 'user', content: message },
{ sessionId, role: 'model', content: response },
],
});
return NextResponse.json({ response });
}
Cost Estimation for Nigerian SMEs
For a typical Nigerian SME with 500 customer conversations/day:
- Average conversation: 6 messages × ~100 tokens = 600 tokens
- Daily token usage: 500 × 600 = 300,000 tokens
- Monthly cost: ~₦135,000 ($90) at current rates
Compare this to a single customer support agent at ₦150,000/month who can only handle ~50 conversations/day during business hours.
The ROI is clear. If you'd like a precise cost estimate for your chatbot, use our project estimator — it covers AI/ML integrations alongside web and mobile work. Or visit our AI development services to see the full scope of what we build.
Neobot Engineering Standard
Every system deployed by Neobot Tech incorporates enterprise baseline practices. We continuously audit our database topologies, REST API query paths, and frontend modular bundles to prevent latency spikes and ensure top-tier security posture.
Discussion
Comments Coming Soon
We are currently migrating our discussion engine to a new real-time database schema. Check back shortly to join the conversation.