Skip to content

Instantly share code, notes, and snippets.

@leny

leny/readme.md Secret

Created July 14, 2020 07:38
Show Gist options
  • Save leny/efea143d8d83253086062ed44568c7f9 to your computer and use it in GitHub Desktop.
Save leny/efea143d8d83253086062ed44568c7f9 to your computer and use it in GitHub Desktop.
Micro chatbot

💬 Micro chatbot challenge

Create a micro chatbot


For this challenge, you will create a chatbot. First, you'll need an UI, which is just a list of messages (there's two types of messages - thoses from the bots and those from the user) and a textarea with a send button.

Sending a message to the bot is done by clicking the send button or typing ENTER.

Bonus/hardmode challenge: support multi-line messages: by typing SHIFT+ENTER, you create a new line in the textarea.

On loading of the page, the bot welcomes the user with a random greeting message (your bot needs at least three different welcoming message), then, he ask the user "how do you feel today?".

Bonus challenge: add "in progress" animation and timeout to simulate "bot thinking"

The user can reply freely, and the bot need to check in the response if he can find a "yes" or a "no":

  • if the script find a "yes" in the message, the bot answers with a random sentence from a specific set (minimum three different)
  • if the script find a "no" in the message, the bot answers with a random sentence from a specific set (minimum three different)
  • if the script cannot find a "yes" or a "no" in the message, the bot answer something like "I didn't understand, can you please try again"
  • if the script cannot find a "yes" or a "no" in the message after three attempts, the bot begins to be mad and use "passive-agressive" answer, like "dude, are you sure you can read?"

After this answer, the bot has finish his routine. He says "bye" to the user and the textarea go to disabled mode.


That's all. You can try to make the bot more "real" by having more possible answers to interact with the user.

Have fun!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment