Respond to WhatsApp Messages with AI Like a Pro! n8n Workflow Template

n8n workflow template · 24 nodes · WhatsApp Business Cloud

Respond to WhatsApp Messages with AI Like a Pro! is a free n8n workflow template that starts from the WhatsApp Business Cloud Trigger node and works with WhatsApp Business Cloud, Wikipedia and Google Gemini. It has 24 nodes, 8 of them AI nodes (Window Buffer Memory, Wikipedia Tool, Basic LLM Chain and Google Gemini Chat Model). The notes inside the workflow say: “Join the Discord or ask in the Forum!” To run it, you add your own credentials for Google Gemini (PaLM) API, Whats App Trigger API and WhatsApp Business Cloud API.

At a glance

Trigger
WhatsApp Business Cloud Trigger (WhatsApp Trigger)
Nodes
24
Apps
WhatsApp Business Cloud, Wikipedia and Google Gemini
AI nodes
8
Credentials
3 types
Category
Chatbots and messaging

Apps and integrations

  • WhatsApp Business Cloud
  • Wikipedia
  • Google Gemini

Node types used

  • WhatsApp Business Cloud Trigger
  • WhatsApp Business Cloud
  • HTTP Request
  • Window Buffer Memory
  • Edit Fields (Set)
  • Split Out
  • Wikipedia Tool
  • Switch
  • Wait
  • Basic LLM Chain
  • Google Gemini Chat Model
  • AI Agent

How it works

The text below comes from the sticky notes inside the workflow. We removed links, code samples and anything that looks like a key or token.

Try It Out!

This n8n template demonstrates the beginnings of building your own n8n-powered WhatsApp chatbot! Under the hood, utilise n8n's powerful AI features to handle different message types and use an AI agent to respond to the user. A powerful tool for any use-case!

  • Incoming WhatsApp Trigger provides a way to get messages into the workflow.
  • The message received is extracted and sent through 1 of 4 branches for processing.
  • Each processing branch uses AI to analyse, summarize or transcribe the message so that the AI agent can understand it.
  • The AI Agent is used to generate a response generally and uses a wikipedia tool for more complex queries.
  • Finally, the response message is sent back to the WhatsApp user using the WhatsApp node.

Need Help?

Join the Discord or ask in the Forum!

Activate workflow to use!

You must activate the workflow to use this WhatsApp Chabot. If you are self-hosting, ensure WhatsApp is able to connect to your server.

1. WhatsApp Trigger

Learn more about the WhatsApp Trigger

To start receiving WhatsApp messages in your workflow, there are quite a few steps involved so be sure to follow the n8n documentation. When we recieve WhatsApp messages, we'll split out the messages part of the payload and handle them depending on the message type using the Switch node.

2. Transcribe Audio Messages

For audio messages or voice notes, we can use GPT4o to transcribe the message for our AI Agent.

3. Describe Video Messages

For video messages, one approach is to use a Multimodal Model that supports parsing video. Currently, Google Gemini is a well-tested service for this task. We'll need to use the HTTP request node as currrently n8n's LLM node doesn't currently support video binary types.

4. Analyse Image Messages

For image messages, we can use GPT4o to explain what is going on in the message for our AI Agent.

5. Text summarizer

For text messages, we don't need to do much transformation but it's nice to summarize for easier understanding.

Google Gemini Required!

Not using Gemini? Feel free to swap this out for any Multimodal Model that supports Audio.

Google Gemini Required!

Not using Gemini? Feel free to swap this out for any Multimodal Model that supports Video.

7. Respond to WhatsApp User

Read more about the Whatsapp node

To close out this demonstration, we'll simple send a simple text message back to the user. Note that this WhatsApp node also allows you to send images, audio, videos, documents as well as location!

Setup notes

The text below comes from the sticky notes inside the workflow. We removed links, code samples and anything that looks like a key or token.

6. Generate Response with AI Agent

Read more about the AI Agent node

Now that we'll able to handle all message types from WhatsApp, we could do pretty much anything we want with it by giving it our AI agent. Examples could include handling customer support, helping to book appointments or verifying documents.

In this demonstration, we'll just create a simple AI Agent which responds to our WhatsApp user's message and returns a simple response.

Nodes in this workflow

The 24 nodes in file order (sticky notes excluded). Branches and connections determine execution order in n8n:

  1. WhatsApp Trigger (WhatsApp Business Cloud Trigger)
  2. Get Audio URL (WhatsApp Business Cloud)
  3. Get Video URL (WhatsApp Business Cloud)
  4. Get Image URL (WhatsApp Business Cloud)
  5. Download Video (HTTP Request)
  6. Download Audio (HTTP Request)
  7. Download Image (HTTP Request)
  8. Window Buffer Memory (Window Buffer Memory)
  9. Get User's Message (Edit Fields (Set))
  10. Split Out Message Parts (Split Out)
  11. Wikipedia (Wikipedia Tool)
  12. Redirect Message Types (Switch)
  13. Get Text (Wait)
  14. Respond to User (WhatsApp Business Cloud)
  15. Image Explainer (Basic LLM Chain)
  16. Format Response (Edit Fields (Set))
  17. Google Gemini Chat Model (Google Gemini Chat Model)
  18. Google Gemini Audio (HTTP Request)
  19. Google Gemini Video (HTTP Request)
  20. Google Gemini Chat Model1 (Google Gemini Chat Model)
  21. Google Gemini Chat Model2 (Google Gemini Chat Model)
  22. Format Response1 (Edit Fields (Set))
  23. Text Summarizer (Basic LLM Chain)
  24. AI Agent (AI Agent)

Credentials you need

  • Google Gemini (PaLM) API – used by Google Gemini Audio, Google Gemini Chat Model, Google Gemini Chat Model1 and Google Gemini Chat Model2 and others
  • Whats App Trigger API – used by WhatsApp Trigger
  • WhatsApp Business Cloud API – used by Download Audio, Download Image, Download Video and Get Audio URL and others

Configure your own credentials after importing. Create each credential in n8n, then select it in the node.

How to import into n8n

  1. Download the JSON file with the button above.
  2. In n8n, open a new workflow, select the ... menu and choose Import from File. You can also paste the JSON straight into the editor canvas.
  3. Open each node that shows a warning and select or create its credential.
  4. Read the notes on the canvas, test the workflow with sample data, then activate it.

Do you need somewhere to run it? Read our guide to self-hosted n8n.

Need this customised?

We can adapt this workflow to your apps, data and process, then deploy and support it.

Contact Us