A Whatsapp bot that turns pictures, small videos and gifs into stickers
example_video.mp4
If you are not interested in running a copy of the project then feel free to use the whatsticker number provided. You can only send private messages and it cannot be added to group chats
-
Download Go modules
# Downloads go modules go mod tidy
-
Create a meta business app for whatsapp cloud API found here WhatsApp FAQ. Make sure to add the whatsapp product for the app.
-
Retrieve the access token from the app to be later used as
BEARER_ACCESS_TOKEN
-
Start ngrok on port 9000 (using us region or adding the webhook would be an issue)
ngrok -http 9000 --region us
-
Create a webhook by following Configure WebHook and add the ngrok link given to you. Save the verify token add to be later used as
VERIFY_TOKEN
. -
Configure the webhook to subscribe to messages.
- Export the necessary tokens
export VERIFY_TOKEN=<xxxxxxx>
export BEARER_ACCESS_TOKEN=<xxxxxxx>
- Run
docker-compose up
. - In development you have to add your number to the test numbers in the app (or just message the running bot in production)
- Send media in chat and bot should respond with sticker
Open the architecture on draw.io
- Media sizes/length enforced by whatsapp (100KB image, 500KB video)
- Video conversion takes time using ffmpeg to be able to whittle away at quality in order to achieve 500KB
- Animated stickers (from videos) may not maintain aspect ratio
This project is opened under the MIT License which allows very broad use for both academic and commercial purposes
Library/Resource | Use |
---|---|
tulir/whatsmeow | whatsmeow is a Go library for the WhatsApp web multidevice API. |
ffmpeg | A complete cross platform solution to record, convert and stream video (and audio). |
cwebp | Compress an image file into WebP file |
webpmux | Write exif file to set metadata on stickers |
prometheus | Live metrics of stickerization |