Fortune Teller Chatbot
Alerts & Notifications
Author
Ian Jennings
Last Updated
2016-08-01
Basis for a chat bot.
This block makes Zoltar, a simple fortune teller chat bot that will respond to a user's questions with a 'magic 8 ball' like response.
Walkthrough
This bot responds to questions asked in the channel. First, an array of responses is defined at the top.
var responses = [ 'It is certain.', 'It is decidedly so.', 'Without a doubt.' //... ]
Then, the script checks to see if a question was asked by making sure a question mark (?
) appears within the message.
If it does not exist, the bot asks the user to ask a question. If it does exist, the bot calculates a response using the question length. This ensures that the same question is met with the same answer.
Input
An example message published by the client Input Channel: advice-channel
1
Output
A message will be published on the same channel Output Channel: advice-channel
1