mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-10-20 08:02:24 +00:00
* ci: drop dlltool from nodejs libs release * nodejs: download libsimplex into the user cache * nodejs: load libsimplex at runtime per backend * support bot: select db backend with --db * python: match backend switch error text * nodejs: download prebuilt add-on at runtime * ci: build nodejs add-on for libs release * calculator bot: load libs and add-on in image * support bot: document add-on override * nodejs: keep worker test output free of colors * nodejs: verify sha-256 of downloaded assets * python: pin core libs release with sha-256 * ci: add packages release script * ci: release nodejs add-on and open release PR * ci: publish packages after release PR * nodejs: keep npm from building the add-on * calculator bot: build the add-on in the image * ci: merge package release workflows * ci: open release PR when publishing fails * ci: build the add-on with node-addon-api only * ci: skip publishing in a called packages workflow * ci: update package release actions to Node 24 * nodejs: fix receive test timeout * ci: test packages on pull requests * nodejs: reuse the database in the close stress test * ci: keep failed package tests from hanging * ci: skip preset server tests * ci: plan package builds from the changes * ci: test packages with a given libsimplex * ci: test packages with libsimplex of core changes
90 lines
3.4 KiB
Markdown
90 lines
3.4 KiB
Markdown
# SimpleX Support Bot
|
|
|
|
A business-address bot that triages incoming support chats, optionally runs them through Grok, and routes handoffs to a team group.
|
|
|
|
## Prerequisites
|
|
|
|
- Node.js v18 or newer (v24 tested)
|
|
- `GROK_API_KEY` env var (xAI) — optional; the bot runs without it
|
|
- For the PostgreSQL backend: Linux x86_64, `libpq5` installed on the host, and a reachable PostgreSQL server
|
|
|
|
## Install & build
|
|
|
|
```bash
|
|
cd apps/simplex-support-bot
|
|
npm install
|
|
npm run build # tsc
|
|
```
|
|
|
|
The native library is downloaded on first start into the user cache. To download it ahead of time (for example in a Dockerfile), run as the user that runs the bot:
|
|
|
|
```sh
|
|
npx simplex-chat install --backend sqlite
|
|
npx simplex-chat install --backend postgres # Linux x86_64 only
|
|
```
|
|
|
|
Select the database with `--db sqlite` (default) or `--db postgres`.
|
|
|
|
## Run
|
|
|
|
```bash
|
|
mkdir -p data # state file lives here by default
|
|
|
|
# SQLite (default)
|
|
npm start -- --team-group "Support Team"
|
|
|
|
# PostgreSQL
|
|
npm start -- --team-group "Support Team" \
|
|
--db postgres --pg-conn "postgres://user:pass@host/db"
|
|
```
|
|
|
|
## Flags
|
|
|
|
Run `npm start -- --help` for the auto-generated reference. Summary:
|
|
|
|
| Flag | Backend | Required | Default | Description |
|
|
|---|---|---|---|---|
|
|
| `--team-group` | both | yes | — | team group display name |
|
|
| `--state-file` | both | no | `./data/state.json` | path to bot state JSON |
|
|
| `--db` | both | no | `sqlite` | `sqlite` or `postgres` |
|
|
| `--sqlite-file-prefix` | sqlite | no | `./data/simplex` | DB file prefix (creates `<prefix>_chat.db`, `<prefix>_agent.db`) |
|
|
| `--sqlite-key` | sqlite | no | (unencrypted) | SQLCipher encryption key |
|
|
| `--pg-conn` | postgres | yes | — | PostgreSQL connection string |
|
|
| `--pg-schema` | postgres | no | `simplex_v1` | schema prefix used for bot tables |
|
|
| `-a` / `--auto-add-team-members` | both | no | | comma-separated `ID:name` pairs (e.g. `1:Alice,2:Bob`) |
|
|
| `--timezone` | both | no | `UTC` | IANA zone for weekend detection |
|
|
| `--complete-hours` | both | no | `3` | auto-complete chats after N hours idle (`0` disables) |
|
|
| `--card-flush-seconds` | both | no | `300` | debounce card state writes |
|
|
| `--context-file` | both | required with `GROK_API_KEY` | | text file with Grok system context |
|
|
| `-h` / `--help` | both | no | | show usage and exit |
|
|
|
|
## Environment variables
|
|
|
|
| Var | Purpose |
|
|
|---|---|
|
|
| `GROK_API_KEY` | xAI API key; enables Grok replies |
|
|
| `SIMPLEX_LIBS_DIR` | directory with a local libsimplex build for the `--db` backend, instead of the downloaded one |
|
|
| `SIMPLEX_ADDON_PATH` | locally built Node.js add-on (`simplex.node`), instead of the downloaded one |
|
|
|
|
## Local development against unreleased lib changes
|
|
|
|
This package depends on `simplex-chat` from npm. To test against an in-tree version:
|
|
|
|
```bash
|
|
# In packages/simplex-chat-nodejs
|
|
npm install && npm run build
|
|
npm link
|
|
|
|
# In apps/simplex-support-bot
|
|
npm link simplex-chat
|
|
export SIMPLEX_ADDON_PATH=../../packages/simplex-chat-nodejs/build/Release/simplex.node
|
|
```
|
|
|
|
`npm unlink simplex-chat && npm install` reverts to the registry version.
|
|
|
|
## Troubleshooting
|
|
|
|
- **`--pg-conn is required with --db postgres`** — pass a connection string, or use `--db sqlite`.
|
|
- **`libpq5` errors at startup** — install `libpq5` on the host (`apt install libpq5` on Debian/Ubuntu).
|
|
- **`ENOENT: no such file or directory, open './data/state.json'`** — the parent directory of `--state-file` must exist; `mkdir -p data` before starting.
|