# Build an AI-powered SMS support system with Twilio and OpenAI: n8n workflow

> Started by another system calling it, and works across Gmail, Postgres and S3. It hands the judgement calls to OpenAI.

Source: https://millionrounds.com/workflow/build-an-ai-powered-sms-support-system-with-twilio-and-opena (Millionrounds; every figure on the page links to its filing or article)

[Automation library](https://millionrounds.com/workflows) · [Customer support](https://millionrounds.com/workflows?category=Customer+support#library)

# Build an AI-powered SMS support system with Twilio and OpenAI

Started by another system calling it, and works across Gmail, Postgres and S3. It hands the judgement calls to OpenAI. 40 steps, 3 branches: large, and worth reading before you trust it with anything live.

Large Calls a model: OpenAI

[Download free](https://millionrounds.com/login?next=%2Fapp%2Fworkflow%2Fbuild-an-ai-powered-sms-support-system-with-twilio-and-opena)

**40 steps** Large: read it before trusting it with anything live

**3** Branches: places the flow splits

**0** Loops or waits

**3** Services it connects to

## The flow

Starts it 8 Model 5 Logic 11 Service 16

The steps in the order they run, from what starts it.

- 1 **Incoming SMS Webhook (Twilio)** Webhook *Starts it*
- 2 **Follow-Up Cron (24h)** Cron *Starts it*
- 3 **User Signup Webhook1** Webhook *Starts it*
- 4 **Verify Code Webhook1** Webhook *Starts it*
- 5 **Extract SMS Data1** Code *Logic*
- 6 **Find Inactive Sessions** Postgres *Service*
- 7 **Generate Verification Code1** Code *Logic*
- 8 **Extract Verification Data1** Code *Logic*
- 9 **Find User Session1** Postgres *Service*
- 10 **🤖 AI Personalized Reminder** Open Ai *Model*
- 11 **Store Verification** Postgres *Service*
- 12 **Check Verification** Postgres *Service*
- 13 **🤖 AI Sentiment Analysis** Open Ai *Model*
- 14 **Send Reminder SMS** Http Request *Service*
- 15 **Send Verification SMS (Twilio API)** Http Request *Service*
- 16 **Validate Code** Switch *Logic*
- 17 **Process AI Analysis** Code *Logic*
- 18 **Signup Response1** Respond To Webhook *Starts it*
- 19 **Create Session** Code *Logic*
- 20 **Verify Failed Response** Respond To Webhook *Starts it*
- 21 **🤖 AI Escalation Router** Switch *Logic*
- 22 **Mark Verified** Postgres *Service*
- 23 **Insert Session** Postgres *Service*
- 24 **Prepare Escalation Data1** Code *Logic*
- 25 **🤖 AI Intent Router** Switch *Logic*
- 26 **Verify Success Response** Respond To Webhook *Starts it*
- 27 **Mark Session Escalated** Postgres *Service*
- 28 **🤖 AI Intake Enrichment** Open Ai *Model*
- 29 **Prepare Closeout** Code *Logic*
- 30 **Send Escalation Email** Gmail *Service*
- 31 **Merge Enriched Data** Code *Logic*
- 32 **Finalize Session** Postgres *Service*
- 33 **Upload to S3** Aws S3 *Service*
- 34 **Send Escalation SMS1** Http Request *Service*
- 35 **Save Enriched Intake1** Postgres *Service*
- 36 **🤖 AI Personalized Closeout** Open Ai *Model*
- 37 **SMS Webhook Response** Respond To Webhook *Starts it*
- 38 **🤖 AI Response Generator** Open Ai *Model*
- 39 **Send Closeout SMS** Http Request *Service*
- 40 **Send AI Response SMS** Http Request *Service*

## How it's built

- **Starts on:** Another system calling it
- **Steps:** 40, with 3 branches
- **Size:** Large: read it before trusting it with anything live
- **Connects to:** Gmail, Postgres, S3
- **Model:** OpenAI

## Questions

What does it need to run?

An n8n account, plus your own Gmail, Postgres and S3 accounts, and a key for OpenAI. You connect your own accounts after importing it; none are included.

What starts it?

It starts on another system calling it.

Does it use AI?

Yes. It calls OpenAI. Model calls are billed by the provider, not by n8n.

How long does it take to set up?

Take your time. At 40 steps it is large: read it before trusting it with anything live.

How do I import it?

Copy the workflow, open a new workflow in n8n and paste. The steps appear on the canvas, ready for your own accounts.

**Before you run it**

Nothing here has been tested by us. It is somebody's working automation, read and described from its own steps. Treat the connections it wants as a list of accounts it will touch, and read the 40 steps before you point it at anything that matters.

## Run it in n8n

- **Create your n8n account** Free to start. n8n is where the workflow runs. [Create an n8n account ↗](https://millionrounds.com/n8n)
- **Download the workflow** Free with a Millionrounds account. [Download free](https://millionrounds.com/login?next=%2Fapp%2Fworkflow%2Fbuild-an-ai-powered-sms-support-system-with-twilio-and-opena)
- **Paste it into n8n** Open a new workflow in n8n and paste. Then connect your own accounts.

Stored with the author's traces removed: canvas notes, instance identifiers, saved credential names and any live document they had left behind.

## Connects to

Each opens the other workflows that use it.

[Gmail](https://millionrounds.com/workflows?service=Gmail#library)[Postgres](https://millionrounds.com/workflows?service=Postgres#library)[S3](https://millionrounds.com/workflows?service=S3#library)

## Workflows like it

Also customer support, with the same services where possible, closest in size first.

- [**AI-powered WhatsApp customer service with OpenAI and Gmail** 37 steps · calls a model · Gmail, Google Sheets](https://millionrounds.com/workflow/ai-powered-whatsapp-customer-service-with-openai-and-gmail)
- [**Route WhatsApp support requests with Claude and Supabase** 37 steps · calls a model · Gmail, Google Calendar](https://millionrounds.com/workflow/route-whatsapp-support-requests-with-claude-and-supabase)
- [**WhatsApp AI customer service chatbot – handles text, voice** 37 steps · calls a model · Google Drive, Postgres](https://millionrounds.com/workflow/whatsapp-ai-customer-service-chatbot-handles-text-voice)
- [**WhatsApp personal AI assistant with PDF** 35 steps · calls a model · Airtable, Gmail](https://millionrounds.com/workflow/whatsapp-personal-ai-assistant-with-pdf)
- [**Multi-department support bot with Pinecone and Telegram** 46 steps · calls a model · Google Drive, Pinecone](https://millionrounds.com/workflow/multi-department-support-bot-with-pinecone-and-telegram)
- [**Escalate overdue and blocked Jira tickets with Gmail** 33 steps · Gmail, Jira](https://millionrounds.com/workflow/escalate-overdue-and-blocked-jira-tickets-with-gmail)
