Give your WhatsApp chatbot a brain. This guide connects Google's Gemini AI to WA.Expert through the External API Request step, so your bot can answer open questions in its own words.
A normal chatbot can only answer what you scripted. Connect it to Gemini and it can handle questions you never anticipated, in natural language, drawing on the model's general knowledge or on context you feed it. You do this with one External API Request step that sends the customer's message to Gemini and brings the answer back into the chat.
This guide gives you the exact values to use. If you have not met the External API Request step before, read the field-by-field foundation guide first; here we assume you know what the fields are and focus on what Gemini specifically needs.
Google is mid-way through changes to how Gemini keys work and which model names are current. Because of that, this guide leans on the durable parts, the endpoint shape, the header name, the body structure, and links you to Google's live documentation for the two things that drift: the exact model name and the latest key rules. If a specific name here looks different in your console, trust the console and Google's docs; the method below still applies.
The key is what proves the request is yours. You get it from Google AI Studio, which is the lightweight developer path (as opposed to the heavier enterprise route through Vertex AI).
For the current key rules, which Google is actively updating through 2026, see Google's own page: Using Gemini API keys. This is the authority for what a valid key needs today.
Now the request itself. Here is exactly how the step should look, followed by each value.
POST. You are sending the model a prompt, so this is a send, not a read.
The generateContent endpoint for your chosen model. The shape is fixed; only the model name in the middle changes as Google releases new versions.
https://generativelanguage.googleapis.com/v1beta/models/gemini-3.5-flash:generateContentThe endpoint uses v1beta (this is correct, not a typo; most current features land there first). Replace the model name with the current stable model from Google's models documentation if it has changed.
Gemini takes the key in a header. Add two header parameters:
| Header name | Value |
|---|---|
| x-goog-api-key | Your Gemini API key (the AIza... string) |
| Content-Type | application/json |
The x-goog-api-key header is Google's current recommended method. Avoid the older key= URL parameter, which exposes the key in logs.
Set Body Type to JSON and send the contents structure Gemini expects. Put the customer's message where the text is, pulling it from your flow rather than hard-coding it.
{
"contents": [
{
"parts": [
{ "text": "{{customer_message}}" }
]
}
]
}Here {{customer_message}} is a placeholder for the value you map in from the conversation. You can also prepend instructions, for example a sentence telling Gemini to answer as your business's support assistant, before the customer's text.
Gemini answers with a JSON structure. The text you want sits inside the candidates list, in the content's parts. Set Response Type to Default Response and map that field into the next step, a WhatsApp message back to the customer.
{
"candidates": [
{
"content": {
"parts": [
{ "text": "...the model's answer is here..." }
]
}
}
]
}So the path to the answer is the first candidate, then content, then the first part, then text. Map that into your reply message and the customer receives Gemini's response inside WhatsApp, in the same conversation, with no app-switching.
When a customer messages your bot, a 24-hour service window is open, so the reply carrying Gemini's answer is free on the WhatsApp side. You only pay Google for the Gemini usage. Sending AI replies as part of an ongoing customer conversation is therefore cheap: free WhatsApp delivery, plus Google's per-token charge for the AI itself.
A customer messages your store asking something your scripted bot does not cover, say, whether a fabric is machine washable. Your flow catches the unmatched question and routes it to the Gemini step. You prepend a short instruction so the model stays on-brand, then send the customer's question.
{
"contents": [
{
"parts": [
{ "text": "You are the support assistant for a clothing store. Answer briefly and politely. Customer question: {{customer_message}}" }
]
}
]
}Gemini replies with a short, polite answer, your flow maps it into a WhatsApp message, and the customer gets a useful response in seconds. For anything the model should not handle, an order change, a refund, you route to a human instead. The AI covers the long tail of open questions; people handle the decisions that matter.
| Symptom | Likely cause | Fix |
|---|---|---|
| 403 or authentication error | Key is unrestricted, or wrong header name | Restrict the key to the Generative Language API, or create a new key; check the header is exactly x-goog-api-key |
| 404 not found | Model name in the URL is wrong or retired | Check Google's models docs for the current model name and update the URL |
| 400 bad request | Body JSON is malformed or the text field is empty | Validate the JSON; confirm {{customer_message}} is being mapped in and is not blank |
| 429 too many requests | Free-tier rate limit hit | Slow the requests, or enable billing on the Google Cloud project for higher limits |
| Empty reply | Mapped the wrong path in the response | Map from candidates, then content, then parts, then text, in that order |
The response the step returns almost always contains Google's own error message, which names the exact problem. Read it first.
Of all these, the 404 from a retired model name is the most likely to hit you months from now, because Google retires older model versions on a schedule. If your working bot suddenly returns 404s, the model name in your URL has almost certainly been deprecated. Swap in the current stable model from Google's docs and it works again, nothing else needs to change.
Free trial, no credit card required. And if you ever get stuck, we are the only platform in India that answers you live on WhatsApp.