Como Construir um Agente de Chatbot de IA para WhatsApp Usando n8n
Na era da transformação digital, a automação se tornou uma peça chave para muitas empresas. Um dos avanços mais interessantes nesse campo é a integração da Inteligência Artificial (IA) aos canais de comunicação, como o WhatsApp. Neste artigo, vamos explorar como construir um agente de chatbot de IA para WhatsApp utilizando a plataforma n8n e a API oficial do WhatsApp Cloud. Este tutorial é o décimo dia do desafio de 30 dias de automação de IA, e nós vamos guiá-lo em cada passo do processo.
O Que é o n8n?
O n8n é uma plataforma de automação de workflows de código aberto que permite integrar diferentes serviços e APIs de maneira intuitiva. Ele não apenas ajuda a automatizar tarefas, mas também oferece uma interface visual que facilita a configuração e a gestão dos fluxos de trabalho. Com a capacidade de se conectar a muitos serviços, o n8n é uma escolha popular para desenvolvedores e profissionais de marketing que buscam implementar soluções de automação.
Por Que Criar um Chatbot para WhatsApp?
O WhatsApp é uma das plataformas de mensagens mais populares do mundo, com bilhões de usuários ativos. Criar um chatbot para essa plataforma pode trazer uma série de benefícios para empresas e indivíduos, incluindo:
- Atendimento ao Cliente 24/7: Um chatbot pode responder a perguntas a qualquer hora do dia, melhorando a experiência do cliente.
- Automatização de Tarefas: Tarefas repetitivas como agendamento de compromissos ou fornecimento de informações podem ser automatizadas.
- Coleta de Dados: Chatbots podem ser usados para coletar informações valiosas de clientes, que podem ser usadas para aprimorar produtos ou serviços.
Pré-requisitos Para a Construção do Chatbot
Antes de começarmos, você precisará atender a alguns pré-requisitos:
- Conta no WhatsApp Business: Acesse o WhatsApp Business e obtenha acesso à API do WhatsApp Cloud.
- n8n Instalado: Você deve ter o n8n instalado em sua máquina ou em um servidor acessível.
- Conhecimento Básico em Programação (opcional): Embora não seja necessário, ter um entendimento básico em programação pode facilitar o processo.
Passo a Passo: Construindo o Chatbot
Passo 1: Configuração do WhatsApp Cloud API
- Crie uma Conta no Facebook Developer: Acesse o site do Facebook Developer e crie uma conta, se ainda não tiver uma.
- Configure um Aplicativo: Crie um novo aplicativo e escolha “WhatsApp” como um dos produtos.
- Obter o Token de Acesso: No painel do aplicativo, você deverá gerar um token de acesso que permitirá que o n8n faça chamadas à API do WhatsApp Cloud.
Passo 2: Configuração do n8n
- Inicie o n8n: Se ainda não estiver em execução, inicie sua instância do n8n.
- Crie um Novo Workflow: Na interface do n8n, clique em “New” e comece a criar seu workflow.
- Adicione um Trigger: O primeiro passo é adicionar um trigger que será ativado quando uma nova mensagem for recebida no WhatsApp. Você deve usar o nó de HTTP Webhook para isso. Configure-o de acordo com a documentação da API do WhatsApp Cloud.
Passo 3: Processando Mensagens Recebidas
-
Adicionar um Nó de Função: Após o trigger, adicione um nó de função, que será responsável por processar a mensagem recebida. Nesse nó, você pode identificar palavras-chave e criar uma lógica básica de respostas.
javascript
const message = $input.item.json.message;if (message.includes(‘oi’)) {
return [{json: {reply: ‘Olá! Como posso ajudar?’}}];
} else {
return [{json: {reply: ‘Desculpe, não entendi sua mensagem.’}}];
}
Passo 4: Enviando Respostas
-
Adicionar um Nó HTTP Request: Agora você precisa adicionar um nó HTTP Request que enviará a resposta do chatbot de volta ao WhatsApp. Configure este nó para usar o método POST e insira a URL da API do WhatsApp Cloud.
-
Configurar o Corpo da Requisição: O corpo da requisição deve conter a mensagem que você deseja enviar ao usuário. Utilize o JSON a seguir:
json
{
“messaging_product”: “whatsapp”,
“to”: “{{ $input.item.json.from }}”,
“text”: {
“body”: “{{ $input.item.json.reply }}”
}
}
Passo 5: Teste o Workflow
- Salve o Workflow: Salve e ative o workflow no n8n.
- Envie uma Mensagem pelo WhatsApp: Use o seu número do WhatsApp Business para enviar uma mensagem ao seu chatbot e verifique se a resposta correta é recebida.
Passo 6: Publicação e Escalabilidade
Uma vez que você tenha testado e verificado que tudo está funcionando bem, você pode considerar ampliar o alcance do seu chatbot:
- Personalização da Experiência: Utilize técnicas de NLP (Processamento de Linguagem Natural) para oferecer respostas mais contextualizadas e personalizadas.
- Integração com CRM: Considere integrar seu chatbot com sistemas de CRM para coletar e gerenciar informações dos clientes.
Conclusão
Neste tutorial, guiamos você por todas as etapas necessárias para criar um agente de chatbot de IA para WhatsApp usando n8n e a API do WhatsApp Cloud. A automação de processos de atendimento ao cliente por meio de chatbots é uma tendência crescente, e a construção desse tipo de solução não precisa ser complexa, especialmente com ferramentas como o n8n.
A automação não apenas economiza tempo, mas também permite que você ofereça um atendimento ao cliente de alta qualidade e disponível 24/7. Aproveite essa tecnologia e inicie o seu projeto de chatbot hoje mesmo!
Se você gostou deste artigo, não esqueça de compartilhar e acompanhar os próximos passos do nosso desafio de 30 dias de automação de IA!


Hello sir pls can it work for many people unlike the one I built Whenever people send messages it replies to me instead of them.
Well put together training Ola!! I am really enjoying this! I am on day 10 and noticed you did not share the prompt for the whatsapp workflow. Can you share please?
The class was amazing. I was able to build my own workflow!
Thank you so much for this gem. God bless you!
@Anythingdata please how can I get the prompt you use for day 10 I've been stocked here cos I don't know what to do, maybe you can let me know how to get it or kindly send them here please. Thank you
Thank you so much for this Mr Adeeko.
Please how can I get the prompt expression because it's not very clear in the video while trying to type it out?
Good evening guys please can anyone drop day 10 prompt here if you have it🙏
Good morning please I need day 10 prompt
Good morning beautiful people, can someone kindly drop day 10 prompt here please
It awesome.
Work Whatsapp not trigger Whatsapp oAuth Account No 3 to 2 You can it 13:21
I think meta has changed their interface and it giving me alot of problem for the past three days. Does anyone have another remedy to it.
Please, i need help…
After logging into the website for the meta stuff, it is not working…
I can't seem to find the page he used to teach, and i don't know why
Thanks for the class. I followed through and get it right
Thanks so much. i have tried this several times yet i am not receiving any message
This is great thanks for simplifying the whole process. I followed through and it worked
I am getting this error message while trying to create the app using whatsap developers
Error message: Onboarding Failure
We limit how often you can post, comment or do other things in a given amount of time to help protect the community from spam. You can try again later.
Onboarding Failure
We limit how often you can post, comment or do other things in a given amount of time to help protect the community from spam. You can try again later. Learn More
I got stocked as Facebook limit my account while going through the process of onboarding the app. I will skip this for now and continue with another tutorial but if anyone encounter this issue please kindly assist
Hello everybody, I have not been able to solve the Whatsapp Problems both On message and message send, whoever have the solution should please explain to us . Mr Adeeko, I see you as God sent, you make AI Automation simpler than expected.
Please we need prompt you use or better you give teach our to generate those prompt
Thank you so much for this in depth class
Hi all. Those who went up to sending a message and testing the chatbot. Please can you share the prompt messages you used? Those who have access to the Newsletter would have it. Unfortunately, I am not receiving the newsletter.
One question I keep asking everyone who has successfully built a WhatsApp chatbot is if they have ever encountered a situation where the trigger doesn't respond. What could be the issue? I get stalk when my trigger doesn't respond.
Please sir I couldn't open a developer
God will continue to bless you and everything that you do 🙏I really appreciate this opportunity,sir
Dear Team. Please i need assistance
Please i tested the send part of the whatsapp chatbot (day 10). i receive response but once i joined it to the agent, and execute, no response again. Anyone that had gone pass this stage should please assist me
Please I did not receive the sent message on my WhatsApp number. Is it because it is not a business account?
Thanks sir.
I have a question. what is your thought pattern and method for coming up with the right solutions as regard automations.
I an thinking of several user case as well as pain point and challenges businesses face and how to solve them with automations. an looking at CRMs, Google sheets, calendars, forms and a whole lot here.
thanks once more sir
Thank you sir for this tutorial…I did mine on a later day and it happened that the 'other' option you clicked has been removed and I don't know where else to click. The places I tried didn't give me anything similar to yours.
I continued building though but definitely can't get results because my WhatsApp nodes can't execute anything. Thank you again. I'll keep trying to fix it
Try to make a video on using an actual Nigerian number
Thank you fro all the good work God bless you, ple i need the system prompt for the WhatsApp message thanks
Hello! Everyone, I've tried several times with this WhatsApp automation, but for some reason, it is not working. The WhatsApp Input trigger is listening successfully, but it is unable to receive input from my WhatsApp. Similarly, I'm unable to send a message to my WhatsApp number from the meta-generated test number except for the WhatsApp Business Security code. I need help.
Thank you sir impacting us, God bless you
But am stock at creating account on meta, it refused to send code to my mail
Hi
So I am getting the message on Facebook on send but nothing on n8n
Thank you instructor… Please my free n8n cloud will expire soon and I have not been able to install it locally bcoz my docker didn't run due to virtualization problem. Plesywhat should I do to continue this training?? Thank you sir
Thanks boss, God bless you sir, pls registering Whatsapp number as business number is it with the service provider or using Whatsapp business, thanks God bless you
Thank you very much for this tutorial sir.
Sir, my test number is not working even though it says "node executed successfully". I don't get any whatsapp message.
Meta required for payment to verified the account
May God bless you
Thank you very much for this sir.
Sir, my test number is not working even though it says "node executed successfully". i don't get any whatsapp message
Thanks for today's class. I was unable to access the system message both in the newsletter and on YouTube. I guess you forgot to attach it.