June 25 - Chat Bot
Chat Bot
A chat bot is a sequence of choices that a user can make that leads to a certain outcome set up by the maker of the chat bot. A user makes a decision, and this leads to another choice, or simply a response. Chat bots are useful for customer service since they can reduce the human contact needed to help a consumer.
When coding a chatbot from scratch, a creator needs to act courteous, just like if they were a person. I began my chat bot by asking for the user's name, then I provided a series of questions that the user could ask and answers that the chat bot would provide. In the actual code, these came in the form of if statements.
If it was any other question, the chat bot would say: "I don't have a real answer, but I'm learning!"
The user could leave at any time by saying bye.
This is a segment of the code for my chat bot:
def chatbot():
print("Hello! I am a chatbot. What's your name?")
name = input()
print(f"Nice to meet you, {name}!")
while True:
print("Ask me anything or type 'bye' to end the chat.")
user_input = input().lower()
if user_input == 'bye':
print("Goodbye! Have a great day!")
break
elif 'how are you' in user_input:
print("I'm just a bunch of code, but I'm doing great!")
elif 'favorite color' in user_input:
print("I love green!")
else:
print("You said:", user_input)
print("I don't have a real answer, but I'm learning!")
I learned that an easier way to make a chatbot is by using a website called Chatfuel. Chatfuel has a drag and drop interface rather than the creator actually needing to know python. Very large chat bots such as the one below that I created about national parks can be made relatively easily. This chatbot has dozens of choices and answers. I made this bot about national parks, and gave the top three parks based on several categories. The user could choose between scenic parks, large parks, or the least visited parks when they engage with the chat bot.
A flow is a sequence of decisions and responses that leads to an end result. What is shown above is a web of many different flows. In my experimentation today, I discovered several pitfalls that chat bots can fall into. You must have a very specific purpose when you are creating a chat bot, and you have to program a question in for it to be answered. I made the same mistake several times: I forgot to link the whole flow together. Just like Christmas lights, all of the choices must be linked together for the flow to work.
Comments
Post a Comment