# Build a WhatsApp AI shopping bot with Gemini and OpenAI: n8n workflow

> Started by an incoming WhatsApp message, and works across Google Drive, Google Sheets, MongoDB, Redis and one other.

Source: https://millionrounds.com/workflow/build-a-whatsapp-ai-shopping-bot-with-gemini-and-openai (Millionrounds; every figure on the page links to its filing or article)

[Automation library](https://millionrounds.com/workflows) · [Chat assistants](https://millionrounds.com/workflows?category=Chat+assistants#library)

# Build a WhatsApp AI shopping bot with Gemini and OpenAI

Started by an incoming WhatsApp message, and works across Google Drive, Google Sheets, MongoDB, Redis and one other. It puts Gemini and OpenAI behind a retrieval step, so answers are drawn from documents you supply rather than from the model alone. 70 steps, 10 branches, 1 loop or waits: large, and worth reading before you trust it with anything live.

Large Calls a model: Gemini, OpenAI Retrieval

[Download free](https://millionrounds.com/login?next=%2Fapp%2Fworkflow%2Fbuild-a-whatsapp-ai-shopping-bot-with-gemini-and-openai)

**70 steps** Large: read it before trusting it with anything live

**10** Branches: places the flow splits

**1** Loop or waits

**5** Services it connects to

## The flow

Starts it 1 Model 9 Logic 24 Service 26

The steps in the order they run, from what starts it. The first 60 of 70.

- 1 **GPT-5-nano (intent classifier)** Lm Chat Open Ai *Model*
- 2 **GPT-4o (order agent)** Lm Chat Open Ai *Model*
- 3 **Create order in MongoDB** Mongo Db Tool *Service*
- 4 **Get product info from MongoDB** Mongo Db Tool *Service*
- 5 **Log order to Google Sheets** Google Sheets Tool *Service*
- 6 **OpenAI embeddings** Embeddings Open Ai *Model*
- 7 **WhatsApp message trigger** Whats App trigger *Starts it*
- 8 **Session memory for shopping agent** Memory Buffer Window *Model*
- 9 **Session memory for order agent** Memory Buffer Window *Model*
- 10 **AI shopping agent (BytezBot)** Agent *Model*
- 11 **Order orchestration AI agent** Agent *Model*
- 12 **MongoDB Atlas vector search** Vector Store Mongo DBAtlas *Model*
- 13 **Check if message is button or image** If *Logic*
- 14 **Detect JSON intent or plain text reply** Code *Logic*
- 15 **Send order confirmation** Whats App *Service*
- 16 **Download product image from Drive** Google Drive *Service*
- 17 **Combine vector search results with images** Merge *Logic*
- 18 **Route interactive vs image message** Switch *Logic*
- 19 **Validate incoming message** Code *Logic*
- 20 **Append AI reply to session history** Code *Logic*
- 21 **Convert product image to base64** Extract From File *Service*
- 22 **Combine products with base64 images** Code *Logic*
- 23 **Parse button and user data** Code *Logic*
- 24 **Get VTO context from Redis** Redis *Service*
- 25 **Pass valid messages, block invalid** If *Logic*
- 26 **Save session to Redis** Redis *Service*
- 27 **Aggregate all product base64 images** Aggregate *Logic*
- 28 **Store products in cache** Redis *Service*
- 29 **Route VTO vs order button tap** Switch *Logic*
- 30 **Is VTO product ID stored in Redis?** If *Logic*
- 31 **Get user session from Redis** Redis *Service*
- 32 **Send validation error to user** Whats App *Service*
- 33 **Route JSON intent vs plain text reply** If *Logic*
- 34 **Unpack products from cache result** Code *Logic*
- 35 **Set VTO context in Redis** Redis *Service*
- 36 **Extract image ID, waId, and product ID** Code *Logic*
- 37 **Ask user to send correct photo** Whats App *Service*
- 38 **Load session and append user message** Code *Logic*
- 39 **Route product search vs recommend** Switch *Logic*
- 40 **Send text response to user** Whats App *Service*
- 41 **Loop through products** Split In Batches *Logic*
- 42 **Prompt user to upload selfie** Whats App *Service*
- 43 **Get product image from MongoDB** Mongo Db *Service*
- 44 **Get WhatsApp media URL** Http Request *Service*
- 45 **Build Redis cache key from search query** Code *Logic*
- 46 **Build product card message body** Code *Logic*
- 47 **Download product image from Drive (VTO)** Google Drive *Service*
- 48 **Download user selfie** Http Request *Service*
- 49 **Check Redis cache** Redis *Service*
- 50 **Convert product image base64 to binary** Code *Logic*
- 51 **Resize product image to 1024px** Edit Image *Service*
- 52 **Analyze user selfie with Gemini** Google Gemini *Model*
- 53 **Resize user selfie to 1024px** Edit Image *Service*
- 54 **Is product cached in Redis?** If *Logic*
- 55 **Upload product image to WhatsApp** Http Request *Service*
- 56 **Extract product image as base64** Extract From File *Service*
- 57 **Gemini: confirm exactly one person** If *Logic*
- 58 **Extract user selfie as base64** Extract From File *Service*
- 59 **Parse cached product JSON array** Code *Logic*
- 60 **Send product message with buttons** Http Request *Service*

## How it's built

- **Starts on:** An incoming WhatsApp message
- **Steps:** 70, with 10 branches, 1 loop or waits
- **Size:** Large: read it before trusting it with anything live
- **Connects to:** Google Drive, Google Sheets, MongoDB, Redis, WhatsApp
- **Model:** Gemini, OpenAI
- **Retrieval:** Answers are drawn from documents you supply, not from the model alone

## Questions

What does it need to run?

An n8n account, plus your own Google Drive, Google Sheets, MongoDB, Redis and WhatsApp accounts, and a key for Gemini and OpenAI. You connect your own accounts after importing it; none are included.

What starts it?

It starts on an incoming WhatsApp message.

Does it use AI?

Yes. It calls Gemini and OpenAI. Its answers draw on documents you give it, not on the model alone. Model calls are billed by the provider, not by n8n.

How long does it take to set up?

Take your time. At 70 steps it is large: read it before trusting it with anything live.

How do I import it?

Copy the workflow, open a new workflow in n8n and paste. The steps appear on the canvas, ready for your own accounts.

**Before you run it**

Nothing here has been tested by us. It is somebody's working automation, read and described from its own steps. Treat the connections it wants as a list of accounts it will touch, and read the 70 steps before you point it at anything that matters.

## Run it in n8n

- **Create your n8n account** Free to start. n8n is where the workflow runs. [Create an n8n account ↗](https://millionrounds.com/n8n)
- **Download the workflow** Free with a Millionrounds account. [Download free](https://millionrounds.com/login?next=%2Fapp%2Fworkflow%2Fbuild-a-whatsapp-ai-shopping-bot-with-gemini-and-openai)
- **Paste it into n8n** Open a new workflow in n8n and paste. Then connect your own accounts.

Stored with the author's traces removed: canvas notes, instance identifiers, saved credential names and any live document they had left behind.

## Connects to

Each opens the other workflows that use it.

[Google Drive](https://millionrounds.com/workflows?service=Google+Drive#library)[Google Sheets](https://millionrounds.com/workflows?service=Google+Sheets#library)[MongoDB](https://millionrounds.com/workflows?service=MongoDB#library)[Redis](https://millionrounds.com/workflows?service=Redis#library)[WhatsApp](https://millionrounds.com/workflows?service=WhatsApp#library)

## Workflows like it

Also chat assistants, with the same services where possible, closest in size first.

- [**Spreadsheet data into smart charts with OpenAI** 76 steps · calls a model · Google Drive, Google Sheets](https://millionrounds.com/workflow/spreadsheet-data-into-smart-charts-with-openai)
- [**Run AI employee onboarding with Groq and Google Workspace** 62 steps · calls a model · Gmail, Google Drive](https://millionrounds.com/workflow/run-ai-employee-onboarding-with-groq-and-google-workspace)
- [**Multi-agent healthcare assistant with WhatsApp and OpenAI** 49 steps · calls a model · Google Sheets, WhatsApp](https://millionrounds.com/workflow/multi-agent-healthcare-assistant-with-whatsapp-and-openai)
- [**Smart kitchen & inventory assistant with OpenAI** 43 steps · calls a model · Google Sheets, Telegram](https://millionrounds.com/workflow/smart-kitchen-and-inventory-assistant-with-openai)
- [**Attendance system with OpenAI and Google Sheets** 41 steps · calls a model · Google Sheets, Telegram](https://millionrounds.com/workflow/attendance-system-with-openai-and-google-sheets)
- [**Generate consensus-based answers with Claude and OpenAI** 41 steps · calls a model · Gmail, Slack](https://millionrounds.com/workflow/generate-consensus-based-answers-with-claude-and-openai)
