패키지, 저장소 및 앱 카테고리 검색

패키지 상세v2.1.2

whatsapp_bot_flutter

Puppeteer 및 WhatsApp 웹 스크래핑을 사용한 WhatsApp 봇. Flutter 데스크톱/웹 및 Dart 프로젝트 지원

WebmacOSWindowsLinux
30일 다운로드
296
좋아요
73
Pub 점수
160

패키지 설치

flutter pub add whatsapp_bot_flutter

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

Puppeteer를 통한 웹 스크래핑을 통해 WhatsApp 봇 기능을 가능하게 하는 Flutter/Dart 패키지로, 데스크톱 및 웹 애플리케이션용으로 설계되었습니다. 헤드리스 브라우저 기능을 활용하여 WhatsApp 웹과의 상호작용을 자동화할 수 있습니다. 웹, macOS, Windows, Linux에서의 크로스플랫폼 배포를 지원하여 맞춤형 메시징 도구 개발에 이상적입니다. Flutter 프로젝트에 원활하게 통합되며, Dart 로직과 브라우저 기반 WhatsApp 상호작용 사이의 다리를 제공합니다.

사용 사례

  • 자동화된 고객 지원 메시지
  • 대량 메시지 브로드캐스팅
  • 예약된 웨이트스앱 알림
  • 인터랙티브 챗봇 인터페이스
  • 데스크톱 기반의 WhatsApp 자동화

주요 기능

  • Puppeteer 기반의 WhatsApp 웹 스크래핑
  • 크로스 플랫폼 지원 (웹, macOS, Windows, Linux)
  • Flutter 및 Dart 프로젝트 통합
  • 헤드리스 브라우저 자동화
  • 실시간 메시지 처리
  • 경량이며 설치가 간편합니다

적합한 대상

  • 데스크톱/웹 WhatsApp 봇을 개발하는 개발자
  • 자동 메시지 솔루션을 필요로 하는 팀
  • 공식 API 없이 WhatsApp 통합을 필요로 하는 프로젝트
  • 교육 또는 프로토타이핑 사용 사례

고려 사항

  • WhatsApp 웹의 공개 인터페이스에 의존합니다(업데이트로 인해 작동이 중단될 수 있음)
  • QR 코드를 통한 사용자 인증이 필요합니다
  • WhatsApp에서의 잠재적인 속도 제한 또는 금지
  • 워그램에서 공식적으로 지원되지 않음
  • 다양한 플랫폼에서 안정적인 Puppeteer 성능에 의존

원본 README

연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.

Whatsapp bot flutter

whatsapp_bot_flutter_logo

whatsapp_bot_flutter version

whatsapp_bot_flutter_mobile version

whatsapp_bot_flutter_web version

Getting Started

We can use this library in Flutter as well as Pure dart projects , checkout dart_example

First launch on Desktop apps will take some time, it will download chromium files locally, using puppeteer

Usage

Get WhatsappClient using connect method

Either link with QRCode (default) and get QrCode in onQrCode callback or set linkWithPhoneNumber, and get code in onPhoneLinkCode callback

// use WhatsappBotFlutterMobile.connect for Android/IOS platforms
WhatsappClient? whatsappClient = await WhatsappBotFlutter.connect(
  onConnectionEvent: (ConnectionEvent event) {
    print(event.toString());
  },
  onQrCode: (String qr, Uint8List? imageBytes) {
    // use imageBytes to display in flutter : Image.memory(imageBytes)
    print(WhatsappBotFlutter.convertStringToQrCode(qr));
  },
);

We have these modules to access whatsappClient features :

WhatsappClient.chat
WhatsappClient.contact
WhatsappClient.profile
WhatsappClient.group

Use sendTextMessage to send a text message

phone parameter can be of this format : countryCode+phoneNumber , eg : 91xxxxxxxxxx , or we can get phone from messageEvents in this format : countryCode+phone+"@c.us"

await whatsappClient.chat.sendTextMessage(
    phone: "------",
    message: "Test Message",
);

Use sendFileMessage to send a File

await whatsappClient.chat.sendFileMessage(
    phone: "------",
    fileBytes: fileBytes, // Pass file bytes
    caption: "Test Message", // Optional
    fileType: fileType, // document, image, audio
);

To get whatsapp connection Events , subscribe to whatsappClient.connectionEventStream

whatsappClient.connectionEventStream.listen((event) {
  // Connection Events : authenticated,logout,connected.....
});

To get new Messages

whatsappClient.on(WhatsappEvent.chat_new_message, (data) {
    List<Message> messages = Message.parse(data);
    // replyMessageId  is optional , add this to send a reply message
    whatsappClient.chat.sendTextMessage(
      phone: message.from,
      message: "Hey !",
      replyMessageId: message.id,
    );
});

We can listen to multiple events like this

whatsappClient.on(WhatsappEvent.EVENT_NAME, (data) {})

To stop listening to an event

whatsappClient.off(WhatsappEvent.EVENT_NAME);

Features

Supported Whatsapp features : - Create multiple whatsapp clients
  • Login with QR
  • Auto refresh QrCode
  • Logout
  • Keep session
  • Listen to whatsapp events
  • Reject calls
  • Send text message
  • Send image, audio & document
  • Send location message
  • Send poll in groups
  • Send contact card
  • Reply to a message
  • Archive/Unarchive chats
  • Mute/Unmute chat
  • Clear chat
  • Delete chat
  • Get lastSeen
  • Get chats
  • Mark messages as seen
  • Mark message as unread
  • Pin/Unpin chat
  • Delete messages
  • Download media
  • Get messages
  • Get profile picture
  • Get status
  • Get contacts
  • Get status of loggedIn user
  • Set status
  • check if logged in user have business account
  • Set profile picture of logged in user
  • and many more..

Mobile Setup (Android/IOS)

To setup on Android , make sure to checkout flutter_inappwebview documentation for Android and IOS setup Android sdk:minSdkVersion cannot be smaller than version 19

Desktop setup (Windows/Mac/Linux)

For Macos , Enable outgoing and incoming connections, If getting sandbox issue , try disabling sandbox mode comment this out in macos/Runner/*.entitlements:

<key>com.apple.security.app-sandbox</key>
<true/>

Should run out of the box in Windows and Linux

Web setup

checkout web demo app : https://rohitsangwan01.github.io/whatsapp_bot_flutter

To run natively on Web, checkout whatsapp_bot_flutter_web

We can use browserless, Create a free account there and get API_TOKEN from browserless, and use this url to connect : wss://chrome.browserless.io?token=API_TOKEN

Or we can run puppeteer, and get browserWsEndpoint from there and pass into the connect method, checkout this example

then pass this browserWsEndpoint in connect method, and also requires wppJsContent, we can download this file from here, add this file in assets and pass like this,

await WhatsappBotFlutter.connect(
    browserWsEndpoint: "BROWSER_WS_ENDPOINT_URL",
    wppJsContent: await rootBundle.loadString("assets/wpp.js"),
);

We can use this on Mobile or Desktop platforms as well , to connect to a chrome server hosted somewhere else

If we have to access this webSocket url locally on Mobile or other platforms , we can use ngrok to expose our local Websocket url to internet

Resources

Thanks to wa-js for exporting functions from WhatsApp Web

Disclaimer

This project is not affiliated, associated, authorized, endorsed by, or in any way officially connected with WhatsApp or any of its subsidiaries or its affiliates. The official WhatsApp website can be found at https://whatsapp.com. "WhatsApp" as well as related names, marks, emblems and images are registered trademarks of their respective owners.

Note

Its just initial version, I can't guarantee you will not be blocked by using this method, try to avoid primary whatsapp numbers. WhatsApp does not allow bots or unofficial clients on their platform, so this shouldn't be considered totally safe.

카테고리

의존성

의존성 목록 2 개

  • puppeteer^3.8.0
  • whatsapp_bot_platform_interface^2.0.2

소스 저장소

이 패키지를 사용하는 프로젝트

아직 데이터가 없습니다.