Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Python by (16.4k points)
My prerequisite is to send WhatsApp message to number present in the Mobile number section at whatever point another client record is made in User table. This will be an invite message.

At the point when another client register on the site, I need to send robotized/automated welcome message to the enrolled mobile number.

I'm searching for an answer where no manual intervention ought to be there.

1 Answer

0 votes
by (26.4k points)

You can do this with the help of Twilio Whatsapp API for python. 

It is a completely computerized measure and doesn't need manual mediation not at all like selenium.

Try the Following code

# Download the helper library from https://www.twilio.com/docs/python/install

import os

from twilio.rest import Client

# Your Account Sid and Auth Token from twilio.com/console

# and set the environment variables. See http://twil.io/secure

account_sid = os.environ['TWILIO_ACCOUNT_SID']

auth_token = os.environ['TWILIO_AUTH_TOKEN']

client = Client(account_sid, auth_token)

message = client.messages.create(

                              body='Hello there!',

                              from_='whatsapp:+14155238886',

                              to='whatsapp:+15005550006'

                          )

print(message.sid)

{

  "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",

  "api_version": "2010-04-01",

  "body": "Hello there!",

  "date_created": "Thu, 30 Jul 2015 20:12:31 +0000",

  "date_sent": "Thu, 30 Jul 2015 20:12:33 +0000",

  "date_updated": "Thu, 30 Jul 2015 20:12:33 +0000",

  "direction": "outbound-api",

  "error_code": null,

  "error_message": null,

  "from": "whatsapp:+14155238886",

  "messaging_service_sid": "MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",

  "num_media": "0",

  "num_segments": "1",

  "price": null,

  "price_unit": null,

  "sid": "SMXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",

  "status": "sent",

  "subresource_uris": {

    "media": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Messages/SMXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Media.json"

  },

  "to": "whatsapp:+15005550006",

  "uri": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Messages/SMXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.json"

}

Click on this this link for more detail.

Wanna become a Python expert? Come and join the python certification course and get certified.

Browse Categories

...