WhatsApp Business Bot

Written by Madhu Dath

This is not a tutorial! But yes, I did create a WhatsApp bot using WhatsApp Cloud and Gemini API. It took several attempts, but it worked, at least untill I changed the display name.

Start with creating an App

Create a Meta App using meta business suit. Go to developer.facebook.com and click on my apps.

You can then create a new app.

Set up the webhook

You need to verify your domain which will interact with the WhatsApp Cloud API.

This requires you to write a code on the server. I used Cloudflare Workers.

The code will accept a GET request and return the challenge.

Then you can write the code that accepts post request, which are messages from user.

Write the Code

The code will accept a POST request and perform a function.

Here’s where you need to set up Gemini.

Setting up gemini

You can set up Gemini by going to Google’s AI Studio

Just start a new prompt and click get code. This will tell you the structure of the post request you need to make to get Gemini response.

Also generate an API key, which you will use in the function.

Complete the function to get Gemini response

Complete the function that will run when WhatsApp sends a post request.

Write another function to send message to customer

Now, you can send the response to the customer. This will require you to write another function, which will send the response as a message to WhatsApp cloud API with the correct phone number id.

The End

This was not a tutorial, but I hope gave you some idea. Rest is up to you. Anyway, I will be writing more tutorials.

Published on: 2025-03-31

whatsapp cloud api

gemini api

learning

whatsapp bot