Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

whatsapp bot python code

from flask import Flask
from googlesearch import search
import requests
from twilio.twiml.messaging_response import MessagingResponse
  
  
app = Flask(__name__)
  
@app.route("/", methods=["POST"])
  
# chatbot logic
def bot():
  
    # user input
    user_msg = request.values.get('Body', '').lower()
  
    # creating object of MessagingResponse
    response = MessagingResponse()
  
    # User Query
    q = user_msg + "geeksforgeeks.org"
  
    # list to store urls
    result = []
  
    # searching and storing urls
    for i in search(q, tld='co.in', num=6, stop=6, pause=2):
        result.append(i)
  
    # displaying result
    msg = response.message(f"--- Result for '{user_msg}' are  ---")
  
    msg = response.message(result[0])
    msg = response.message(result[1])
    msg = response.message(result[2])
    msg = response.message(result[3])
    msg = response.message(result[4])
  
    return str(response)
  
  
if __name__ == "__main__":
    app.run()
Comment

PREVIOUS NEXT
Code Example
Python :: pandas 
Python :: python string caps lock 
Python :: how to update a python package 
Python :: pygame buttons 
Python :: size of matrix python 
Python :: draw canvas in python 
Python :: remove dict python 
Python :: python array use numpy arange 
Python :: flask socketio send 
Python :: how to print from a python list 
Python :: boolean python example 
Python :: how to use loop in python 
Python :: pd.explode 
Python :: false python 
Python :: pandas columns 
Python :: run python from c# 
Python :: when to use map function in python 
Python :: jama api python 
Python :: mapping in python 
Python :: self.variable 
Python :: copy multiple files from one folder to another folder 
Python :: python else 
Python :: python newton raphson 
Python :: python string: immutable string 
Python :: print numbers from 1 to 100 in python 
Python :: round() function in python 
Python :: how to transcode a video in python using ffmpeg 
Python :: receipt parsing 
Python :: python builtwith 
Python :: numpy nditer 
ADD CONTENT
Topic
Content
Source link
Name
5+6 =