@qemuguest/site-chat-simplex-bridge
v0.1.0
Published
Relay your website chat into SimpleX: each customer becomes their own SimpleX chat, and your replies go back to their website chat live. Pairs with @qemuguest/site-chat-server.
Downloads
203
Maintainers
Readme
@qemuguest/site-chat-simplex-bridge
Relay your website chat into SimpleX: each customer becomes their own SimpleX chat,
and whatever you type there goes back to their chat window on your site, live. Works with
@qemuguest/site-chat-server and
@qemuguest/site-chat-widget.
website ──► site-chat-server (simplexRelay) ◄── polls ── this bridge ── SimpleX ──► "Web · Sam" chat ──► you
── reply ─► ◄── you typeThe SimpleX core is a native library, so it can't run in a Worker or serverless function. This runs on any always-on machine (your Mac, a small VPS) and only makes outbound HTTPS requests to your site, so no port or tunnel is needed.
Run
npx @qemuguest/site-chat-simplex-bridge \
--url https://example.com/api/site-chat \
--secret-file ./secret # same value as simplexRelay({ secret }) on the serverThe first run installs the SimpleX SDK into ~/.cache/site-chat-simplex-bridge and builds its native addon,
which needs a C++ toolchain (Xcode Command Line Tools on macOS, build-essential on Linux, VS Build Tools on
Windows). It then prints the bridge's address. Connect to it once from your SimpleX app. The first contact to
connect becomes the only one that can read and answer.
From then on:
- each new website conversation is a new group named after the customer ("Web · Sam · Ace Roofing"; renamed when they give their details), with you invited as admin;
- their messages, contact details, contact-form submissions, and replies you send from other channels (admin, Telegram) all appear there;
- anything you type in the group is delivered to their website chat within a few seconds.
In the official SimpleX apps each new customer arrives as a group invitation you tap to join. Clients built on the SDK can join automatically:
const { autoJoinBridgeChats } = require("@qemuguest/site-chat-simplex-bridge");
autoJoinBridgeChats(chatApi, { name: "Website chat", pinFile: "./data/autojoin-contact" });Options
| Flag | Env | Default |
| --- | --- | --- |
| --url | SITE_CHAT_URL | (required) where site-chat-server is mounted |
| --secret / --secret-file | SITE_CHAT_SECRET | (required) 32+ characters |
| --data | SITE_CHAT_DATA | ./site-chat-bridge-data (bridge database + state; back it up) |
| --name | SITE_CHAT_NAME | Website chat |
| --prefix | | Web |
| --cache | | ~/.cache/site-chat-simplex-bridge |
Programmatic: const { runBridge } = require("@qemuguest/site-chat-simplex-bridge"); const b = await runBridge({ url, secret }); await b.stop();
Keep it running with launchd, systemd or pm2; it shuts down cleanly on SIGTERM.
AGPL-3.0, because it uses the SimpleX chat SDK, which is AGPL-3.0.
