iSolvoltar ao site

ENGINEERING

A WhatsApp assistant answered by your own gateway

August 2026 · 5 min read

Just activated iSol API? Your key lives in the customer portal, isollm.ai/account → API keys (the portal shows the raw sk-… value; store it in your secret manager). The endpoint for every guide on this blog is https://tokens.4clouders.com/v1, and per-key spend updates live on the same portal page. That is all you need to follow along.

Why WhatsApp + your own gateway

In Brazil, WhatsApp is the customer channel. Which is exactly why its AI assistant should not forward customer conversations to a vendor endpoint you cannot audit. The pattern is the same as every guide in this series: the messaging side stays standard (Meta Cloud API), and the intelligence comes from a gateway you control.

Step 1: WhatsApp side (Meta, once)

  1. Create an app at developers.facebook.com → add the WhatsApp product.
  2. From API Setup, note the WHATSAPP_TOKEN and the WHATSAPP_PHONE_ID (Meta gives you a test number to start).
  3. Point the webhook at your server's /webhook and subscribe to messages.

Step 2: The webhook (complete)

import os, requests
from flask import Flask, request

app = Flask(__name__)
ISOL = "https://tokens.4clouders.com/v1/chat/completions"
KEY = os.environ["ISOL_API_KEY"]
WA_TOKEN = os.environ["WHATSAPP_TOKEN"]
PHONE_ID = os.environ["WHATSAPP_PHONE_ID"]

def ask_isol(text: str) -> str:
    r = requests.post(ISOL, timeout=60,
        headers={"Authorization": f"Bearer {KEY}"},
        json={"model": "isol-4.9", "messages": [
            {"role": "system", "content": "You are the company's WhatsApp assistant. Be brief and friendly."},
            {"role": "user", "content": text}]})
    r.raise_for_status()
    return r.json()["choices"][0]["message"]["content"]

@app.post("/webhook")
def incoming():
    change = request.json["entry"][0]["changes"][0]["value"]
    for msg in change.get("messages", []):
        if msg.get("type") == "text":
            reply = ask_isol(msg["text"]["body"])
            requests.post(
                f"https://graph.facebook.com/v21.0/{PHONE_ID}/messages",
                headers={"Authorization": f"Bearer {WA_TOKEN}"},
                json={"messaging_product": "whatsapp", "to": msg["from"],
                      "type": "text", "text": {"body": reply}})
    return "ok"

Step 3: Run one message through it, for real

Below, the handler processes a message exactly as Meta delivers it, and the reply comes back from the sovereign gateway, in Portuguese, ready to post to graph.facebook.com:

Real run of the WhatsApp webhook handler answering in Portuguese through the iSol gateway
Real call, captured 2026-08-19: the reply text came from the live gateway. Key masked.
Real session: the handler processing the message in the format Meta delivers and the answer ready to post back (3.5s measured).

Gotchas we hit running this for real

Handler executed against the live iSol gateway on 2026-08-19. Chat-side screenshots come from the deployment walkthrough, bring your Meta app.

Same gateway, rest of your stack: every guide with real sessions

The pattern: one gateway, every tool Telegram GitHub Actions Teams Claude Code Cursor VS Code aider OpenCode n8n Zapier Power Automate Power BI Google Sheets Website chatbot Hermes Agent

Try it on ours

Our gateway (iSol API) runs exactly this setup on sovereign infrastructure, US$ 99/month, 14-day trial.

See plans →