#n8n chat with external response

7 messages · Page 1 of 1 (latest)

unkempt bane
#

I am working on a particular use case (owing to security constraints) wherein I am using n8n to orchestrate the web chat, however the chat responses are not generated by n8n AI module, infact there is no AI module in the entire chatflow.

here is how the simplified workflow looks: webchat ↔ n8n ↔ external AI ↔ n8n ↔ webchat

the way I am achieving this is using Wait node and resumeUrl: webchat ↔ n8n ↔ wait (resume on webhook) ↔ external AI ↔ webhook ↔ n8n ↔ webchat.
But I am facing a problem, the resumeUrl is a single response endpoint and at times the the external AI has to send multiple responses. the number of response payload that the external AI will generate is not known, hence only one wait is added and we end up loosing trailing messages

I tried replacing the wait with a webhook passing and receiving sessionId back, this method does not all send to chat to work

Does anyone know how to solve this use case, really appreciate any guidance

unkempt bane
#

<@&1164861653565837374>

oblique ruin
#

@unkempt bane you are facing issue because

Wait + resumeUrl is designed for exactly one callback to continue the workflow.
Multiple calls after the first are ignored, so trailing AI messages vanish.

Create a dedicated inbound webhook for each chat session, and let the external AI call it as many times as needed.

Start node:

  • When the user opens a chat, generate a unique sessionId (e.g. UUID).
  • Store that in n8n (Redis, DB, or n8n’s built-in workflow data store).

Webhook node (persistent):

  • A single webhook endpoint like /chat/:sessionId.
  • External AI POSTs to this endpoint for every message it produces.
  • The workflow is triggered each time, looks up the session state, and pushes the message to the web chat.
unkempt bane
oblique ruin
#

Yes

Use a plain HTTP Request node

If your webchat exposes a REST endpoint such as

POST https://your-chat-server.example/api/message
body: { sessionId, text }

you can call it directly with an HTTP Request node.

  • This works from any branch of the workflow, including those started by a Webhook, because it’s just an outbound HTTP call.
kind wing
#

check your message

unkempt bane