Skip to content

Commit a83b808

Browse files
authored
Create building whatsapp boot in python
A WhatsApp bot is application software that is able to carry on communication with humans in a spoken or written manner. And today we are going to learn how we can create a WhatsApp bot using python. First, let’s see the requirements for building the WhatsApp bot using python language.
1 parent d221bd2 commit a83b808

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

whatsapp boot in python

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Required Libraries: twilio, flask
2+
3+
from flask import Flask, request
4+
from twilio.twiml.messaging_response import MessagingResponse
5+
6+
app = Flask(__name__)
7+
8+
@app.route("/bot", methods=['POST'])
9+
def bot():
10+
incoming_msg = request.values.get('Body', '').lower()
11+
resp = MessagingResponse()
12+
msg = resp.message()
13+
responded = False
14+
15+
if 'hello' in incoming_msg:
16+
msg.body('Hello! How can I assist you today?')
17+
responded = True
18+
19+
if 'help' in incoming_msg:
20+
msg.body('Sure, how can I help you?')
21+
responded = True
22+
23+
if not responded:
24+
msg.body('Sorry, I didn\'t get that. Can you please clarify?')
25+
26+
return str(resp)
27+
28+
if __name__ == "__main__":
29+
app.run(debug=True)

0 commit comments

Comments
 (0)