Code within the GupShup IDE for the chatbot:
function MessageHandler(context, event) {
if(event.message.toLowerCase() == "hi"){
context.sendResponse("Hello.");
}
else if(event.message.toLowerCase() == "hello"){
context.sendResponse("Hello.");
}
else if(event.message.toLowerCase() == "help"){
context.sendResponse("Enter 'random', 'weather', 'politics', 'science', 'sports', entertainment', or 'tech' for corresponding news.")
}
else if(event.message.toLowerCase() == "weather"){
context.simplehttp.makeGet("http://gupshup-kylemarino22164237.codeanyapp.com/weather.php")
}
else if(event.message.toLowerCase() == "random"){
context.simplehttp.makeGet("http://gupshup-kylemarino22164237.codeanyapp.com/random.php")
}
else if(event.message.toLowerCase() == "politics"){
context.simplehttp.makeGet("http://gupshup-kylemarino22164237.codeanyapp.com/politics.php")
}
else if(event.message.toLowerCase() == "science"){
context.simplehttp.makeGet("http://gupshup-kylemarino22164237.codeanyapp.com/science.php")
}
else if(event.message.toLowerCase() == "sports"){
context.simplehttp.makeGet("http://gupshup-kylemarino22164237.codeanyapp.com/sports.php")
}
else if(event.message.toLowerCase() == "entertainment"){
context.simplehttp.makeGet("http://gupshup-kylemarino22164237.codeanyapp.com/entertainment.php")
}
else if(event.message.toLowerCase() == "tech"){
context.simplehttp.makeGet("http://gupshup-kylemarino22164237.codeanyapp.com/tech.php");
}
else {
context.sendResponse("I don't understand. Type 'help' for a list of supported commands.");
}
}
//newsfetcher function HttpResponseHandler(context, event) { var content = JSON.parse(event.getresp); context.console.log(content); context.sendResponse("Your info: " + content) }
function EventHandler(context, event) { if(! context.simpledb.botleveldata.numinstance) context.simpledb.botleveldata.numinstance = 0; numinstances = parseInt(context.simpledb.botleveldata.numinstance) + 1; context.simpledb.botleveldata.numinstance = numinstances; context.console.log(numinstances); }

Log in or sign up for Devpost to join the conversation.