WhatsGramBot is a Python bot primarily designed for managing a bot on WhatsApp. It utilizes a Telegram group to organize WhatsApp Chats according to topics, enhancing the management of WhatsApp conversations.
-
User-Based Messaging Organization:
- Each WhatsApp user is assigned a dedicated topic within a Telegram group.
- Messages from WhatsApp users are forwarded to their respective topics within the Telegram group.
- Telegram group administrators can respond to messages from WhatsApp within the Telegram group, facilitating collaborative communication.
-
Settings Configuration (/settings command):
- Enable or disable welcome messages and customize their content.
- Toggle automatic topic creation when a user opens a chat with the bot on WhatsApp. When enabled, a welcome message and topic creation occur immediately upon chat opening, even if the user hasn't sent a message yet.
- Toggle mark messages as read as soon as new replies are sent to the user on WhatsApp.
-
Information Retrieval (/info command):
- Obtain details about specific user topics and their configurations.
- Clone the repository
git clone https://github.com/yehuda-lev/WhatsGramBot.git
To set up the environment variables for the project, follow these steps:
- Copy the
.env.example
file:
cp .env.example .env
-
Edit the
.env
file:-
Open the
.env
file in a text editor of your choice. -
Replace the placeholder values with your actual credentials. You can obtain these credentials from the following sources:
-
Telegram Credentials:
TG_API_ID
andTG_API_HASH
: Obtain from my.telegram.org.TG_BOT_TOKEN
: Create a new bot on BotFather.TG_GROUP_TOPIC_ID
: ID of the Telegram group where the bot will operate.
-
WhatsApp Credentials:
WA_PHONE_ID
,WA_BUSINESS_ID
,WA_VERIFY_TOKEN
,WA_TOKEN
,WA_PHONE_NUMBER
: Create a WhatsApp application following the guide here.WA_APP_ID
andWAAPP_SECRET
: Obtain from your Facebook developers account under "App Settings" > "Basic". Access all your apps here.WA_CALLBACK_URL
: URL for the webhook to receive incoming messages from WhatsApp. You can use a service like ngrok to create a secure tunnel to your local server.WEBHOOK_ENDPOINT
: Endpoint to register the webhook for the bot (will becomeWA_CALLBACK_URL/WEBHOOK_ENDPOINT
)
-
General Settings:
PORT
: Port number to run the server on (default is 8080).DEBUG
: Set totrue
to enable debug mode, which logs additional information to the console (default isfalse
).HTTPX_TIMEOUT
: Timeout for HTTP requests in seconds. change if running on a slow network or server (default is 15.0 seconds).
-
-
-
Save the
.env
file:- After editing, save the changes to the
.env
file.
- After editing, save the changes to the
By completing these steps, your environment variables will be properly configured for the project.
Clone the repository to your local machine. Then, build the Docker image using the following command:
If you want to rebuild the image, you can use the
--build
flag to force a rebuild: If you want to run the bot in the background, you can use the-d
flag:
docker compose up
This project was created by @yehudalev.