uh hello guys uh welcome to this video
So in this video I will show you how to
build out a WhatsApp bot which can
actually automatically send messages for
you using a flask web application So for
this we are using this API I have given
the link in the description of this
video So first of all you just need to
create a free account here After
creating a free account you can login
with your Google account and then it
will grant you with 150 messages free
messages You can try out this free
API It will give you 150
messages and uh it will give you your
token as well I have already created
this So this will be your token So just
link with your own I've already linked
in with my mobile number WhatsApp number
So you just need to link it and just
create a simple channel So I am there
inside this So let me build out a flash
cap
So let me just show you the application
that we will be building here So this
will be a simple web application which
will actually contain this two input
fields where you will write the number
and actually the message and there is a
send button out there So it's actually a
web application as you can see it is
running on local host and here you will
input the number of the user to which
you are sending out the
message So followed by the message and
now as I click the send button you will
basically see it will make the response
to the API and the response will be
returned to us Message
sent And if I show you WhatsApp web you
will see this message is automatically
sent to to this phone number As you can
see it's a WhatsApp
bot So we input the number we input the
actual message that needs to be sent So
again if I repeat
this and
uh again if I click send here you will
see again the message will be sent
automatically you will see that So it's
a simple WhatsApp bot kind of a
application inside flask I will show you
how to get started here step by step So
first of all just create a simple
account here I've already created this
login with your Google account and it
will give you this 150 free
messages So after that you need to
create a flask
application So all the source code I
have given in the description of the
video So first of all just
Make a simple app py file and after
that you need to import the flask from
that import flask and uh the request
module and the
JSON and also render
template And then we also need the
request module as well to actually make
the request to the API And then we'll be
initializing the new flask app like
this And then here we need to specify
the a API token So this API token it
will be giving So simply copy this from
here Once you create the account the
token will be assigned to you So you
need to use the token After that
uh we will have this hook here which
will
be I have given all this script in the
description of the video So if you need
the full
script the link is given in the
description you can directly copy paste
the full overall
script So inside this web hook we will
be listening for all the messages which
will be coming
So data request
JSON So this is essentially we are
listening it's kind of a hook where we
are listening for any sort of messages
which will be coming right here inside
this
hook So received message So if someone
sends you a message then this will be
printed
out But for this application we just
need a simple index.html file where we
allow the user to input the message So
here we are loading this index.html So
right in the templates
folder in the flags we will create this
index html file And right here we will
allow the user
to having a simple
form where inside the form we will have
two input fields for entering the phone
number and actually the actual message
and we have will be having a button So
this will be a simple form uh if I try
to run the application now by going to
localhost So now it will look something
like this This is will be a form So when
you submit the form right here you just
need to
write make a simple fetch request a post
request So write in the JavaScript
just after the body So right here we are
making this post request fetch request
slash
send It's a post request So we are
sending this data which is these to and
body So now we just need to make this
post
request inside your Python file
So so right in this post request inside
slash send just after
this we are getting the data that is
submitted through the form
here to body everything and then now we
here we are calling this function which
is send response So now we just need to
define this function which is send
response which will get
executed which will be responsible for
sending the WhatsApp message So
send response and uh to and
body So right here making a
simple request to the API
https
gate So we will providing the payload
which will be the two values the two
And then we also be passing the headers
which will contain the API
token and
then our response will be sent So as
soon as the response is sent our message
will also be
sent like this
So this completes the application
So if I just show you the application
Now if
I enter a 10digit mobile number then I
enter my message Click on send Now you
will see message will be sent And if I
check now you will
see your message is successfully sent So
in this way guys you can build out a
simple WhatsApp web bot kind of a bot
which can where you can actually send
messages automatically using this API
So first of all you need to create an
account here It will give you 150 free
messages and uh after that you just need
to subscribe to their API to get more
messages As you can see I've used up six
messages out of 150 So when you sign up
you will get this
free token free messages as well So
there is some limitations to it as well
So you can upgrade the if you want the
unlimited access So thank you very much
for watching this video and also check
out my website freemediatools.com
uh which contains uh thousands of tools