Skip to main content

Build an AI-powered SMS support system with Twilio, GPT-4 and PostgreSQL

Workflow preview

Workflow preview
100%
Build an AI-powered SMS support system with Twilio, GPT-4 and PostgreSQL preview
Open on n8n.io

Important notice

This workflow is provided as-is. Please review and test before using in production.

1. Workflow Overview

How it works 1. User Signup & Verification: The workflow starts when a user signs up. It generates a verification code and sends it via SMS using Twilio. 2. Code Validation: The user replies with t...

Best for

  • Support Chatbot automation workflows
  • AI Chatbot automation workflows
  • advanced n8n builders looking for reusable templates

Tools used

n8n-nodes-base.stickynote, n8n-nodes-base.postgres, n8n-nodes-base.httprequest, n8n-nodes-base.switch, n8n-nodes-base.code, n8n-nodes-base.respondtowebhook, n8n-nodes-base.webhook, n8n-nodes-base.openai

Source and attribution

This workflow is cataloged by N8N Workflows and links back to its original n8n.io source page by John.

Original n8n.io source

1.1 Workflow description

Title
Build an AI-powered SMS support system with Twilio, GPT-4 and PostgreSQL
Workflow name
Build an AI-powered SMS support system with Twilio, GPT-4 and PostgreSQL

How it works

  1. User Signup & Verification:
    The workflow starts when a user signs up. It generates a verification code and sends it via SMS using Twilio.

  2. Code Validation:
    The user replies with the code. The workflow checks the code and, if valid, creates a session for the user.

  3. Conversational AI:
    Incoming SMS messages are analyzed by Chat GPT AI for sentiment, intent, and urgency. The workflow stores the conversation context and generates smart, AI-powered replies.

  4. Escalation Handling:
    If the AI detects urgency or frustration, the workflow escalates the session—alerting your team and sending a supportive SMS to the user.


Set up steps

  • Estimated setup time: 10–20 minutes for most users.

  • What you’ll need:

    • A free n8n account (self-hosted or cloud)
    • Free Twilio account (for SMS)
    • OpenAI API key (for AI)
    • A PostgreSQL database (Supabase, Neon, or local)
  • Setup process:

    1. Import this workflow into n8n.
    2. Add your Twilio and OpenAI credentials as environment variables or n8n credentials.
    3. Update webhook URLs in your Twilio console (for incoming SMS).
    4. (Optional) Adjust sticky notes in the workflow for detailed, step-by-step guidance.

1.2 Logical Blocks

This catalog entry is organized from the workflow JSON. The node-level section below shows the executable blocks available for review before importing the template.

2. Block-by-Block Analysis

Block 1 - Sticky Note

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 2 - Sticky Note1

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 3 - Sticky Note2

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 4 - Sticky Note3

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 5 - Store Verification

Type / Role
n8n-nodes-base.postgres - postgres
Config choices
Version 2

Block 6 - Send Verification SMS (Twilio API)

Type / Role
n8n-nodes-base.httpRequest - httpRequest
Config choices
Version 4

Block 7 - Check Verification

Type / Role
n8n-nodes-base.postgres - postgres
Config choices
Version 2

Block 8 - Validate Code

Type / Role
n8n-nodes-base.switch - switch
Config choices
Version 3

Block 9 - Create Session

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 10 - Mark Verified

Type / Role
n8n-nodes-base.postgres - postgres
Config choices
Version 2

Block 11 - Insert Session

Type / Role
n8n-nodes-base.postgres - postgres
Config choices
Version 2

Block 12 - Verify Success Response

Type / Role
n8n-nodes-base.respondToWebhook - respondToWebhook
Config choices
Version 1

Block 13 - Verify Failed Response

Type / Role
n8n-nodes-base.respondToWebhook - respondToWebhook
Config choices
Version 1

Block 14 - Incoming SMS Webhook (Twilio)

Type / Role
n8n-nodes-base.webhook - webhook
Config choices
Version 1

Block 15 - 🤖 AI Sentiment Analysis

Type / Role
n8n-nodes-base.openAi - openAi
Config choices
Version 1

Block 16 - Process AI Analysis

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 17 - 🤖 AI Escalation Router

Type / Role
n8n-nodes-base.switch - switch
Config choices
Version 3

Block 18 - Mark Session Escalated

Type / Role
n8n-nodes-base.postgres - postgres
Config choices
Version 2

Block 19 - Send Escalation Email

Type / Role
n8n-nodes-base.gmail - gmail
Config choices
Version 2

Block 20 - 🤖 AI Intent Router

Type / Role
n8n-nodes-base.switch - switch
Config choices
Version 3

Block 21 - 🤖 AI Intake Enrichment

Type / Role
n8n-nodes-base.openAi - openAi
Config choices
Version 1

Block 22 - Merge Enriched Data

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 23 - 🤖 AI Response Generator

Type / Role
n8n-nodes-base.openAi - openAi
Config choices
Version 1

Block 24 - Send AI Response SMS

Type / Role
n8n-nodes-base.httpRequest - httpRequest
Config choices
Version 4

Showing the first 24 of 49 workflow blocks. Download the JSON for the full node graph.

3. Summary Table

Workflow Build an AI-powered SMS support system with Twilio, GPT-4 and PostgreSQL
Complexity advanced
Nodes 49
Categories Support Chatbot, AI Chatbot
Author John
Published 03 Oct 2025

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/9220/9220.json as the source template for this automation.

  2. 2. Import the template into n8n

    Open n8n, import the downloaded JSON, and review each node before activating the workflow.

  3. 3. Configure credentials and variables

    Replace placeholder credentials, API keys, webhook URLs, account IDs, and environment-specific values with your own settings.

  4. 4. Test with sample data

    Run the workflow manually or in a staging workspace, inspect node output, and confirm downstream systems receive the expected data.

  5. 5. Activate and monitor

    Enable the workflow only after testing, then monitor executions, errors, and rate limits during the first production runs.

5. General Notes & Resources

Review imported nodes carefully before activation. This catalog entry is intended to help you inspect the workflow structure, understand required services, and find related templates faster.

Node names, credentials, schedules, webhook paths, and external service limits may need adjustment for your workspace.

Frequently asked questions

What does Build an AI-powered SMS support system with Twilio, GPT-4 and PostgreSQL do?

How it works 1. User Signup & Verification: The workflow starts when a user signs up. It generates a verification code and sends it via SMS using Twilio. 2. Code Validation: The user replies with t...

What do I need before importing this workflow?

Review the workflow JSON, configure any required credentials in n8n, and test the automation in a safe workspace before using it in production.

Can I customize this workflow?

Yes. Use the block-by-block analysis and the downloadable JSON to inspect each node, then adjust credentials, prompts, schedules, filters, or destinations for your Support Chatbot, AI Chatbot use case.