-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathchoices.ts
41 lines (32 loc) · 1.04 KB
/
choices.ts
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
import { TurnContext, MemoryStorage, ConsoleAdapter, Activity } from 'botbuilder';
import { Topic, prettyConsole, WSTelemetry, consoleOnTurn, doTopic, Prompt, hasText, PromptArgs, ChoicePrompt, ChoicePromptArgs } from '../src/topical';
class Root extends Topic {
async onStart() {
await this.next();
}
async next() {
await this.startChild(ChoicePrompt, {
prompt: 'pick',
reprompt: 'please pick',
}, {
choices: ['one', 'two', 'three'],
});
}
async onDispatch() {
if (this.text)
await this.dispatchToChild();
}
async onChildEnd(child: ChoicePrompt) {
await this.send(`You picked "${child.return!.result.value!.value}".`)
await this.next();
}
}
Root.register();
// const wst = new WSTelemetry('ws://localhost:8080/server');
// Topic.telemetry = action => wst.send(action);
Topic.init(new MemoryStorage());
consoleOnTurn(
new ConsoleAdapter()
.use(prettyConsole),
context => doTopic(Root, context)
);