Chatbot Logic
The chatbot logic is simple.
We will search the incoming message for the words 'dog' and 'quote'. If the incoming message contains both the words, we return a media file containing a dog image and a famous quote along with it.
Here responded = False, acts as a flag to check whether or not a message has been responded.
responded = False
if 'quote' in incoming_msg:
# Respond with a quote
responded = True
if 'dog' in incoming_msg:
# Respond with a dog picture
responded = True
if not responded:
# return a generic response here
We will use the following third-party APIs to supply the chatbot with quotes and dog pictures. On refreshing the API, a dog or a quote is returned.
Dog API: https://dog.ceo/api/breeds/image/random
Quote API: https://api.quotable.io/random
5
