Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions bots/cherry-help/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
SLACK_BOT_TOKEN=
SLACK_APP_TOKEN=
GITHUB_TOKEN=
GITHUB_REPOS=
NOTION_TOKEN=
NOTION_PAGE_IDS=
BOT_MODE=retrieve_only
ALLOWED_CHANNEL_IDS=
VOLUNTEER_LEAD_LABEL=the volunteer lead
NODE_ENV=production
9 changes: 9 additions & 0 deletions bots/cherry-help/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
node_modules/
dist/
coverage/
data/
.env
.env.*
!.env.example
npm-debug.log*
!package-lock.json
1 change: 1 addition & 0 deletions bots/cherry-help/Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
worker: npm start

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Worker start path can fail without a prior build artifact.

On Line 1, npm start assumes dist/src/app.js already exists. If the deploy step doesn’t run npm run build, worker boot will fail.

Safer Procfile command
-worker: npm start
+worker: npm run build && npm start
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
worker: npm start
worker: npm run build && npm start
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@bots/cherry-help/Procfile` at line 1, The Procfile's worker entry currently
uses "worker: npm start" which assumes the build artifact exists
(dist/src/app.js); update the Procfile so the worker boot runs the build first
or invokes a start script that performs the build (e.g., run the build command
before starting or use a start:prod script that builds), ensuring the "worker:
npm start" invocation is replaced with a command that guarantees npm run build
(or equivalent) completes prior to launching the app so the dist artifacts
exist.

122 changes: 122 additions & 0 deletions bots/cherry-help/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
# cherry-help

`cherry-help` is an internal Slack bot for cherry volunteers. It answers simple questions from approved cherry docs only, cites the source, and refuses requests that involve secrets, personal data, admin bypasses or unsafe changes.

The bot is intentionally small. It is retrieval-only for the MVP, so it does not guess when the docs do not contain the answer.

## Slack setup

The Slack app should use Socket Mode. This lets the worker receive mentions and direct messages without a public HTTP endpoint.

Expected Slack app setup:

- App name: `cherry volunteer help`
- Slash command: `/cherryhelp`
- Socket Mode: enabled
- App-level token: `connections:write`
- Event subscriptions: `app_mention` and `message.im`
- Bot scopes: `app_mentions:read`, `chat:write`, `commands`, `im:history`, `im:read`, `im:write`

Reinstall the Slack app after changing scopes or event subscriptions.

## Environment variables

Set these in Railway variables for production. Use `.env` only for local development, and never commit it.

```env
SLACK_BOT_TOKEN=
SLACK_APP_TOKEN=
GITHUB_TOKEN=
GITHUB_REPOS=
NOTION_TOKEN=
NOTION_PAGE_IDS=
BOT_MODE=retrieve_only
ALLOWED_CHANNEL_IDS=
VOLUNTEER_LEAD_LABEL=the volunteer lead
NODE_ENV=production
```

`GITHUB_REPOS` accepts comma-separated values such as `owner/repo` or `owner/repo#main`.

`ALLOWED_CHANNEL_IDS` is optional. Leave it blank to answer in any channel where the bot is present. Set comma-separated Slack channel IDs to restrict replies.

## Approved sources

The bot indexes:

- `content/volunteer-faq.md`
- `README.md`
- `AGENTS.md`
- `CONTRIBUTING.md`
- `docs/**`
- `.devcontainer/**`
- Notion pages listed in `NOTION_PAGE_IDS`

It skips `.env` files, build output, dependencies and unrelated source files. Do not put secrets, donor data, customer data or private Slack content in approved docs.

Retrieval order is:

1. FAQ
2. GitHub or local docs
3. Notion pages

## Run locally

From this directory:

```sh
npm ci
cp .env.example .env
npm run build-index
npm run build
npm test
npm run dev
```

Fill `.env` with local test values before starting the bot. Do not use production tokens on a shared machine.

## Railway deployment

Railway should build from:

```text
bots/cherry-help
```

Recommended build command:

```sh
npm ci --include=dev && npm run build && npm run build-index
```

Start command:

```sh
npm start
```

The service can stay unexposed because Socket Mode does not need an inbound public URL.

## Slash command behaviour

`/cherryhelp <question>` replies ephemerally by default. Mentions reply in the same thread when possible. Direct messages reply in the DM.

When the bot cannot find a reliable approved source, it says:

```text
I do not know from the approved cherry docs yet. Please ask the volunteer lead, and we can add the answer to the volunteer FAQ afterwards.
```

## Improving the FAQ

Add volunteer-ready answers to `content/volunteer-faq.md`. Keep each answer short, factual and easy to check. Prefer plain language. Always spell cherry with a lowercase `c`.

After changing approved docs, rebuild the index:

```sh
npm run build-index
```

## Security notes

Never commit `.env`, Slack tokens, GitHub tokens, Notion tokens, donor data, customer data or private Slack messages. Rotate any secret that has been pasted into chat, screenshots, logs or docs.
23 changes: 23 additions & 0 deletions bots/cherry-help/content/volunteer-faq.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# cherry volunteer FAQ

This FAQ is the first approved source for `cherry-help`.

## What is cherry?

cherry is an open-source, charity-first resale platform. It turns pre-loved clothing into 100% donations for UK-registered charities.

Every penny raised goes to charity. Fees only cover platform security.

## How do I run the backend locally?

From the backend repo root, install dependencies, copy `.env.example` to `.env`, add the required local values, then run the local development command in the backend README.

Only use test keys and local development credentials. Never share real tokens or secrets in Slack.

## Where should volunteer guidance live?

Add clear, approved answers to this FAQ or to the main project docs. Keep answers short, factual and easy for another volunteer to check.

## What should I do if I cannot find an answer?

Ask the volunteer lead. Once the answer is confirmed, add it to the volunteer FAQ so the next person can find it quickly.
7 changes: 7 additions & 0 deletions bots/cherry-help/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/** @type {import('jest').Config} */
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
roots: ['<rootDir>/tests'],
clearMocks: true
};
Loading