{"id":11011,"date":"2026-09-23T17:12:12","date_gmt":"2026-09-23T20:12:12","guid":{"rendered":"https:\/\/z-api.io\/blog\/?p=11011"},"modified":"2026-09-23T17:15:11","modified_gmt":"2026-09-23T20:15:11","slug":"how-to-build-an-ai-powered-whatsapp-chatbot-with-n8n-z-api-chatgpt","status":"publish","type":"post","link":"https:\/\/z-api.io\/blog\/en\/how-to-build-an-ai-powered-whatsapp-chatbot-with-n8n-z-api-chatgpt\/","title":{"rendered":"How to build an AI-powered WhatsApp chatbot with n8n + Z-API + ChatGPT"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Building an AI-powered WhatsApp chatbot is no longer a project reserved for large development teams. With a messaging API, an automation platform, and a language model, you can create workflows capable of receiving questions, understanding context, and replying automatically.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In this guide, <strong>you\u2019ll learn how to build an AI chatbot with n8n, Z-API, and ChatGPT<\/strong>. The workflow is based on the video tutorial referenced for this content and has been expanded with information from the technical documentation of each tool.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The architecture is straightforward: <strong>Z-API connects the WhatsApp number to the system; n8n receives events and orchestrates the workflow; and the AI interprets messages and generates responses<\/strong>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Conversation memory allows the chatbot to take previous interactions into account, while webhooks and message-sending configurations deliver the response back to the customer.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The result goes beyond a simple keyword-based autoresponder. It becomes a conversational operation that can integrate with CRMs, e-commerce platforms, scheduling systems, ERPs, knowledge bases, and internal systems.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What is an AI-powered WhatsApp chatbot with n8n, and how does it work?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">An AI-powered WhatsApp chatbot is a system capable of receiving a message, understanding its content, generating a response, and sending it back to the user without requiring an agent to manually perform every step.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Traditional bots usually depend on menus, keywords, and predefined paths. A chatbot connected to a language model, on the other hand, <strong>can understand natural-language questions and generate more flexible responses<\/strong>.<\/p><div class=\"advads-blog-ads-no-post advads-entity-placement\" style=\"text-align: center;\" id=\"advads-400053779\"><div id=\"advads-3680220322\"><a href=\"https:\/\/hubs.li\/Q04pCy0Y0\" target=\"_blank\" aria-label=\"Banner_002\"><img src=\"https:\/\/z-api.io\/blog\/wp-content\/uploads\/2026\/06\/Banner_002.jpg\" alt=\"\"  srcset=\"https:\/\/z-api.io\/blog\/wp-content\/uploads\/2026\/06\/Banner_002.jpg 1200w, https:\/\/z-api.io\/blog\/wp-content\/uploads\/2026\/06\/Banner_002-300x88.jpg 300w, https:\/\/z-api.io\/blog\/wp-content\/uploads\/2026\/06\/Banner_002-1024x299.jpg 1024w, https:\/\/z-api.io\/blog\/wp-content\/uploads\/2026\/06\/Banner_002-768x224.jpg 768w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" width=\"1200\" height=\"350\"   \/><\/a><\/div><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">That does not mean letting AI respond without any controls. A professional chatbot needs a clear objective, context, boundaries, reliable data sources, and rules for handing conversations over to human agents.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In the workflow covered in this tutorial:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>The customer sends a message through WhatsApp.<\/li>\n\n\n\n<li>Z-API forwards the event to n8n through a webhook.<\/li>\n\n\n\n<li>n8n identifies the contact and extracts the message.<\/li>\n\n\n\n<li>The OpenAI model receives the text and instructions.<\/li>\n\n\n\n<li>Memory, when configured, retrieves the session context.<\/li>\n\n\n\n<li>n8n receives the generated response.<\/li>\n\n\n\n<li>Z-API sends the text back through WhatsApp.<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/z-api.io\/en\" target=\"_blank\" rel=\"noreferrer noopener\">Z-API<\/a> provides a REST API and webhooks for interacting with WhatsApp and receiving events from the connected number.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What tools do you need?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">To recreate this architecture, you need a Z-API instance, an n8n account, and OpenAI credentials.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th><strong>Component<\/strong><\/th><th><strong>Role<\/strong><\/th><th><strong>Required information<\/strong><\/th><\/tr><\/thead><tbody><tr><td><strong>Z-API<\/strong><\/td><td>Receive and send messages<\/td><td>Instance ID, Token, and Client Token if enabled<\/td><\/tr><tr><td><strong>n8n<\/strong><\/td><td>Orchestrate events and integrations<\/td><td>Workflow and HTTPS webhook URL<\/td><\/tr><tr><td><strong>OpenAI<\/strong><\/td><td>Interpret messages and generate responses<\/td><td>API Key and model<\/td><\/tr><tr><td><strong>Memory<\/strong><\/td><td>Maintain context across interactions<\/td><td>Session identifier and memory configuration<\/td><\/tr><tr><td><strong>CRM\/internal system<\/strong><\/td><td>Retrieve or store data<\/td><td>API or corresponding credentials<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Z-API also provides a <strong>community node for n8n<\/strong>, which can simplify message-sending operations. Alternatively, you can use an HTTP Request node with the API\u2019s <code>send-text<\/code> endpoint.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">On <a href=\"https:\/\/app.n8n.cloud\/login\" target=\"_blank\" rel=\"noreferrer noopener\"><strong>n8n Cloud<\/strong><\/a>, the availability of community nodes depends on the platform\u2019s verification rules. In self-hosted environments, they can be installed directly.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How do you configure incoming messages with Z-API?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The first step is to create a workflow in n8n that can receive external requests. Add a <strong>Webhook<\/strong> node, set the method to POST, and copy the generated URL.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">n8n provides both a test URL and a production URL. During development, use the test URL so you can inspect incoming data. Once the workflow has been published, switch to the production URL.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In Z-API, the incoming-message webhook is configured with a PUT request to <code>update-webhook-received<\/code>. <strong>The URL you provide must use HTTPS<\/strong>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>curl --request PUT \\\n  --url https:\/\/api.z-api.io\/instances\/{instanceId}\/token\/{token}\/update-webhook-received \\\n  --header 'Client-Token: YOUR_CLIENT_TOKEN' \\\n  --header 'Content-Type: application\/json' \\\n  --data '{\n    \"value\": \"https:\/\/your-n8n.com\/webhook\/whatsapp-receive\"\n  }'\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Replace these values with the credentials and URL from your own instance. <strong>Never publish tokens in articles, repositories, or screenshots<\/strong>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Adjust your filters before testing<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">If your chatbot does not need to process messages sent by the connected number itself, disable those notifications. Z-API provides the <code>update-notify-sent-by-me<\/code> endpoint to control this behavior.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This prevents the bot from processing its own reply and entering a message loop.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To ignore groups, the webhook includes the <code>isGroup<\/code> attribute. In n8n, you can add a filter so the workflow continues only when <strong><code>isGroup<\/code> is <code>false<\/code><\/strong>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Your filters should match your use case: <strong>a one-to-one customer service chatbot may ignore groups, while other automations may need to process them<\/strong>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Still exploring what Z-API can do? <strong><a href=\"https:\/\/z-api.io\/blog\/en\/official-whatsapp-api-vs-z-api-differences-costs-and-risks-in-2026\/\" target=\"_blank\" rel=\"noreferrer noopener\">Read our guide about Z-API vs. Official WhatsApp API.<\/a><\/strong><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How do you process the incoming payload in n8n?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">After the Webhook, <strong>you can add a Code node in JavaScript to transform the incoming event into a predictable structure<\/strong>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The Z-API webhook includes fields such as phone number, message ID, timestamp, source, and content type. For text messages, the content appears in <code>text.message<\/code>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Here is an example normalization:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>const body = $json.body ?? $json;\n\nreturn &#091;{\n  json: {\n    phone: body.phone,\n    text: body.text?.message?.trim() ?? \"\",\n    messageId: body.messageId,\n    timestamp: body.momment,\n    fromMe: body.fromMe,\n    isGroup: body.isGroup,\n    raw: body\n  }\n}];\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The <code>phone<\/code>, <code>messageId<\/code>, <code>momment<\/code>, <code>fromMe<\/code>, and <code>isGroup<\/code> fields are part of the callback documented by Z-API.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>This example handles text messages.<\/strong> Images, audio, video, documents, and other content types have their own structures and should be handled according to the payload received.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">After normalization, use filter nodes to stop the workflow when there is no phone number or text, when <code>fromMe<\/code> is <code>true<\/code>, or when the event does not match your use case.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Validating the payload before calling OpenAI helps prevent unnecessary processing, errors, and response loops.<\/strong><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How do you configure the AI Agent in n8n?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Once the data has been organized, add an <strong>AI Agent<\/strong> node. It receives the input, uses a chat model, and can call tools to perform tasks.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In current versions of n8n, the AI Agent works as a <strong>Tools Agent and needs at least one connected tool<\/strong>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For a chatbot that only generates responses, a Basic LLM Chain may be enough. If you need to retrieve order data, check schedules, or access internal systems, use the AI Agent with the appropriate tools and permissions.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Connect the OpenAI chat model<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Add the <strong>OpenAI Chat Model<\/strong>, configure your API Key, and select an available model.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The video may use a specific model, <strong>but your choice should take cost, speed, and task complexity into account<\/strong>, since available models change over time. OpenAI publishes current model options and API pricing in its documentation.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Lower-cost models may work well for FAQs and initial triage, while more complex tasks may require more capable models.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How do you write the system prompt?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The prompt defines the chatbot\u2019s <strong>purpose, behavior, boundaries, and escalation criteria<\/strong>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For example:<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\">You are the virtual assistant for Flower &amp; Gifts, a flower shop specializing in bouquets and gifts.<br>Help customers choose products and provide delivery times and opening hours only when that information is available.<br>Reply in American English, clearly and concisely.<br>Do not invent prices, inventory, or delivery times.<br>For payments, order changes, complaints, or requests for human support, hand the conversation over to the team.<br>Do not claim that an action has been completed unless the system confirms it.<\/p>\n<\/blockquote>\n\n\n\n<p class=\"wp-block-paragraph\">The same structure can be adapted to different businesses.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>The prompt guides the model, but critical controls should live in the workflow and tool permissions<\/strong>, not only in the instructions.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How do you add conversation memory?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Without memory, each message may be processed without any context from previous interactions. With memory, the agent can take recent exchanges into account.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In the tutorial, <strong>Simple Memory<\/strong> can use the phone number as the session key:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Session Key: {{$json.phone}}\n\nContext Window Length: 10\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The Context Window Length <strong>represents the number of previous interactions included in the context<\/strong>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">A phone number is a convenient session key, but it should be normalized. In larger operations, an internal CRM ID may be more appropriate.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Memory is not a knowledge base<\/strong>. For pricing, products, policies, or up-to-date information, the agent should query specific sources such as APIs, databases, or RAG systems.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">There is also an important limitation: <strong>n8n advises against using Simple Memory in production workflows running in queue mode<\/strong>. In that scenario, use persistent memory such as Redis or Postgres instead.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How do you send the response back to WhatsApp?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">After the AI Agent generates a response, you can use a <strong>Code<\/strong> node to validate or normalize the text before sending it. This step is optional.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The agent\u2019s response often appears in a field such as <code>output<\/code>, but you should confirm the actual node output structure before mapping the expression.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In the tutorial, <strong>the response can be sent through the Z-API WhatsApp community node using the Send Text Message operation<\/strong>. The phone number comes from the webhook, while the message comes from the agent output.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You can also send the message directly through the Z-API API:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>curl --request POST \\\n  --url https:\/\/api.z-api.io\/instances\/{instanceId}\/token\/{token}\/send-text \\\n  --header 'Client-Token: YOUR_CLIENT_TOKEN' \\\n  --header 'Content-Type: application\/json' \\\n  --data '{\n    \"phone\": \"5511999999999\",\n    \"message\": \"Hello! How can I help?\"\n  }'\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The <code>send-text<\/code> endpoint uses <code>phone<\/code> and <code>message<\/code> in the request body. In n8n, these values should come from previous nodes:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Phone: {{$node&#091;\"Code \u2013 Normalize Input\"].json.phone}}\n\nMessage: {{$node&#091;\"AI Agent\"].json.output}}\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Avoid hardcoding the phone number or message in the workflow<\/strong>. When the send request is accepted, Z-API returns identifiers such as <code>zaapId<\/code>, <code>messageId<\/code>, and <code>id<\/code>, which can be stored for <strong>correlation, status tracking, and troubleshooting<\/strong>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How do you test the chatbot without repeatedly sending messages?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">During development, you can capture the JSON from a real execution and reuse it in your tests.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">n8n allows you to <strong>pin data from a node and reuse it in manual executions<\/strong>, avoiding additional calls to the external system. (<a href=\"https:\/\/github.com\/n8n-io\/n8n-docs\/blob\/main\/docs\/build\/work-with-data\/pin-and-mock-data.md?utm_source=chatgpt.com\" target=\"_blank\" rel=\"noreferrer noopener\"><strong>github.com<\/strong><\/a>)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Capture a real message, save the payload, and use it to test normalization, prompts, and memory.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>If the sending node is still active, the workflow may send a real message<\/strong>, so stop the flow before that step when you only want to test the logic.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You should also test greetings, incomplete questions, out-of-scope requests, requests for human support, and different media types.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Text, image, audio, video, and document messages have different payload structures. <strong>Files received through Z-API remain available for 30 days and require type-specific handling<\/strong>. (<a href=\"https:\/\/developer.z-api.io\/en\/tips\/file-expiration?utm_source=chatgpt.com\" target=\"_blank\" rel=\"noreferrer noopener\"><strong>developer.z-api.io<\/strong><\/a>)<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How do you prevent loops and duplicate responses?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">A loop can occur when the bot processes a message sent by its own number as though it were a new incoming message.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">When those events are not needed, disable <code>notifySentByMe<\/code>. Z-API provides a dedicated setting for this. (<a href=\"https:\/\/developer.z-api.io\/en\/webhooks\/update-notify-sent-by-me?utm_source=chatgpt.com\" target=\"_blank\" rel=\"noreferrer noopener\"><strong>developer.z-api.io<\/strong><\/a>)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If you need to keep the setting enabled, filter out events where <code>fromMe: true<\/code>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">It is also a good idea to store the <code>messageId<\/code> of processed events and <strong>ignore IDs that have already been handled<\/strong>. This idempotency reduces the risk of duplicate processing.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If a customer sends several messages in quick succession, parallel executions may occur. <strong>For more complex workflows, use queues or session-level controls to preserve processing order<\/strong>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How do you create a human fallback?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Your chatbot needs an exit path for situations where it does not have enough information, encounters an exception, or receives a request for human support.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The handoff can be triggered by <strong>business rules, explicit requests, missing data, or repeated failures<\/strong>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">When this happens, pause the automation for that conversation and send the context to the support team.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\">\u201cGot it. I\u2019ll hand your conversation over to a member of our team, along with the context you\u2019ve already provided.\u201d<\/p>\n<\/blockquote>\n\n\n\n<p class=\"wp-block-paragraph\">The fallback should also account for technical failures. If the AI model is unavailable while WhatsApp remains operational, the workflow can send an alternative response.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If the Z-API send operation itself fails, <strong>log the error, alert the team, and apply the recovery strategy defined for your operation<\/strong>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Are you already aware of the new pricing for WhatsApp Business? <a href=\"https:\/\/z-api.io\/blog\/en\/whatsapp-per-message-pricing-how-to-prepare-for-october-2026\/\" target=\"_blank\" rel=\"noreferrer noopener\">Read our article and find out how to prepare for October 2026.<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Security: how do you protect tokens and data?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Z-API and OpenAI credentials are sensitive information. <strong>Never publish tokens in code, screenshots, videos, or repositories<\/strong>. In n8n, use the platform\u2019s credential system and appropriate access controls.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In Z-API, the Client Token can add an additional layer of protection to your instances. When enabled, it must be included with authorized requests.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The webhook also requires attention: use HTTPS, minimize logged data, and avoid storing unnecessary personal information in logs.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If the chatbot accesses CRM records, order information, or financial data, <strong>apply the principle of least privilege to all credentials and tools available to it<\/strong>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The prompt can instruct the agent not to reveal internal data or claim that unconfirmed actions were completed, but security controls should exist in the workflow and permission layer, not only in the prompt.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How do you turn the chatbot into a sales and support agent?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The basic workflow answers questions. With additional integrations, it can also <strong>execute controlled processes<\/strong>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Tools connected to the AI Agent can retrieve orders, check schedules, register leads, or update opportunities. <strong><a href=\"https:\/\/n8n.io\/\" target=\"_blank\" rel=\"noreferrer noopener\">n<\/a><\/strong><a href=\"https:\/\/n8n.io\/\" target=\"_blank\" rel=\"noopener\"><strong>8n<\/strong><\/a> orchestrates those integrations, while Z-API maintains communication with WhatsApp.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th><strong>Stage<\/strong><\/th><th><strong>Action<\/strong><\/th><th><strong>Possible integration<\/strong><\/th><\/tr><\/thead><tbody><tr><td>Capture<\/td><td>Identifies the contact and their interest<\/td><td>CRM<\/td><\/tr><tr><td>Qualification<\/td><td>Collects needs, timeframe, and budget<\/td><td>CRM or database<\/td><\/tr><tr><td>Recommendation<\/td><td>Retrieves suitable options<\/td><td>Catalog or internal system<\/td><\/tr><tr><td>Conversion<\/td><td>Sends a proposal, checkout, or scheduling option<\/td><td>ERP, e-commerce, or calendar<\/td><\/tr><tr><td>Follow-up<\/td><td>Re-engages opportunities according to defined rules<\/td><td>CRM and n8n<\/td><\/tr><tr><td>Handoff<\/td><td>Escalates complex cases<\/td><td>Customer service platform<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">AI should not invent operational information: <strong>prices, inventory, delivery times, and status updates must come from the system responsible for that data<\/strong>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Metrics to track chatbot performance<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">A chatbot should not be evaluated only by message volume.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Track metrics such as automated resolution rate, handoff rate, messages per interaction, cost per resolution, qualified leads, and conversions.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You should also analyze failures: <strong>which questions went unanswered, where customers dropped out of the flow, and which requests required more human intervention<\/strong>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This data helps improve prompts, memory, integrations, and the overall experience.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th><strong>Metric<\/strong><\/th><th><strong>What it reveals<\/strong><\/th><\/tr><\/thead><tbody><tr><td>Automated resolution rate<\/td><td>How much the chatbot resolves without human help<\/td><\/tr><tr><td>Handoff<\/td><td>Which requests require human support<\/td><\/tr><tr><td>Messages per interaction<\/td><td>Workflow efficiency<\/td><\/tr><tr><td>Response time<\/td><td>Operational speed<\/td><\/tr><tr><td>Technical errors<\/td><td>Workflow reliability<\/td><\/tr><tr><td>Qualified leads<\/td><td>Contribution to sales<\/td><\/tr><tr><td>Conversion by journey<\/td><td>Business results<\/td><\/tr><tr><td>Cost per resolution<\/td><td>Automation viability<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Mistakes to avoid<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The first mistake is starting with the prompt before defining the process. <strong>Before choosing a model, determine which problem you need to solve and which data will be required<\/strong>.<\/li>\n\n\n\n<li>The second is exposing credentials. Published tokens can provide unauthorized access to your APIs.<\/li>\n\n\n\n<li>The third is failing to filter messages sent by the connected number itself when those events are enabled, creating loops and duplicate responses.<\/li>\n\n\n\n<li>The fourth is keeping too much context. Excessive history increases costs and may cause the model to consider outdated or irrelevant information.<\/li>\n\n\n\n<li>The fifth is giving the AI no path to human support. When the system cannot resolve an issue, the workflow should escalate the conversation.<\/li>\n\n\n\n<li>The sixth is failing to log what happened. <strong>IDs, statuses, and logs are essential for troubleshooting failures and monitoring chatbot behavior<\/strong>.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Quick step-by-step overview<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">To get the workflow running:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Connect WhatsApp to a Z-API instance.<\/li>\n\n\n\n<li>Create an n8n workflow with a POST Webhook.<\/li>\n\n\n\n<li>Configure the incoming-message webhook in Z-API.<\/li>\n\n\n\n<li>Adjust <code>notifySentByMe<\/code> and any required filters.<\/li>\n\n\n\n<li>Capture a real payload for testing.<\/li>\n\n\n\n<li>Normalize the phone number, text, ID, and timestamp.<\/li>\n\n\n\n<li>Configure the OpenAI model.<\/li>\n\n\n\n<li>Use a chain for simple responses or an AI Agent with tools for actions.<\/li>\n\n\n\n<li>Configure memory with a session key.<\/li>\n\n\n\n<li>Add message sending through Z-API or an HTTP Request.<\/li>\n\n\n\n<li>Test errors, duplicates, and human handoff.<\/li>\n\n\n\n<li>Publish the workflow and monitor logs, statuses, and metrics.<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">Take your WhatsApp operation to the next level<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Building an AI-powered WhatsApp chatbot with n8n, Z-API, and OpenAI <strong>makes it possible to turn conversations into automated workflows connected to your company\u2019s systems<\/strong>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The basic architecture combines a webhook, data processing, an AI model, memory, and message sending. From there, you can connect CRMs, e-commerce platforms, scheduling systems, ERPs, and knowledge bases.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">When authorized tools are available, the agent can also perform specific actions across integrated systems.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The result depends less on simply connecting tools and more on designing a well-defined operation. <strong>Clear prompts, controlled memory, protected credentials, loop prevention, logs, human handoff, and performance metrics<\/strong> all make the workflow more reliable.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If your company wants to automate customer service, qualify leads, or connect WhatsApp to internal systems, Z-API provides APIs and webhooks to integrate the channel into your automations.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Click the banner below, create your Z-API account, and connect WhatsApp to your automation workflows.<\/strong><\/p>\n\n\n<div class=\"kk-star-ratings kksr-auto kksr-align-right kksr-valign-bottom\"\n    data-payload='{&quot;align&quot;:&quot;right&quot;,&quot;id&quot;:&quot;11011&quot;,&quot;slug&quot;:&quot;default&quot;,&quot;valign&quot;:&quot;bottom&quot;,&quot;ignore&quot;:&quot;&quot;,&quot;reference&quot;:&quot;auto&quot;,&quot;class&quot;:&quot;&quot;,&quot;count&quot;:&quot;1&quot;,&quot;legendonly&quot;:&quot;&quot;,&quot;readonly&quot;:&quot;&quot;,&quot;score&quot;:&quot;5&quot;,&quot;starsonly&quot;:&quot;&quot;,&quot;best&quot;:&quot;5&quot;,&quot;gap&quot;:&quot;5&quot;,&quot;greet&quot;:&quot;Avalie este post&quot;,&quot;legend&quot;:&quot;5\\\/5 - (1 vote)&quot;,&quot;size&quot;:&quot;24&quot;,&quot;title&quot;:&quot;How to build an AI-powered WhatsApp chatbot with n8n + Z-API + ChatGPT&quot;,&quot;width&quot;:&quot;142.5&quot;,&quot;_legend&quot;:&quot;{score}\\\/{best} - ({count} {votes})&quot;,&quot;font_factor&quot;:&quot;1.25&quot;}'>\n            \n<div class=\"kksr-stars\">\n    \n<div class=\"kksr-stars-inactive\">\n            <div class=\"kksr-star\" data-star=\"1\" style=\"padding-right: 5px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" data-star=\"2\" style=\"padding-right: 5px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" data-star=\"3\" style=\"padding-right: 5px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" data-star=\"4\" style=\"padding-right: 5px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" data-star=\"5\" style=\"padding-right: 5px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n    <\/div>\n    \n<div class=\"kksr-stars-active\" style=\"width: 142.5px;\">\n            <div class=\"kksr-star\" style=\"padding-right: 5px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" style=\"padding-right: 5px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" style=\"padding-right: 5px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" style=\"padding-right: 5px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" style=\"padding-right: 5px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n    <\/div>\n<\/div>\n                \n\n<div class=\"kksr-legend\" style=\"font-size: 19.2px;\">\n            5\/5 - (1 vote)    <\/div>\n    <\/div>\n<div class=\"advads-banner-cta advads-entity-placement\" id=\"advads-1666155378\"><div id=\"advads-2507948802\"><a href=\"https:\/\/hubs.li\/Q04pCy0Y0\" target=\"_blank\" aria-label=\"Banner_006\"><img src=\"https:\/\/z-api.io\/blog\/wp-content\/uploads\/2026\/06\/Banner_006.jpg\" alt=\"\"  srcset=\"https:\/\/z-api.io\/blog\/wp-content\/uploads\/2026\/06\/Banner_006.jpg 1200w, https:\/\/z-api.io\/blog\/wp-content\/uploads\/2026\/06\/Banner_006-300x88.jpg 300w, https:\/\/z-api.io\/blog\/wp-content\/uploads\/2026\/06\/Banner_006-1024x299.jpg 1024w, https:\/\/z-api.io\/blog\/wp-content\/uploads\/2026\/06\/Banner_006-768x224.jpg 768w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" width=\"1200\" height=\"350\"   \/><\/a><\/div><\/div>","protected":false},"excerpt":{"rendered":"<p>Learn how to create an AI chatbot for WhatsApp using n8n, Z-API, and OpenAI\u2014featuring memory, automations, integrations, and a human fallback option.<\/p>\n","protected":false},"author":16,"featured_media":11012,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"content-type":"","footnotes":""},"categories":[221,231,208],"tags":[],"class_list":["post-11011","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-whatsapp-automation","category-tutorials","category-whatsapp-api-en-us"],"_links":{"self":[{"href":"https:\/\/z-api.io\/blog\/en\/wp-json\/wp\/v2\/posts\/11011","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/z-api.io\/blog\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/z-api.io\/blog\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/z-api.io\/blog\/en\/wp-json\/wp\/v2\/users\/16"}],"replies":[{"embeddable":true,"href":"https:\/\/z-api.io\/blog\/en\/wp-json\/wp\/v2\/comments?post=11011"}],"version-history":[{"count":2,"href":"https:\/\/z-api.io\/blog\/en\/wp-json\/wp\/v2\/posts\/11011\/revisions"}],"predecessor-version":[{"id":11015,"href":"https:\/\/z-api.io\/blog\/en\/wp-json\/wp\/v2\/posts\/11011\/revisions\/11015"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/z-api.io\/blog\/en\/wp-json\/wp\/v2\/media\/11012"}],"wp:attachment":[{"href":"https:\/\/z-api.io\/blog\/en\/wp-json\/wp\/v2\/media?parent=11011"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/z-api.io\/blog\/en\/wp-json\/wp\/v2\/categories?post=11011"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/z-api.io\/blog\/en\/wp-json\/wp\/v2\/tags?post=11011"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}