From a7236050cf742ddbb82df181d6dbdcba776b8991 Mon Sep 17 00:00:00 2001 From: Miya Date: Fri, 11 Sep 2026 23:49:15 +0200 Subject: [PATCH] =?UTF-8?q?feat(examples):=20prospect=20demo=20flow=20?= =?UTF-8?q?=E2=80=94=20LLM=20to=20Slack=20to=20observer=20(#344)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/prospect-demo/README.md | 64 +++++++++++++++++++++++++++++ examples/prospect-demo/demo.flow.ts | 11 +++++ 2 files changed, 75 insertions(+) create mode 100644 examples/prospect-demo/README.md create mode 100644 examples/prospect-demo/demo.flow.ts diff --git a/examples/prospect-demo/README.md b/examples/prospect-demo/README.md new file mode 100644 index 000000000..21ec13af3 --- /dev/null +++ b/examples/prospect-demo/README.md @@ -0,0 +1,64 @@ +# Prospect demo + +Generate a short message with `f.llm`, post it to Slack's `#test` channel with +`f.slack.post`, and open the observer URL printed by `flows run`. + +You need Node.js 22.18+, an installed and authenticated Claude CLI, a relayfile +Slack mount connected to your workspace with permission to post in `#test`, +and a Relaycast workspace key for the observer link. Create `#test` and invite +the connected Slack bot before running the demo. + +Copy `demo.flow.ts` into a new directory, then run these commands there: + +```sh +npm init -y +npm pkg set type=module +npm install relayflows @relayflows/surface +cat > flows.json <<'JSON' +{ "cli": "claude" } +JSON +``` + +To use an authenticated Codex CLI instead, change `"claude"` to `"codex"` in +`flows.json`. The LLM step uses that CLI's configured model and credentials. + +Point to your existing relayfile mount and configure the observer workspace: + +```sh +export RELAYFILE_MOUNT_PATH='/absolute/path/to/your/relayfile-mount' +export RELAYCAST_WORKSPACE_KEY='rk_live_REPLACE_WITH_YOUR_WORKSPACE_KEY' +``` + +The mount must contain a working `slack/` integration that confirms delivery. +Setting `SLACK_BOT_TOKEN` alone is not enough: the current Slack helper requires +relayfile writeback. See the [Slack helper documentation](../../docs/SLACK-HELPER.md). +If `agent-relay` already has an active workspace saved locally, you can omit +`RELAYCAST_WORKSPACE_KEY`; the CLI uses that workspace automatically. + +Check the flow and run it: + +```sh +npx flows check demo.flow.ts +npx flows run demo.flow.ts --local-agent --input '{}' +``` + +With `flows` on your PATH, the equivalent command is +`flows run demo.flow.ts --local-agent --input '{}'`. The local worker runs the +LLM call; the Slack helper waits for a delivery receipt before completing. +Each new run posts a new message to `#test`. + +On success, look for the generated message in Slack and a terminal line like: + +```text +Observer: https://agentrelay.com/observer?key=ot_live_... +``` + +Open that URL to view the configured Relaycast workspace. The CLI mints the +observer token and prints the link; the flow needs no separate observer call. +If the line is missing, check the workspace key, unset `FLOWS_NO_OBSERVER`, and +look for an `[observer]` diagnostic. `flows observer` can mint a link separately. +The link uses a scoped observer token, not the workspace key. + +For a local preview without sending a Slack message, prefix the run command +with `RELAYFLOWS_SLACK_MOCK=1`. The LLM call still runs, but Slack delivery is +replaced by a local receipt; this does not demonstrate live Slack delivery. diff --git a/examples/prospect-demo/demo.flow.ts b/examples/prospect-demo/demo.flow.ts new file mode 100644 index 000000000..5773c9c15 --- /dev/null +++ b/examples/prospect-demo/demo.flow.ts @@ -0,0 +1,11 @@ +import { flow } from '@relayflows/surface'; + +export default flow('prospect-demo', async (f) => { + const message = await f.llm`Write one short, friendly Slack message introducing + Relayflows: a flow can generate a message with an LLM and post it to Slack. + Return only the message text. Do not use tools or mention anyone.`; + + await f.slack.post('#test', message); + f.done('success'); + // `flows run` prints the observer URL after the run summary when configured. +});