Build a Chatbot in Minutes! It’s a Lot More Obvious Than it Seems

30 sec explanation of how Chatbots work

Whether you’re a data scientist, data analyst, or software engineer; and whether you have a strong handle on NLP tools and approaches, if you’re here, you’ve likely wondered how a chatbot works and how to build one, but haven’t ever had the need or chance. Well… you’re here now, so let's get it done.

You’ll be surprised to find you’re likely familiar with what goes into creating your own chatbot

Use cases?

It may be to query a simple database, make an order, reservation, customer service, and much more. We interact with chatbots every day.

What’s on the inside?

Chatbots are all about what’s called a rule matching engine.

In the simplest form; that pretty much means that when you get a message, what do you do with it?

One way you could do this is just by repeating back what was originally typed. While it seems overly simple and uninteresting, this idea serves as a good foundation before you branch into more complexity with your chatbot.

Let's get our hands dirty

def parrot_talk(incoming_message):

bot_response = "Hi, my name is Randy the Parrot, you said: " + message

return bot_response

print(parrot_talk("hello!"))

Obviously that’s a simple example, let's take it up a notch.

responses = {

"Hello": "Hey! How can I help you?",

"I need a refund": "I'm happy to help, can you give me more detail?"

}

def respond(message):

if message in responses:

return responses[message]

respond("I need a refund?")

Similar to what you saw the first time, here is a customer service chatbot. What we’re doing in the above dictionary is establishing keys that should relate to what our customers might say… those keys then map to an appropriate response.

Now obviously the limitation here is that it would require the message to be exactly the same as the key in the dictionary.

We can very quickly become far rigorous, using things like regular expressions on any given message, creating a flag to indicate the presence of various terms in the text & then keying off of that flag to populate our response.

To take it even further, we could deploy ML algorithms that could predict whether or not a message falls under a given intent or topic which we could then map back to the dictionary of appropriate responses.

Challenges

Have you ever seen the auto responses in LinkedIn? You should try to have a conversation by just tapping those prompts… beyond being fun, it’s an interesting exploration in the sophistication as well as the lack thereof. Among the toughest things for chat bots is the ability to track the state of any given conversation, which will be very obvious once you go and have that chat in linkedin.

Conclusion

Chatbots are surprisingly simple to create at first glance. Come check out more blog posts where we get into more of the nitty gritty of how to make your chatbots far more robust at datasciencelessons.com

Happy Data Science-ing!

我来评几句
登录后评论

已发表评论数()

相关站点

热门文章