This file contains 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
// Import Botkit and Google Cloud Language API | |
const Botkit = require('botkit'); | |
const language = require('@google-cloud/language'); | |
// Instantiates a GCPL client | |
const client = new language.LanguageServiceClient(); | |
// Create the Botkit controller | |
const controller = Botkit.sparkbot({ | |
public_address: process.env.public_address, |
This file contains 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
const response_emoji = ['😭', '😢', '😞', '😐', '🙂', '😃', '😄']; | |
controller.on('direct_mention,direct_message', function(bot, message) { | |
if(message.text) { | |
const document = { | |
content: message.text, | |
type: 'PLAIN_TEXT', | |
}; | |
client.analyzeSentiment({document: document}) |
This file contains 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
# Environment Config | |
access_token=YOUR_CISCO_BOT_TOKEN | |
public_address=PUBLIC_GLITCH.ME_ADDRESS | |
secret=RANDOM_STRING | |
studio_token= | |
PORT= | |
GOOGLE_APPLICATION_CREDENTIALS=~/.data/credentials.json |
This file contains 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
"dependencies": { | |
... | |
"@google-cloud/language": "2.0.0" | |
}, |
This file contains 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
// Import Botkit | |
const Botkit = require('botkit'); | |
// Imports the Google Cloud client library | |
const language = require('@google-cloud/language'); | |
// Instantiates a client | |
const client = new language.LanguageServiceClient(); | |
// Create the Botkit controller | |
const controller = Botkit.sparkbot({ |
This file contains 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
# Environment Config | |
access_token=YOUR_CISCO_TOKEN | |
public_address=GLITCH_DOMAIN | |
secret=RANDOM_STRING | |
studio_token= | |
PORT= | |
weather_token=YOUR_OPENWEATHERMAP_KEY |
This file contains 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
controller.on('direct_mention', function(bot, message) { | |
if(message.text){ | |
const query = message.text.trim(); | |
if(query.includes('help')) { | |
bot.reply(message, 'Hi! I\'m Weatherbot! I can get you the weather in any city!'); | |
bot.reply(message, 'Usage: @weather-bot [city] or @weatherbot [city],[country code]'); | |
} | |
else { | |
bot.reply(message, 'Let me check...'); | |
getWeatherFor(bot, message, query); |
This file contains 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
function getWeatherFor(bot, message, city) { | |
const query = 'http://api.openweathermap.org/data/2.5/weather?q=' + encodeURI(city) | |
+ '&appid=' + process.env.weather_token; | |
http.get(query, (res) => { | |
const { statusCode } = res; | |
const contentType = res.headers['content-type']; | |
res.setEncoding('utf8'); |
This file contains 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
// Import Botkit | |
const Botkit = require('botkit'); | |
// Import Node HTTP for API requests | |
const http = require('http'); | |
// Create the Botkit controller | |
const controller = Botkit.sparkbot({ | |
public_address: process.env.public_address, | |
access_token: process.env.access_token, |
This file contains 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
// Import Botkit | |
const Botkit = require('botkit'); | |
// Import Node HTTP for API requests | |
const http = require('http'); | |
// Create the Botkit controller | |
const controller = Botkit.sparkbot({ | |
public_address: process.env.public_address, | |
access_token: process.env.access_token, |