Jul 20, 2025

[n8n x Poku] SMS AI Agent Guide

If you're new to conversational AI or just want a fast way to get an SMS agent up and running, this tutorial is for you. We'll walk you through how to build an SMS AI agent in n8n that connects with Twilio for texting and Poku to enable powerful features like:

✅ Chat Toggle – Switch between AI mode and human intervention
🚩 Conversation Flagging – Detect and flag edge cases or custom criteria mid-conversation

Download this PDF guide or follow the instructions below:


🧰 What You’ll Need

Before building, make sure you have the following:

  • A Poku account (sign in with Gmail)

  • Your Poku API Key (found under the Account tab)

  • A Twilio account with an A2P 10DLC verified phone number

  • Your Twilio SID and Auth Token

  • An n8n account

  • An OpenAI API key (or similar LLM provider)

🛠️ Step-by-Step Setup

Step 1: Connect Twilio to n8n

  • Start with a Twilio Trigger Node that listens for incoming SMS messages.

  • “Test Step” by texting your Twilio number to capture the message structure.

Step 2: Add Poku Inbound Request

To check the chat toggle and enable conversation flagging:

  • Add an HTTP Request Node right after the trigger.

  • Method: POST

  • URL: https://api.pokulabs.com/chats/inbound

  • Headers:

    Authorization: Bearer YOUR_POKU_API_KEY
  • Body (Raw JSON):

    {
      "message": "{{json.body}}",
      "to": "{{json.to}}",
      "from": "{{json.from}}"
    }

This lets Poku check whether the AI agent should respond—or if a human should take over.

Step 3: Add Filter for Chat Toggle

Insert a Filter Node to check the toggle status:

  • Use this expression:

    {{json.isDisabled}} is not equal to true

If the toggle is flipped to Human Mode in your Poku dashboard, this will stop the AI from responding.

Step 4: Set Up Your AI Agent

  • Add the AI Agent Node (OpenAI, or other LLM provider).

  • Pass the prompt:

    • Input: {{json.data.body}}

    • System Message: Write your agent's core prompt.

  • For memory:

    • Use a key like {{json.data.to}}{{json.data.from}}

    • Set how many messages you would like to retrieve to maintain context

Step 5: Add Poku Outbound Message Analysis

This enables outbound flagging (optional but powerful):

  • Add another HTTP Request Node

  • Method: POST

  • URL:

    https://api.pokulabs.com/chats/outbound
  • Body:

    {
      "message": "{{json.body}}",
      "to": "{{json.to}}",
      "from": "{{json.from}}"
    }

Step 6: Send SMS Reply via Twilio

  • Add a Twilio Send SMS Node

  • Use {{json.output}} as the message content

  • Responds to the original sender using your Twilio number

✅ You’re Live

Your SMS AI agent is now:

  • Receiving and responding to messages

  • Respecting the Chat Toggle from your Poku dashboard

  • Able to flag edge cases or complex conversations for human review

Need Help?

📬 Reach out at hello@pokulabs.com
📅 Schedule a setup call