Programming WhatsApp is now even simpler for Python builders
WhatsApp is a free multiplatform messaging program that lets you make video and cellphone conversations, ship textual content messages, and extra all around the web. WhatsApp is extraordinarily widespread amongst family and friends who reside in different international locations and want to keep in contact, with over 2 billion lively customers.
WhatsApp lately opened up its Cloud API to make it simpler for builders to combine with its messaging service, however getting began could also be tough.
Heyoo is an open-source Python wrapper developed by Neurotech to make the combination even simpler.
- Message sending
- Media Distribution (pictures, audio, video and paperwork)
- Ship location
- Ship interactive buttons
- Ship message templates
To start utilizing
heyoo, you will need to first set up the library, both manually or utilizing pip.
You’ll be able to clone the venture repository with git or instantly obtain it as indicated beneath.
$ git clone https://github.com/Neurotech-HQ/heyoo
$ cd heyoo
heyoo $ python setup.py set up
# For Home windows
pip set up --upgrade heyoo
#For Linux | MAC
pip3 set up --upgrade heyoo
To run the code on this bundle you’ll need a TOKEN and a TEST WHATSAPP NUMBER.
You’ll have to setup a Fb developer account on the Facebook Developer Portal the place you’ll later be prompted to setup a Fb enterprise account.
Some tips to get began.
- Go to your purposes.
- Create an utility
- Select Enterprise >> Bussiness: You may be requested to fill out some primary app data.
- Subsequent you may be prompted to incorporate merchandise in your app. WhatsApp Messenger ought to be included.
- After making a enterprise account you’ll discover your TOKEN and TEST WHATSAPP NUMBER proper there.
- Lastly, double-check the quantity you’ll use for testing within the To discipline.
- After you’ve accomplished the previous steps, you’re prepared to start hacking with the Wrapper.
How you can authenticate your utility.
from heyoo import WhatsApp
messenger = WhatsApp('TOKEN', phone_number_id='104xxxxxx')
Upon getting authenticated your app, now you can begin utilizing the above-mentioned function as proven above.
Right here is tips on how to ship messages:
messenger.send_message('Your message ', 'xxxxxxxxxxx') # put cell quantity the place there's xxxxxxxxxxx
messenger.send_message('Hello there simply testing', 'xxxxxxxxxxx') # put cell quantity the place there's xxxxxxxxxxx
You’ll be able to both specify a hyperlink containing the media or specify an object id when transmitting media (picture, video, audio, gif, and doc) utilizing the identical technique.
All media strategies assume you’re sending a hyperlink with media by default, however you could change that by specifying
Right here is an instance:
"header": "Header Testing",
"physique": "Physique Testing",
"footer": "Footer Testing",
"button": "Button Testing",
"id": "row 1", "title": "Send Money", "description": "",
"id": "row 2",
"title": "Withdraw money",
Right here is tips on how to ship a pre-approved template message.