automatic post LinkedIn

Hi @kapa.ai

I’m building a Chat workflow to draft/refine LinkedIn posts with persistent state in Google Sheets (session_id) and a RAG (OneDrive → Vector Store) for “Groupe NSA” tone/wording.

Goal / Flow

  1. First message (create)

When chat message received → Init Session (build session_id, read user_msg, compute ok_to_publish)

Sheets lookup (session_id) → Session Exists?

No session → AI Agent (draft) → Append row → Respond to Chat (send draft + “OK or edits”) → end of run

  1. Next messages (approve/edit)

New user reply should trigger a new run:

Init Session → Sheets lookup → Session Exists?

OK → LinkedIn Post

Else → AI Agent (rewrite) → Append/Update row → Respond to Chat → end of run

Loop continues message-by-message.

Actual issue

User must reply “OK / edit…”, but after Respond to Chat the workflow doesn’t return to the trigger. I want to keep one workflow, no Manual Trigger, and rely on the next user message to auto re-trigger via When chat message received, reload state, then branch to Publish? / Rewrite.

Symptoms: sometimes the next message behaves like a first message (session not found) or nothing chains forward. I previously tried a Merge after Respond to Chat (doesn’t emit—run already ended).

Current setup (short)

session_id from sessionId / chatId / x-n8n-session-id fallback

Lookup by session_id in sessions_linkedin

ok_to_publish is a boolean

Removed any internal loop after Respond to Chat

Ask / Best practices

Confirm: Chat = 1 message → 1 execution, Respond to Chat closes run; you must rely on the next message to re-trigger, right?

Session persistence: should I enforce stable x-n8n-session-id across the whole conversation? Tips to guarantee the same id each message?

“Session Exists?”: prefer {{$items(‘sessions_linkedin’).length > 0}} after lookup?

Any reference workflow for “Chat Trigger → Sheets state → Publish?/Rewrite branch”? Thanks! (modifié)