Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Commit

Permalink
Add google hangouts bot example
Browse files Browse the repository at this point in the history
  • Loading branch information
ouadie-lahdioui committed Jul 30, 2018
1 parent 78add23 commit df842af
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 7 deletions.
88 changes: 81 additions & 7 deletions examples/google_hangouts_bot.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,91 @@
var Botkit = require('../lib/Botkit.js');

var controller = Botkit.googlehangoutsbot({
endpoint: 'Axjn86rTGRQwisaYFyT0XZyiOCh7rZUPGx1A',
token: "efe_CIaKfFDdQlm_HBnQBkVeJUC_yNF3Uhs2lNeCdYs=",
token: "YOUR_TOKEN",
debug: true,
});

var bot = controller.spawn({});

controller.setupWebserver(3000, function(err, webserver) {
controller.createWebhookEndpoints(webserver, bot, function() {
console.log('ONLINE!');
controller.setupWebserver(3000, function (err, webserver) {
controller.createWebhookEndpoints(webserver, bot, function () {
console.log(`🚀 Congratulation, the web server is online!`);
});
});

controller.on('message_received', function (bot, message) {
bot.reply(message, `You said '${message.text}'`);
});

controller.hears('new thread', 'message_received', function (bot, message) {
bot.replyAsNewThread(message, `Hello ! this is a new thread`);
});

controller.hears('thread key', 'message_received', function (bot, message) {
bot.replyWithThreadKey(message, {
threadKey : "YOUR_THREAD_KEY",
requestBody : {
text : `Hi ! this message inside the same thread`
}
});
});

controller.hears('hello', 'message_received', function(bot, message) {
console.log("2 >> " + message.text);
});
controller.hears('convo', 'message_received', function (bot, message) {

bot.startConversation(message, function(err, convo) {

convo.ask('You want to know more about Botkit ?', [
{
pattern: bot.utterances.yes,
callback: function(response, convo) {
convo.say('Take a look here https://botkit.ai/docs/');
convo.next();
}
},
{
pattern: bot.utterances.no,
default: true,
callback: function(response, convo) {
convo.say('No problem');
convo.next();
}
}
]);
});

});

controller.hears('cards', 'message_received', function (bot, message) {
bot.reply(message, {
requestBody: {
cards: [
{
"sections": [
{
"widgets": [
{
"image": { "imageUrl": "https://image.slidesharecdn.com/botkitsignal-160526164159/95/build-a-bot-with-botkit-1-638.jpg?cb=1464280993" }
},
{
"buttons": [
{
"textButton": {
"text": "Get Started",
"onClick": {
"openLink": {
"url": "https://botkit.ai/docs/"
}
}
}
}
]
}
]
}
]
}
]
}
});
});
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"debug": "^3.1.0",
"email-addresses": "^3.0.1",
"express": "^4.15.2",
"googleapis": "^32.0.0",
"https-proxy-agent": "^2.2.1",
"jfs": "^0.3.0",
"localtunnel": "^1.8.2",
Expand Down

0 comments on commit df842af

Please sign in to comment.