Skip to content

Chatbot integration

Drupal AI's chatbot hands every message to a Chat Processor plugin. This module provides one, FlowDrop Workflow, that runs a FlowDrop workflow for each message and returns the workflow's output as the reply.

Set it up

  1. Build a workflow that takes a chat message and produces a reply. It starts with FlowDrop's Chat Input node and ends with a node that writes the reply.
  2. Enable the AI Chatbot module (ai_chatbot, part of Drupal AI).
  3. At /admin/structure/block, place the AI Chatbot block.
  4. In the block settings, select the FlowDrop Workflow chat processor.
  5. Pick the workflow, and decide on Remember conversation.
Setting Default Effect
FlowDrop Workflow none The workflow to run. Required.
Remember conversation on On: one FlowDrop session per chat thread, so the workflow sees earlier messages. Off: every message starts a new session. Use off for one-shot workflows.

What happens per message

sequenceDiagram
    participant U as Chatbot
    participant P as FlowDrop Workflow processor
    participant S as FlowDrop session
    participant W as Workflow
    U->>P: user message
    alt pending interrupt on the session
        P->>S: resolve the interrupt with the message
        S->>W: resume the paused run
    else
        P->>S: reuse the thread's session, or open a new one
        P->>W: run a chat turn
    end
    W-->>S: reply, or a new interrupt question
    P-->>U: reply or question

Human in the loop

When a workflow pauses on a FlowDrop interrupt, the chatbot shows the interrupt's question. The user's next message answers it, and the workflow resumes where it stopped. A pending interrupt is always resumed on its own session, even with Remember conversation off.

Session History node

To give a Chat node the earlier conversation, load it with Session History and wire it into Chat's history port.

Input Type Default Notes
session_id integer Wire from Chat Input's sessionId.
message_id integer Wire from Chat Input's messageId. This message and later ones are left out.
history_context_length integer 4 How many user and assistant pairs to return, counting back from the newest.
Output Type Notes
history array Messages, oldest first, in the shape Chat's history input takes.
count integer Number of messages returned.
flowchart LR
    CI[Chat Input] -- sessionId, messageId --> SH[Session History]
    CI -- message --> C[Chat]
    SH -- history --> C
    C -- response --> CO[Chat Output]