push redis and receive twilio events and get redis
Configured with Agent, OpenAI Chat Model, Memory Buffer Window, Memory Manager, and additional nodes. Review the connections and setup before adapting this template.
Node categories in this workflow
- AI & models
- Routing
- Data store
- Trigger
- Messaging
- Wait
- Transform
Icons describe general node roles, inferred from node types. Inspect the parameters for the configured action.
Drag to pan; use + and − to zoom. Reconstructed from the exported node positions; nothing runs here. Dashed lines represent non-main connections. Full node names and notes appear below.
How it works
The exported workflow contains the following configured nodes. Their connections are shown above; inspect the JSON for the complete logic, expressions, and external actions.
| Node | Category | Type | Operation |
|---|---|---|---|
| OpenAI Chat Model | AI & models | OpenAI Chat Model | See node parameters |
| No Operation, do nothing | Routing | No Op | See node parameters |
| Add to Messages Stack | Data store | Redis | push |
| Should Continue? | Routing | If | See node parameters |
| Window Buffer Memory | Data store | Memory Buffer Window | See node parameters |
| Twilio Trigger | Trigger | Twilio Trigger | See node parameters |
| Get Latest Message Stack | Data store | Redis | get |
| Send Reply | Messaging | Twilio | See node parameters |
| Wait 5 seconds | Wait | Wait | See node parameters |
| Get Chat History | Data store | Memory Manager | See node parameters |
| Window Buffer Memory1 | Data store | Memory Buffer Window | See node parameters |
| Get Messages Buffer | Transform | Edit Fields | See node parameters |
| AI Agent | AI & models | Agent | See node parameters |
Setup
- Download the JSON and import it into an isolated n8n instance. Leave the workflow inactive.
- Connect your own credentials through n8n’s credential store. Replace
REPLACE_WITH_*values with your resource identifiers. - Inspect API destinations, Code nodes, database queries, file paths, and outbound actions.
- Run with synthetic data and harmless destinations. Enable triggers only after checking the actual outputs.
Requirements
An n8n instance with the listed node types and compatible versions. Service-connected workflows may require accounts, credentials, or paid APIs.
Credential types declared in the source
openAiApiredistwilioApi
Workflow notes
Step 2. Buffer Incoming Messages
Step 2. Buffer Incoming Messages
- New messages are captured into a list.
- After X seconds, we get a fresh copy of this list
- If the last message on the list is the same as the incoming message, then we know no new follow-on messages were sent within the last 5 seconds. Hence the user should be waiting and it is safe to reply.
- But if the reverse is true, then we will abort the execution here.
Step 1. Listen for Twilio Messages
Step 1. Listen for Twilio Messages
Read more about Twilio Trigger
In this example, we'll use the sender's phone number as the session ID. This will be important in retrieving chat history.
Step 3. Get Messages Since Last Reply
Step 3. Get Messages Since Last Reply
Read more about using Chat Memory
Once conditions are met and we allow the agent to reply, we'll need to find the bot's last reply and work out the buffer of user messages since then. We can do this by looking using chat memory and comparing this to the latest message in our redis messages stack.
Step 4. Send Single Agent Reply For Many Messages
Step 4. Send Single Agent Reply For Many Messages
Learn more about using AI Agents
Finally, our buffered messages are sent to the AI Agent that can formulate a single response for all. This could potentially improve the conversation experience if the chat interaction is naturally more rapid and spontaneous. A drawback however is that responses could be feel much slower - tweak the wait threshold to suit your needs!
Try It Out!
Try It Out!
This workflow demonstrates a simple approach to stagger an AI Agent's reply if users often send in a sequence of partial messages and in short bursts.
- Twilio webhook receives user's messages which are recorded in a message stack powered by Redis.
- The execution is immediately paused for 5 seconds and then another check is done against the message stack for the latest message.
- The purpose of this check lets use know if the user is sending more messages or if they are waiting for a reply.
- The execution is aborted if the latest message on the stack differs from the incoming message and continues if they are the same.
- For the latter, the agent receives buffered messages and is able to respond to all in a single reply.
push redis and receive twilio events and get redis
push redis and receive twilio events and get redis
Purpose and structure
This folder contains the push redis and receive twilio events and get redis workflow. Its executable nodes use agent, if, lmChatOpenAi, memoryBufferWindow, memoryManager, noOp, redis, set, twilio, twilioTrigger, wait. The table and connection map below are derived from the JSON, not an inferred guarantee of behavior.
Setup
Import inactive. Configure your own credentials and replace REPLACE_WITH_* values. Review external destinations and Code nodes before running.
Entry points
Twilio Trigger
Verification
Sanitized source candidate; not runtime-tested. This overview is generated from node metadata. Read the folder README for the connection map, credential types, and license.
Attribution
https://github.com/Zie619/n8n-workflows/blob/94007c1445d9258a7da116646b79473e7c7c3282/workflows/Wait/0542_Wait_Redis_Create_Triggered.json MIT; preserve source notices.