# Run a flow from an AI··Room

import { Steps } from "@astrojs/starlight/components"

A **Chathook** trigger starts a flow when someone mentions that flow in an **AI··Room** in the same environment. The room
message, conversation id, and sender details become data you can use in later steps. On **AI··Task** steps under a
Chathook, you can turn on **Reply in chat** to stream the model output back into the room. Screenshots on this page use
a sample IP look-up job so you can see filled names and settings.

## When to use

- Analysts or operators should start a flow from a conversation instead of opening the designer or calling a webhook
  URL.
- You want the chat message (and optional conversation memory) available to an **AI··Task** or other steps.
- Prefer [Run flow through webhook](../run-flow-through-webhook/) when an **external** system must start the flow over
  HTTPS.
- Prefer [Call a flow](../../control-flow-execution/call-a-flow/) when one Mindflow flow should start another without leaving Studio.

Before you begin, you need permission to create and deploy flows in the environment, and access to **Rooms** in that
environment. Create or open a room in the same environment where you will deploy the flow.

## Guide

### Add a Chathook trigger

A **Chathook** is the trigger that makes a flow callable from an AI··Room. After you add it and deploy the flow, anyone
with room access in that environment can mention the flow by name.

<ol>
<li>

**Create or open the flow.** Name it for the job it performs, then open it in the designer.

</li>
<li>

**Add Chathook.** Open **Add a step**, choose **Triggers**, then **Chathook**. Rename the step and fill a
description.

</li>
<li>

**Open Settings.** On the Chathook step, open the **Settings** tab. Studio shows how to mention the flow in a room
(`@` plus the flow name) and which variables the trigger exposes.
<div class="docs-screenshot-compact">

![Analyze suspicious IP designer: Chathook step Receive room request Settings callout with @Analyze suspicious IP mention example and Reply in chat guidance](./assets/chathook-settings.png)

</div>

</li>
</ol>
### Use Chathook data in later steps

When the room message runs the flow, Chathook provides the text after the mention as **message**, the room conversation
id as **conversationId**, and sender details. Later steps pick those values from the data picker.

<ol>
<li>

**Add the next step.** Add the step that should use the room text (for example **AI··Task** or **Transform data**).

</li>
<li>

**Pick from Chathook.** In a formula field, open the data picker, choose the Chathook step, then select **message**
(or **conversationId** when you need the room conversation id).
<div class="docs-screenshot-compact">

![Assess IP risk AI··Task prompt with Chathook message data pill selected from Receive room request](./assets/chathook-message-in-prompt.png)

</div>

</li>
</ol>
### Configure AI··Task for chat replies

When the flow includes a Chathook, each **AI··Task** shows a **Conversation** section. **Reply in chat** streams that
step’s output into the room that started the run. **Previous Step Memory** after a Chathook uses the room’s
conversation memory so follow-up mentions keep context.

<ol>
<li>

**Add AI··Task.** After the Chathook, open **Add a step** and choose **AI··Task**. Rename the step and fill a
description.

</li>
<li>

**Write the prompt.** On **Input**, write the user prompt and insert the Chathook **message** (and any other fields
you need) from the data picker.

</li>
<li>

**Open Settings.** On the AI··Task step, open the **Settings** tab.

</li>
<li>

**Set Memory.** Under **Memory**, choose **Previous Step Memory** when the model should reuse the room conversation.
Leave **None** when each mention should be stateless.

</li>
<li>

**Turn on Reply in chat.** Under **Conversation**, leave **Reply in chat** on (the default under a Chathook) so the
step streams into the room. Turn it off only when the step must not post back to chat.
<div class="docs-screenshot-compact">

![Assess IP risk Settings with Memory set to Previous Step Memory and Conversation Reply in chat enabled](./assets/ai-task-reply-in-chat.png)

</div>

</li>
</ol>
### Deploy and mention the flow in an AI··Room

The flow is callable from rooms only after it is deployed in that environment. Mention uses the **flow name**, not the
Chathook step name.

<ol>
<li>

**Deploy the flow.** Deploy it to the environment that owns the room. See
[Manage version and deployments](../../../operate/manage-version-and-deployments/).

</li>
<li>

**Open Rooms.** In Studio, open **Rooms** and select (or create) a room in that environment.

</li>
<li>

**Mention the flow.** In the composer, type `@`, choose the flow, then add the rest of the message. Everything after
the mention becomes the Chathook **message**.
<div class="docs-screenshot-compact">

![AI··Room composer with @Analyze suspicious IP mention and Get a security report for IP 23.45.67.89](./assets/mention-flow-in-room.png)

</div>

</li>
<li>

**Send the message.** Studio starts the deployed flow. With **Reply in chat** on, the AI··Task output streams into
the same room.

</li>
</ol>
## Example

A SOC analyst wants a quick IP check without leaving chat. The flow **Analyze suspicious IP** starts with Chathook
**Receive room request** (“Starts when someone mentions this flow in an AI··Room”). An **AI··Task** named **Assess IP
risk** uses the Chathook **message** in its prompt, **Previous Step Memory**, and **Reply in chat**.

In an AI··Room in the same environment, the analyst sends:

`@Analyze suspicious IP Get a security report for IP 23.45.67.89`

The flow runs with **message** set to `Get a security report for IP 23.45.67.89`. The AI··Task streams its
assessment back into the room. A follow-up mention in the same room can reuse conversation memory when **Previous Step
Memory** stays on.

## Keep in mind

- The flow must be **deployed** in the room’s environment before `@` can start it.
- Mention the **flow name**. Renaming the Chathook step does not change the mention.
- Text after the mention is the Chathook **message**. The mention token itself is not part of that value.
- **Reply in chat** appears on AI··Task only when the flow has a Chathook. Without it, the step cannot stream to the
  room.
- Prefer [AI··Rooms](../../../operate/ai-rooms-turning-prompts-into-powerful-actions/) for general room usage; this page covers
  starting a **flow** from chat.

## Related

[Trigger your flow](../) ·
[Run flow through webhook](../run-flow-through-webhook/) ·
[AI··Rooms](../../../operate/ai-rooms-turning-prompts-into-powerful-actions/) ·
[Manage version and deployments](../../../operate/manage-version-and-deployments/)
