Skip to content

How to call an API from a WhatsApp chatbot

The API node sends an HTTP request during the chatbot. Drag Data Blocks → API, set URL and Method, optional headers and body, store the response under Session variable name, then use Test request and connect status-code outputs.

Prerequisites

  • A chatbot in the builder. See How to build a WhatsApp chatbot.
  • A reachable HTTPS (or HTTP) endpoint. API URL is required and must be a valid URL.
  • Optional: earlier Ask Question or Form nodes if you will insert {{variables}} in the body.

Step-by-step

  1. Add the API node
    Open Automation → Chatbots, create or Edit a chatbot, expand Components → Data Blocks, and drag API. Connect it from the previous step.

  2. Set URL and Method
    Enter URL. Set Method to GET, POST, PUT, PATCH, or DELETE.

  3. Add headers and body
    Click Add header for key/value headers. For a body, choose Key-value (Add field) or Raw. Raw supports {{variables}}. Leave the body empty for GET or no body.

  4. Name the session variable
    Set Session variable name (default api). The response body is stored under that key. Use {{api}} for the full body, or a JSON path such as {{api.user.name}}.

  5. Test, branch, and save
    Optionally check Add fallback output for unmatched HTTP status codes. Click Test request (needs a URL). Matching HTTP codes appear under Response cases. Connect those handles (and the fallback if enabled) to later nodes. Click Save. First save uses Save Flow and Chatbot Name.

TIP

Use Test request before going live. A success toast shows HTTP {code}. Truncated bodies note that the preview was truncated.

WARNING

Orphaned nodes block save (This node is not connected to the chatbot). Connect every API node into the path from Start.

FAQ

Can I use chatbot answers in the request?

Yes. Raw body supports {{variables}} from earlier steps such as Ask Question or Form.

What if the HTTP status is not in Response cases?

Enable Add fallback output for unmatched HTTP status codes and connect that handle. Otherwise only tested or listed status codes get their own outputs.

Which methods are supported?

GET, POST, PUT, PATCH, and DELETE.