whatsapp_bot_flutter 0.0.3 whatsapp_bot_flutter: ^0.0.3 copied to clipboard
Whatsapp bot using whatsapp web scrapping
Whatsapp bot flutter #
Whatsapp bot using whatsapp web scrapping
Getting Started #
First launch will take some time
it will download chromium files locally, using puppeteer for whatsapp web and scarping data
Macos setup #
Enable outgoing and incoming connections for macos and also disable sandbox mode comment this out in macos/Runner/*.entitlements:
<key>com.apple.security.app-sandbox</key>
<true/>
Features #
Supported Whatsapp features are :
- Login with QR
- Logout
- Keep session
- Send text message
- Send image, audio & document
- Listen to New Messages
- Listen to Connection Events
Usage #
First connect with whatsapp using WhatsappBotFlutter.connect
method , we can get qrcode from onQrCode
callback
if we got onSuccess
,this means we are connected and ready to send messages
To convert qrCode String to QrCode widget for scanning use pretty_qr_code , check example for more details
WhatsappBotFlutter.connect(
onQrCode: (String qr) {
// there we will get QrCode string use any library to convert string to qrcode and scan
},
onError: (String er) {
// listen for errors
},
onSuccess: () {
// if we received this callback , it means we are connected to whatsapp
},
progress: (int prg) {
// we can listen for progress update
},
);
Use sendTextMessage
to send a text message
WhatsappBotFlutter.sendTextMessage(
countryCode: "91",
phone: "------",
message: "Test Message",
);
Use sendFileMessage
to send a File
await WhatsappBotFlutter.sendFileMessage(
countryCode: "91",
phone: "------",
fileBytes: imageBytes, // Pass a Uint8List file bytes
caption: "Test Message", // Optional
fileType: fileType, // document, image, audio
;
To get new Messages , subscribe to WhatsappBotFlutter.messageEvents
WhatsappBotFlutter.messageEvents.listen((Message message) {
// Got whatsapp messages ...
});
To get whatsapp connection Events , subscribe to WhatsappBotFlutter.connectionEventStream
WhatsappBotFlutter.connectionEventStream.listen((event) {
// Got Connection Events ...
});
Resources #
Thanks to wa-js for exporting functions from WhatsApp Web
Note #
Its just initial version , under heavy development