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 22, 2018
1 parent 78add23 commit 33edb39
Showing 1 changed file with 81 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/"
}
}
}
}
]
}
]
}
]
}
]
}
});
});

0 comments on commit 33edb39

Please sign in to comment.