Last active
August 4, 2017 09:29
-
-
Save jazzedge/8e96542b22b3b55662c2d8f0e98f8824 to your computer and use it in GitHub Desktop.
Bot - Random salutation #1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| HELPERS.JS | |
| module.exports = function () { | |
| /** | |
| * Returns a random integer between min (inclusive) and max (inclusive) | |
| * Using Math.round() will give you a non-uniform distribution! | |
| */ | |
| global.getRandomInt = function (min, max) { | |
| return Math.floor(Math.random() * (max - min + 1)) + min; | |
| } | |
| global.random_greeting = [ | |
| 'Greetings new friend.', | |
| "Hello there!", | |
| "Having fun I hope?", | |
| "Glad we've met.", | |
| "Happy to help!" | |
| ] | |
| } | |
| APP.JS | |
| function showIntroCard(message) { | |
| var randint = getRandomInt(0, random_greeting.length-1); | |
| var reply = new builder.Message() | |
| .address(message.address) //Required | |
| .text(random_greeting[randint] +" This is Yaddops' Geography Chatbot") | |
| .addAttachment({ | |
| contentUrl:"https://roccobot02gghwh4.blob.core.windows.net/images/chatbot1.jpg", | |
| contentType: 'image/jpg', | |
| name: 'chatbot1.png' | |
| }); | |
| bot.send(reply); | |
| setTimeout(function(){ | |
| var reply = new builder.Message() | |
| .address(message.address) //Required | |
| .text('I can answer questions on countries, capital cities, populations, and languages spoken. Try asking me something like "What is the population of France?", "What is the capital city of Venezula?", or "What languages are spoken in Russia?"'); | |
| bot.send(reply); | |
| }, 3000); | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment