Background
SimpleX Chat, which is the first messenger without user IDs and privacy-focused, is also an open source project and you could self host the server as you like. But it's not many bot tutorials and deploy it simply. As a blog said, it has to use CLI to be gateway/bridge to communicate between SMP Server and your bot server.
Architecture

What I Expected
I want to put the CLI to the docker container so I could deploy it easily.
But I faced the issue that I need to input the username to create user profile when running the CLI at the first time, and there is no CLI option to set it. To make matters worse, some APIs like create group didn't work in typescript SDK.
What I did
So I forked the repo to fix the problems of CLI and SDK, and created a repo to show how to dockerize the CLI and build a bot server.
Dockerize CLI
I add --display-name option to the CLI so I could create user profile with non-interactive mode. I created a docker image named feimeizhan/simplex-chat-gateway which code is here.
Typescript SDK
I fixed the issue like create group error and no group list, and publish as @reply2future/simplex-chat which code is here
bot-center
I also created a bot example to show how to use typescript sdk.
How to Use simplex-chat-gateway
Requirements
dockeranddocker-compose- Linux system
Steps
- Run the comand
git clone https://github.com/reply2future/simplex-chat-gateway.gitto clone the repo and cd to the directory of repo. - Copy
.env.templateto.envin current directory, and change the environment variables as you need. - Run the command
docker compose up -d - You could see the
bot addressandgroupIdin the console of docker containerbot-centerlike below:
- You need to add the bot by paste the bot address to your simplex-chat client, and the bot accepts the friend request automatically, and you could see the
contact_idof your user profile. - Send a message like
/square-num 8which is pre-defined handler inbot-center, then the bot would reply8 * 8 = 64 - (Optional) add you to the pre-created group like
Notificationby calling the api ofbot-centerlikehttp://localhost:6794/invite/:contact_id, the more information you could see the code here, so you could send message to the group frombot-centerby using api likehttp://localhost:6794/notification/:group_id.
How to Create your handler in bot-center
I will show it how to add your handler to bot-center
Requirements
TypeScript
Steps
- Go to the
bot-centerdirectory - Create a handler in
./handlersdirectory, like./handlers/direct/echo.ts - Implement interface
IHandlerinecho.ts - Add
echo.tsto./handlers/index.ts, like['echo', new EchoHandler()] - Deploy your
bot-center - Test it by sending a direct message to bot like
/echo test
More SDKs
The official supported SDK is TypeScript, but you could create your SDK using your familiar programming language, because it uses websocket.
Why no windows/macOS
Because of the secure reason the SimpleX-Chat agent will bind 127.0.0.1 only, and network_mode: host is not supported in a meaningful way on macOS and Windows due to Docker's reliance on a VM architecture, so it doesn't work in macos and windows.