Commit 10ab3ccc authored by Tammo Ronke's avatar Tammo Ronke

not defined

parent 6150f9f7
......@@ -63,25 +63,16 @@ bot.recognizer(recognizer);
* Dialogs
*/
bot.dialog("welcome", require("./dialogs/welcome"));
bot.dialog("join", require("./dialogs/join"));
<<<<<<< HEAD
bot.dialog("openSettings", require("./dialogs/settings")).triggerAction({
bot.dialog("settings", require("./dialogs/settings")).triggerAction({
matches: "settings"
});
=======
bot
.dialog("learning", require("./dialogs/learning"))
.triggerAction({ matches: "learn" });
bot
.dialog("debug", session => {
session.beginDialog("welcome");
})
.triggerAction({
matches: "settings"
});
>>>>>>> 41a92cd8dcc059fc54be4ac7ab4ea9e199e7e2ab
bot.on("conversationUpdate", activity => {
if (activity.membersAdded) {
activity.membersAdded.forEach(identity => {
......
var builder = require("botbuilder");
module.exports = [(session, args, next) => {}];
const joinCard = session => {
return new builder.Message(session)
.attachmentLayout(builder.AttachmentLayout.carousel)
.attachments(cards);
};
const topicCard = topic => {
return new builder.HeroCard(session)
.title(topic)
.images([
builder.CardImage.create(
session,
"https://fat.gfycat.com/LightheartedSimilarGallinule.gif"
)
])
.buttons([
builder.CardAction.postBack(session, "load." + topic, "More")
]);
};
......@@ -2,35 +2,94 @@ var builder = require("botbuilder");
module.exports = [
(session, args, next) => {
const choices = ["deleteUserData", "changeName"];
var reply = new builder.Message(session).addAttachment(
const choices = [
"Confirm deletion of User",
"Confirm change of Name to"
];
const reply = new builder.Message(session).addAttachment(
settingsCard(session)
);
builder.Prompts.choice(session, reply, choices);
},
(session, results, next) => {
switch (results.response) {
case "deleteUserData": {
break;
session.dialogData.confirm = results.response.entity;
if (results.response.entity !== "Confirm change of Name to") {
const choices = ["true", "false"];
const reply = new builder.Message(session).addAttachment(
confirmationCard(session, results.response.entity)
);
builder.Prompts.choice(session, reply, choices);
} else {
next();
}
},
(session, results, next) => {
if (results.response && results.response.entity === "true")
switch (session.dialogData.confirm) {
case "Confirm deletion of User": {
session.userData = {};
session.replaceDialog("welcome");
break;
}
}
case "changeName": {
break;
else {
switch (session.dialogData.confirm) {
case "Confirm change of Name to": {
builder.Prompts.text(session, "How should I call you?");
break;
}
default: {
session.replaceDialog("settings");
}
}
}
session.send(JSON.stringify(results));
},
(session, results, next) => {
session.dialogData.name = results.response;
const choices = ["true", "false"];
const reply = new builder.Message(session).addAttachment(
confirmationCard(session, `So, your name is ${results.response}?`)
);
builder.Prompts.choice(session, reply, choices);
},
(session, results, next) => {
if (results.response.entity === "true") {
session.send(
`Ok, from now on I will call you ${session.dialogData.name}.`
);
session.userData.name = session.dialogData.name;
session.endDialog();
}
session.replaceDialog("settings");
}
];
const settingsCard = session => {
return new builder.HeroCard(session)
.title("Settings")
.text(`Name: ${session.userData.name}`)
.buttons([
builder.CardAction.postBack(
session,
"deleteUserData",
"Confirm deletion of User",
"Delete User"
),
builder.CardAction.postBack(session, "changeName", "Change Name")
builder.CardAction.postBack(
session,
"Confirm change of Name to",
"Change Name"
)
]);
};
const confirmationCard = (session, title) => {
return new builder.HeroCard(session)
.title(title)
.buttons([
builder.CardAction.postBack(session, "true", "Yes"),
builder.CardAction.postBack(session, "false", "No")
]);
};
var builder = require("botbuilder");
module.exports = [
session => {
const msg = new builder.Message(session).addAttachment(
welcomeCard(session)
(session, args, next) => {
if (session.userData === {} || session.userData) {
const msg = new builder.Message(session).addAttachment(
welcomeCard(session)
);
session.send(msg);
setTimeout(() => next(), 800);
} else {
session.replaceDialog("join");
}
},
(session, results, next) => {
builder.Prompts.text(session, "How should I call you?");
},
(session, results, next) => {
session.send(
`Ok, from now on I will call you ${
results.response
}. \n\n But you can change it all the time in the settings.`
);
session.send(msg);
session.userData.name = results.response;
session.endDialog();
}
];
......@@ -14,12 +30,12 @@ const welcomeCard = session => {
return new builder.HeroCard(session)
.title("Welcome to GlaDos!")
.text(
"I am GlaDos, if you want to learn anything, just ask me and I will try to provide you with useful information!"
"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!"
)
.images([
builder.CardImage.create(
session,
"https://assets.gitlab-static.net/uploads/-/system/project/avatar/6142850/ezgif-4-9305c3684f.gif"
"https://fat.gfycat.com/LightheartedSimilarGallinule.gif"
)
]);
};
......@@ -6,6 +6,7 @@
"dependencies": {
"botbuilder": "^3.13.1",
"botbuilder-azure": "^3.0.4",
"free-google-image-search": "^1.0.0",
"restify": "^5.0.0"
},
"devDependencies": {
......@@ -14,8 +15,7 @@
},
"scripts": {
"bot": "node ./app.js",
"clean":
"rm -rf ./dist && rm -rf ./test && rm -rf ./node_modules && rm -f ./yarn.lock && rm -f ./package-lock.json && rm -rf ./yarn-error.log && clear && echo -e \"\\e[1;31mFinished cleaning!\\e[0m\""
"clean": "rm -rf ./dist && rm -rf ./test && rm -rf ./node_modules && rm -f ./yarn.lock && rm -f ./package-lock.json && rm -rf ./yarn-error.log && clear && echo -e \"\\e[1;31mFinished cleaning!\\e[0m\""
},
"author": "barbra",
"license": "ISC"
......
......@@ -22,6 +22,7 @@ npm manifest:
"dependencies": {
"botbuilder": "^3.13.1",
"botbuilder-azure": "^3.0.4",
"free-google-image-search": "^1.0.0",
"restify": "^5.0.0"
},
"devDependencies": {
......@@ -30,8 +31,7 @@ npm manifest:
},
"scripts": {
"bot": "node ./app.js",
"clean":
"rm -rf ./dist && rm -rf ./test && rm -rf ./node_modules && rm -f ./yarn.lock && rm -f ./package-lock.json && rm -rf ./yarn-error.log && clear && echo -e \"\\e[1;31mFinished cleaning!\\e[0m\""
"clean": "rm -rf ./dist && rm -rf ./test && rm -rf ./node_modules && rm -f ./yarn.lock && rm -f ./package-lock.json && rm -rf ./yarn-error.log && clear && echo -e \"\\e[1;31mFinished cleaning!\\e[0m\""
},
"author": "barbra",
"license": "ISC"
......@@ -487,6 +487,10 @@ Lockfile:
version "1.2.1"
resolved "https://registry.yarnpkg.com/formidable/-/formidable-1.2.1.tgz#70fb7ca0290ee6ff961090415f4b3df3d2082659"
free-google-image-search@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/free-google-image-search/-/free-google-image-search-1.0.0.tgz#7a6278be8edc646ed96a712251db32671724c815"
generate-function@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/generate-function/-/generate-function-2.0.0.tgz#6858fe7c0969b7d4e9093337647ac79f60dfbe74"
......
......@@ -444,6 +444,10 @@ formidable@^1.0.17:
version "1.2.1"
resolved "https://registry.yarnpkg.com/formidable/-/formidable-1.2.1.tgz#70fb7ca0290ee6ff961090415f4b3df3d2082659"
free-google-image-search@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/free-google-image-search/-/free-google-image-search-1.0.0.tgz#7a6278be8edc646ed96a712251db32671724c815"
generate-function@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/generate-function/-/generate-function-2.0.0.tgz#6858fe7c0969b7d4e9093337647ac79f60dfbe74"
......
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