def sms(): # Get the text in the message sent message_body = request.form['Body'] # Create a Twilio response object to be able to send a reply back (as per # Twilio docs) resp = MessagingResponse() # Send the message body to the getReply message, where # we will query the String and formulate a response replyText = getReply(message_body) # Text back our response! resp.Message('Hi\n\n' + replyText) return str(resp)
def bot(): incoming_message = requests.values.get('Body','').lower() resp = MessagingResponse() msg = resp.Message() responded = False if 'quote' in incoming_message(): r = requests.get('https://api.quotable.io/random') if r.status_code == 200: data = r.json() quote = f'{data["content"]} ({data["author"]})' else: quote ='I could not retrieve any quote(s) at this time.' msg.body(quote) responded = True if 'cat' in incoming_message(): msg.media('https://cataas.com/cat') responded = True if not responded : msg.body('I only know famous quotes and cats') return str(resp)