Commit a99e521f authored by Tammo Ronke's avatar Tammo Ronke

v23424324wer32sdfkltiorgawrgjr

parent 3a67a983
......@@ -109,8 +109,6 @@ server.get("/redirect/:address/:url", (req, res, next) => {
address = JSON.parse(address);
bot.loadSession(address, (error, session) => {
console.log(session.userData.recentQueries);
let suggestion = suggestionStore.getSuggestionByUrl(
address,
session.userData
......
var builder = require("botbuilder");
var GSearch = require("../utils/gsearch");
var answers = require("../speech/answers");
var store = require("../store/suggestion");
module.exports = [
(session, args, next) => {
......@@ -9,17 +10,18 @@ module.exports = [
session.userData.name
])
);
setTimeout(() => next(), 700);
setTimeout(() => next(), 500);
},
session => {
const hist = ["China", "Java", "Rustlang", "goland", "car", "muddi"];
const msg = joinCard(session, hist, GSearch.getImgs(hist));
const topics = store.getRecentTopics(6, session.userData);
const msg = joinCard(session, topics, GSearch.getImgs(topics));
session.send(msg);
session.endDialog();
}
];
const joinCard = (session, topics, imgUrls) => {
console.log(imgUrls);
let topicCards = [];
topics.forEach((element, index) => {
topicCards.push(topicCard(session, element, imgUrls[index]));
......@@ -34,5 +36,11 @@ const topicCard = (session, topic, img) => {
return new builder.HeroCard(session)
.title(topic)
.images([builder.CardImage.create(session, img)])
.buttons([builder.CardAction.postBack(session, topic, "Learn More")]);
.buttons([
builder.CardAction.postBack(
session,
"suggestions:[" + topic + "]",
"Learn More"
)
]);
};
......@@ -5,8 +5,8 @@ const dialog = recognizer => {
let dialog = new builder.IntentDialog({
recognizers: [recognizer]
});
dialog.matches("vote", "vote")
dialog.matches(/^suggestions:\[*.*\]/, "suggestions");
dialog.matches("vote", "vote");
dialog.matches("settings", "settings");
dialog.matches("delete", "delete");
dialog.matches("changeName", "name");
......
const builder = require("botbuilder");
const GSearch = require("../utils/gsearch");
const store = require("../store/suggestion");
var base64 = require("base-64");
module.exports = [
(session, args, next) => {
const msg = suggCards(session, args);
if (!/^suggestions:\[*.*\]/.test(session.message.text)) {
const msg = suggCards(session, args);
const choices = [];
args.forEach(element => {
choices.push(JSON.stringify(element));
});
builder.Prompts.choice(session, msg, choices);
session.endDialog();
const choices = [];
args.forEach(element => {
choices.push(JSON.stringify(element));
});
builder.Prompts.choice(session, msg, choices);
session.endDialog();
} else {
const args = store.getWithTopic(
10,
session.message.text
.replace(/^suggestions:\[/, "")
.replace(/\]/, ""),
session.userData
);
const msg = suggCards(session, args);
const choices = [];
args.forEach(element => {
choices.push(JSON.stringify(element));
});
builder.Prompts.choice(session, msg, choices);
session.endDialog();
}
}
//(session, results, next) => {
// session.replaceDialog("vote", JSON.parse(results.response.entity));
//}
];
const suggCards = (session, args) => {
......
......@@ -30,14 +30,14 @@ module.exports = [
const welcomeCard = session => {
return new builder.HeroCard(session)
.title("Welcome to GlaDos!")
.title("Hi, I am C3Pbot")
.text(
"I am GlaDos, if you want to learn anything, just ask me and I will try to provide you with useful information! \n\n P.S. If you want to know what I can do just ask!"
"I am your personal learning advisor. Just tell me what you need to learn and I wil find the perfect learning resources for you \n\n P.S. You can also set reminders and learning goals."
)
.images([
builder.CardImage.create(
session,
"https://fat.gfycat.com/LightheartedSimilarGallinule.gif"
"https://gitlab.com/gett-hackathon/data-ki-bots/raw/master/c3pbot_logo.jpg"
)
]);
};
......@@ -20,8 +20,8 @@ var getRecentQueries = (count, userData) => {
var addHistory = (suggestions, userData) => {
if (!userData.recentQueries) userData.recentQueries = [];
userData.recentQueries = userData.recentQueries
.concat(suggestions)
userData.recentQueries = suggestions
.concat(userData.recentQueries)
.slice(0, 150);
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment