跳到主要内容

Puppet Provider: WhatsApp

Wechaty Puppet Whatsapp

Wechaty Puppet Whatsapp

NPM Version npm (tag)

WhatsApp is the most popular Instance Messaging service in many parts of the world. With the WhatsApp Wechaty Puppet Provider, you can reach more than 1.5 billion WhatsApp users. You can send notifications, have two-way conversations, by building chatbots. If you're trying to reach and better converse with users in the west world, you need to consider using WhatsApp.

With the introduction of wechaty puppet and the growth of the wechaty ecosystem and community, we’re happy to introduce wechaty-puppet-whatsapp which connects Wechaty API, the conversational RPA SDK for chatbot makers, and WhatsApp, a free, multi-platform messaging app.

The WhatsApp Wechaty Puppet Provider is now available in alpha stage, to allow developers to start building and prototyping in your developing environments.

As a developer, you can use wechaty-puppet-whatsapp to build your own WhatsApp chatbot with a few lines of code, which can send and receive WhatsApp messages with wechaty API.

Features

  1. Send & receive messages

Deployment

Run wechaty-puppet-whatsapp:

npm install wechaty-puppet-whatsapp
export WECHATY_PUPPET=wechaty-puppet-whatsapp
npm start

Integrating a Bot to Whatsapp

Let's take up an example on how to integrate bot from starter templete to Whatsapp.

The steps are similar for all other bots as well.

Prerequisite

  1. Offical Wechaty package: package/wechaty.
  2. QRCode terminal edition: package/qrcode-terminal.

You can follow up the steps mentioned below:

  1. Initialize the project by creating a new folder my-bot.
mkdir my-bot
cd my-bot
  1. Install the dependencies using the following commands:
npm install wechaty
npm install qrcode-terminal
  • Add the dependencies for using the bot with Whatsapp.
  • npm install wechaty-puppet-whatsapp
  • Create a new folder src and add a file my-bot.js. Add your custom functions to the code snippet below:
  •   
    import {
    Wechaty,
    ScanStatus,
    log,
    } from 'wechaty'

    import qrcodeTerminal from 'qrcode-terminal'

    console.log(welcome)
    const bot = new Wechaty()

    /*
    *Your function goes here
    */
    1. After you are done with the file, you can run the bot using the following commands:
    export WECHATY_LOG=verbose
    export WECHATY_PUPPET=wechaty-puppet-whatsapp
    node src/my-bot.js

    Scan it using your Whatsapp and you are ready to play with the bot! You can read more about deploying a whatsapp puppet here.

    Features to be implemented

    Here are some features to be implemented :

    FeatureStatus
    Send and Receive text messages
    Send media (images/audio/documents)
    Send video
    Receive Video
    Receive media (images/audio/video/documents)
    Send contact cards
    Get invite for group
    Modify group subject
    Add group participants
    Kick group participants
    Mention users
    Get contact info
    Get profile pictures
    Set user status message

    History

    Contributing

    Feel free to file an issue on the github repo for any feedback.

    wechaty-puppet-whatsapp is an open-source project. If you’re interested in contributing to this project, check out the contribution guidelines to learn more, and welcome to join the Wechaty Developers’ Home or our Gitter network to join our community.

    Maintainers