Skip to main content

monitor signal chat groups and post a message when people join

Project description

Welcome Bot

A bot that monitors signal chat groups and posts a message when people join

Getting Started

Note: this is a work in progress. These setup instructions are very rough and will be evolving rapidly.

Create a local volume to hold the state of the signal-api and the welcomebot. This volume will be replaced by an encrypted volume in the cloud:

docker volume create welcomebot_state

Also create a bridge nwork that you will need later:

docker network create --driver bridge signal

Register your account with signal-api, but link the volume in a little higher in the filesystem so we can use the volume for other state sotrage as well:

docker run --detach --name signal-api -p 8080:8080 \
      --volume welcomebot_state:/home/.local \
      --network signal \
      -e 'MODE=json-rpc' bbernhard/signal-cli-rest-api

Open the registration QR code at http://localhost:8080/v1/qrcodelink?device_name=welcome-bot And scan it with the "link account" flow from the phone with the bot account.

Note that the bot will have access to all the contacts and chats of the account you link it to. You should not use your personal Signal account for this. You should get a separate phone number, create a Signal account with that number, and then use that account only for the bot.

Replace 12125551212 with the bot's phone number and execute these commands.

curl http://localhost:8080/v1/groups/+12125551212
curl http://localhost:8080/v1/contacts/+112125551212

If you are using a fresh Signal account (you are, right?), then they should both return an empty result: [].

Send the bot account a message from the account you want it to trust as the management account. Accept that message as the bot using the phone. Then invite it to a group chat with a title you will remember, like "Welcomebot Control Room".

Rerun those curl commands above and look for the new (only!) responses.

The value WELCOME_MANAGER will be the uuid of your entry in the response to the contacts query. The value of WELCOME_CNC will be the internal_id in the response to the groups query.

Now create .env with:

SIGNAL_SERVICE=localhost:8080
PHONE_NUMBER=...
WELCOME_MANAGER=...
WELCOME_CNC=...

Then test locally with:

uv sync
uv run pytest
uv run python -m welcomebot

If you send the message "help" to the bot in the CNC channel, it should reply with a help message.

containerized!

Now you should be able to copy your local state to a volume and run the bot in it's own container:

# copy state into the volume
docker build -f copypaste.dockerfile -t copypaste .
docker run -it -v ~/.local/share:/home/a -v wecomebot_state:/home/b copypaste

# run the bot
docker build -f docker/welcomebot.dockerfile \
      --build-arg WELCOMEBOT_VERSION=0.1.8 \
      -t welcomebot:v0.1.8 .
docker run -d --name welcomebot --rm \
     -v welcomebot_state:/home/.local \
     --env-file .env \
     --network container:signal-api \
     welcomebot:v0.1.8

compose

Stop the other containers and use compose.yaml config to bring the services up together:

docker compose up

controlling the bot

  • send help to the bot in the CNC chat
  • invite the bot to a group you want to manage
  • send list_groups to the bot in the CNC chat
  • set the welcome mesage for the group:
set_motd 0
hello and welcome to the chat.
please adhere to group guidlines at
https://codeforamerica.org/code-of-conduct/

Release Process

uv run pytest
uv version --bump patch
tag=v$(uv version --short)
git commit -S -a -m "publishing $tag"
git tag -m "publishing $tag" $tag
git push --tags

Primary Dependancies

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

welcomebot-0.2.0.tar.gz (9.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

welcomebot-0.2.0-py3-none-any.whl (9.2 kB view details)

Uploaded Python 3

File details

Details for the file welcomebot-0.2.0.tar.gz.

File metadata

  • Download URL: welcomebot-0.2.0.tar.gz
  • Upload date:
  • Size: 9.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.8 {"installer":{"name":"uv","version":"0.11.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for welcomebot-0.2.0.tar.gz
Algorithm Hash digest
SHA256 e0d5df01ad3947506eec56a119b193c2a5ca08051c61006793890b2ba5c84c4b
MD5 b6b65eb5011a2a318a66a1f61a29cb8a
BLAKE2b-256 6ed1ca330739f4e036e34ffd61a27c3d0ce2c0b2c77f71b8b7a6b9a4f3ab9417

See more details on using hashes here.

File details

Details for the file welcomebot-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: welcomebot-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 9.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.8 {"installer":{"name":"uv","version":"0.11.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for welcomebot-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1b4d2effe192de655eb915e324800fec982348b0e79ce6c57bf46b320a77740f
MD5 e8fe593d06ed4657ecdd6163415dbb60
BLAKE2b-256 08f0ad4744826ae6e880ded98bc42972c7d5e01d0913849d958f1e9514d8272d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page