Skip to content

Commit

Permalink
fixed example
Browse files Browse the repository at this point in the history
  • Loading branch information
miki2826 committed Jul 4, 2016
1 parent 36df3be commit 041e9d2
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions example/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,27 +23,30 @@ botly.on('message', (sender, message, data) => {

if (users[sender]) {
if (data && data.text && data.text.indexOf("image") !== -1) {
botly.sendImage(sender, "https://upload.wikimedia.org/wikipedia/en/9/93/Tanooki_Mario.jpg", function (err, whatever) {
botly.sendImage({id: sender, url:"https://upload.wikimedia.org/wikipedia/en/9/93/Tanooki_Mario.jpg"}, function (err, whatever) {
console.log(err);
});
}
else if (data && data.text &&data.text.indexOf("buttons") !== -1) {
let buttons = [];
buttons.push(botly.createWebURLButton("Go to Askrround", "http://askrround.com"));
buttons.push(botly.createPostbackButton("Continue", "continue"));
botly.sendButtons(sender, "What do you want to do next?", buttons, function (err, data) {
botly.sendButtons({id: sender, text: "What do you want to do next?", buttons: buttons}, function (err, data) {
console.log("send buttons cb:", err, data);
});
}
else if (data && data.text && data.text.indexOf("generic") !== -1) {
let buttons = [];
buttons.push(botly.createWebURLButton("Go to Askrround", "http://askrround.com"));
buttons.push(botly.createPostbackButton("Continue", "continue"));
let element = botly.createElement("What do you want to do next?",
"https://upload.wikimedia.org/wikipedia/en/9/93/Tanooki_Mario.jpg",
"https://upload.wikimedia.org/wikipedia/en/9/93/Tanooki_Mario.jpg",
"Choose now!", buttons);
botly.sendGeneric(sender, element, function (err, data) {
let element = {
title: 'What do you want to do next?',
item_url: 'https://upload.wikimedia.org/wikipedia/en/9/93/Tanooki_Mario.jpg',
image_url: 'https://upload.wikimedia.org/wikipedia/en/9/93/Tanooki_Mario.jpg',
subtitle: 'Choose now!',
buttons: [botly.createWebURLButton('Go to Askrround', 'http://askrround.com')]
};
botly.sendGeneric({id: sender, elements:element}, function (err, data) {
console.log("send generic cb:", err, data);
});
}
Expand Down Expand Up @@ -98,14 +101,14 @@ botly.on('message', (sender, message, data) => {
}
]
};
botly.sendReceipt(sender, payload, function (err, data) {
botly.sendReceipt({id: sender, payload: payload}, function (err, data) {
console.log("send generic cb:", err, data);
});
}
else {
botly.send(sender, {
botly.send({id: sender, message: {
text: `Sorry ${users[sender].last_name}, you are annoying `
}, function (err, data) {
}}, function (err, data) {
console.log("regular send cb:", err, data);
});
}
Expand Down Expand Up @@ -138,7 +141,7 @@ botly.on('error', (ex) => {
});

if (process.env.PAGE_ID) {
botly.setWelcomeScreen(process.env.PAGE_ID, {text: "What's upppppppppp?????!!!!"}, function (err, body) {
botly.setWelcomeScreen({pageId: process.env.PAGE_ID, message: {text: "What's upppppppppp?????!!!!"}}, function (err, body) {
console.log("welcome cb:", err, body);
});
}
Expand Down

0 comments on commit 041e9d2

Please sign in to comment.