-
-
Notifications
You must be signed in to change notification settings - Fork 3
adding a /cherryhelp Slack bot #26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
CherryCIC
wants to merge
2
commits into
main
Choose a base branch
from
cherry/add-cherry-help-bot-clean
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| worker: npm start | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
| }; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Worker start path can fail without a prior build artifact.
On Line 1,
npm startassumesdist/src/app.jsalready exists. If the deploy step doesn’t runnpm run build, worker boot will fail.Safer Procfile command
📝 Committable suggestion
🤖 Prompt for AI Agents