Skip to content

Commit

Permalink
Fix event trigger issue > rel #148
Browse files Browse the repository at this point in the history
  • Loading branch information
thejoefriel committed Feb 18, 2019
1 parent 4b09ef8 commit b2aa602
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 10 deletions.
4 changes: 2 additions & 2 deletions client/src/Components/Pages/Chat/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ class Chat extends Component {
if (completedInfo && !conversation.length) {
// completed info then call the "event"
this.getIntent("event")
.then(result => console.log("result to server", result))
.then(result => console.log("event result to server", result))
.catch(err => console.log(err));
} else if (completedInfo && conversation.length) {
// do nothing
} else {
this.getIntent("start")
.then(result => console.log("result to server", result))
.then(result => console.log("start result to server", result))
.catch(err => console.log(err));
}
});
Expand Down
6 changes: 1 addition & 5 deletions server/database/dummy_data/conversation.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,9 @@ const buildConversation = async () => {
const moods = await Mood.find();

const conversations = [{
user: Nadia,
mood: moods[0],
completed: false,
}, {
user: Nadia,
mood: moods[1],
completed: true,
completed: false,
time: "2019-01-27",
}, {
user: Nadia,
Expand Down
8 changes: 7 additions & 1 deletion server/database/dummy_data/message.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,13 @@ const buildMessage = async () => {
}, {
conversation,
text: [
"Good to hear you found it intresting, lets hope the next lesson in the same!",
"Good to hear you found it intresting, lets hope the next lesson in the same!"
],
sender: "bot",
},
{
conversation,
text: [
"Remeber you can write down your thoughts on anything you want... it's a good practice to get into!",
],
sender: "bot",
Expand Down
4 changes: 3 additions & 1 deletion server/router/bot/dialogflowSessionClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,15 @@ module.exports = async (query, userId) => new Promise((resolve, reject) => {
},
};
} else if (query.event) {
console.log("EVENT REACHED")
// decide which event should be sent in the query
const event = await decideFlow(query.event, userId);
request = {
session: sessionPath,
resetContexts: event.eventTitle === "start",
queryInput: {
event: {
name: event.eventTitle,
name: event.intent,
languageCode,
},
},
Expand All @@ -116,6 +117,7 @@ module.exports = async (query, userId) => new Promise((resolve, reject) => {
};
}

console.log("REQUEST", request)
// Send request and log result
const responses = sessionClient.detectIntent(request);
resolve(responses);
Expand Down
3 changes: 3 additions & 0 deletions server/router/bot/startChat.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ module.exports = async (req, res) => {
const intent = result.intent.displayName;
const completedInfo = await checkUserInfo(id);

console.log("initial", intent)

if (!initialConversationIntents.includes(intent) && completedInfo) {
// STORAGE -------------------------------

Expand All @@ -37,6 +39,7 @@ module.exports = async (req, res) => {
// RENDER----------------------------------
// check if result comes back defined and includes intent
if (result && result.intent) {
console.log("intent", result.intent)
// send over array of fulfillment messages via pusher
pusher(`bot_${id}`, "bot-response", {
message: messageArr,
Expand Down
2 changes: 1 addition & 1 deletion server/router/bot/subjectFulfillment.js
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ exports.leastFavePositive = (agent) => {

exports.leastFaveDidWell = (agent) => {
agent.add(new Text("That's great to hear! What made it different this time?"));
agent.add(new Text("My work"));
agent.add(new Suggestion("My work"));
agent.add(new Suggestion("I overcame a challenge"));
agent.add(new Suggestion("Other"));
};
Expand Down

0 comments on commit b2aa602

Please sign in to comment.