Go to file
copilot-swe-agent[bot] ff599df6c7 Fix voting logic to trigger exactly at threshold
Co-authored-by: kuhyx <147418882+kuhyx@users.noreply.github.com>
2025-12-01 15:19:13 +00:00
.github/workflows Create pylint.yml 2024-06-24 12:25:43 +02:00
.env.sample chore: added env sample file 2024-09-24 22:36:55 +02:00
.gitignore feat: added nohup to gitignore 2024-06-24 18:18:05 +01:00
LICENSE Initial commit 2024-06-23 19:36:33 +02:00
main.py Fix voting logic to trigger exactly at threshold 2025-12-01 15:19:13 +00:00
readme.md added sticker to the sample message 2024-10-05 10:53:23 +02:00
requirements.txt feat: made it uvicorn fast api compliant 2024-10-11 19:27:15 +02:00
run.sh feat: made it uvicorn fast api compliant 2024-10-11 19:27:15 +02:00
SECURITY.md Create SECURITY.md 2024-06-24 12:26:18 +02:00

Signal CLI REST API Integration Guide

This guide will help you set up and run a Signal bot using the Signal CLI REST API. For more details, refer to the signal cli rest api examples.

Message Formats

Message Sent from the Same Account as the Bot

{
    "envelope": {
        "source": "NAME",
        "sourceNumber": "PHONE_NUMBER",
        "sourceUuid": "SOURCE_ID",
        "sourceName": "USER_DEFINED_NAME",
        "sourceDevice": 69,
        "timestamp": 1719177728639,
        "syncMessage": {
            "sentMessage": {
                "destination": "DEST_NAME",
                "destinationNumber": "DEST_PHONE_NUMBER",
                "destinationUuid": "DEST_SEND_MESSAGE",
                "timestamp": 1719177728639,
                "message": "MESSAGE_CONTENT",
                "expiresInSeconds": 0,
                "viewOnce": false,
                'sticker': {
                    'packId': '166dd1b5b060200035a533bbb0d118ff',
                    'stickerId': 6
                },
            }
        }
    },
    "account": "BOT_ACCOUNT_PHONE_NUMBER"
}

Message Sent from Another Account

{
    "envelope": {
        "source": "NAME",
        "sourceNumber": "PHONE_NUMBER",
        "sourceUuid": "SOURCE_ID",
        "sourceName": "USER_DEFINED_NAME",
        "sourceDevice": 69,
        "timestamp": 1719177917717,
        "dataMessage": {
            "timestamp": 1719177917717,
            "message": "MESSAGE_CONTENT",
            "expiresInSeconds": 0,
            "viewOnce": false,
            'sticker': {
                'packId': '166dd1b5b060200035a533bbb0d118ff',
                'stickerId': 6
            },
            "groupInfo": {
                "groupId": "ID_OF_GROUP_SEND_TO",
                "type": "DELIVER"
            }
        }
    },
    "account": "BOT_ACCOUNT_PHONE_NUMBER"
}

Setting Up the WebSocket Server

The bot uses asyncio for running the WebSocket server and simple Python fetch requests/responses for sending and receiving data.

How to Run

  1. Follow the instructions on the Signal CLI REST API GitHub page.

    The main steps are summarized below:

    sudo docker run -d --name signal-api --restart=always -p 9922:8080 \
        -v /home/user/signal-api:/home/.local/share/signal-cli \
        -e 'MODE=json-rpc' bbernhard/signal-cli-rest-api:0.167-dev
    

    Pay attention to :0.167-dev! Try to upgrade if there is a new one as you can see errors connected with connecting your signal account otherwise Double check if you are using correct version using: http://localhost:9922/v1/about

  2. Access the Signal CLI setup page:

    http://localhost:9922/v1/qrcodelink?device_name=signal-api
    
  3. Scan the QR code to complete the Signal CLI setup.

Clone the Repository

git clone https://github.com/kuhyx/signal-bot

Initialize the Python Virtual Environment

python -m venv venv

Add Necessary API Information

Edit the venv/bin/activate file:

vim venv/bin/activate

Add the following lines at the end of the file:

export PHONE_NUMBER="+69YOURPHONENUMBER"
export CAT_API="CAN_LEAVE_BLANK"
export GROUP_ID="MESSAGES_SEND_HERE_WILL_TRIGGER_COMMANDS"
export GROUP_ID_SEND="TRIGGERED_COMMANDS_WILL_SEND_DATA_HERE"

And source the venv shell:

source venv/bin/activate

Install Required Python Packages

pip install -r requirements.txt

Run the Server

python main.py

Now your Signal bot should be up and running, ready to send and receive messages via the Signal CLI REST API.