-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtaskDialog.js
More file actions
58 lines (40 loc) · 1.81 KB
/
taskDialog.js
File metadata and controls
58 lines (40 loc) · 1.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
const { ComponentDialog, TextPrompt, WaterfallDialog} = require('botbuilder-dialogs');
const taskId = 'taskDialog';
const fs = require('fs');
const jsonfile = require('jsonfile');
//Prompt for Task
const { TaskPrompt } = require('./prompts/taskPrompt')
const GET_TASK_PROMPT = 'taskPrompt';
class TaskDialog extends ComponentDialog {
constructor(id){
super(id);
this.initialDialogId = taskId;
this.addDialog(new TextPrompt('textPrompt'));
this.addDialog(new WaterfallDialog(taskId, [
this.promptForTask.bind(this),
this.captureTask.bind(this),
this.returnTask.bind(this)
]));
//Add Prompts
//GET_TASK_PROMPT Will validate user tasks
this.addDialog(new TaskPrompt(GET_TASK_PROMPT));
}
async promptForTask(step){
step.values.task = {};
step.values.profile = {};
step.values.profile = step.options.profile;
var tasks = jsonfile.readFileSync(`./Resources/Classes/${step.values.profile.class}/Teams/${step.values.profile.team}/tasks.json`);
let task_list = Object.keys(tasks);
return await step.prompt(GET_TASK_PROMPT, 'What task would you like to see?',task_list);
}
async captureTask(step){;
var tasks = jsonfile.readFileSync(`./Resources/Classes/${step.values.profile.class}/Teams/${step.values.profile.team}/tasks.json`);
step.values.task = tasks[`${step.result.value}`]
return await step.next();
}
async returnTask(step){
await step.context.sendActivity(`The description of the task is "${step.values.task.description}". The status of the task states "${step.values.task.status}". The task is due ${step.values.task.date}.`)
return await step.endDialog(step.values.task);
}
}
exports.TaskDialog=TaskDialog;