|
5 | 5 |
|
6 | 6 | // @ts-check |
7 | 7 |
|
8 | | -const botbuilderCore = require('botbuilder-core'); |
9 | | -const { BotAdapter, TurnContext, ActivityTypes } = botbuilderCore; |
| 8 | +// const botbuilderCore = require('botbuilder-core'); |
| 9 | +const { CloudAdapter, TurnContext } = require('@microsoft/agents-hosting'); |
| 10 | +const { ActivityTypes, Activity } = require('@microsoft/agents-activity') |
10 | 11 | const readline = require('readline'); |
11 | | - |
| 12 | +const { text } = require('stream/consumers'); |
| 13 | +const BotAdapter = CloudAdapter; |
12 | 14 | /** |
13 | 15 | * Lets a user communicate with a bot from a console window. |
14 | 16 | * |
@@ -36,7 +38,7 @@ class ConsoleAdapter extends BotAdapter { |
36 | 38 | this.reference = { |
37 | 39 | channelId: 'console', |
38 | 40 | user: { id: 'user', name: 'User1' }, |
39 | | - bot: { id: 'bot', name: 'Bot' }, |
| 41 | + agent: { id: 'bot', name: 'Bot' }, |
40 | 42 | conversation: { id: 'convo1', name: '', isGroup: false }, |
41 | 43 | serviceUrl: '', |
42 | 44 | ...reference |
@@ -77,21 +79,17 @@ class ConsoleAdapter extends BotAdapter { |
77 | 79 | output: process.stdout, |
78 | 80 | terminal: false |
79 | 81 | }); |
80 | | - rl.on('line', line => { |
| 82 | + rl.on('line', async line => { |
81 | 83 | // Initialize activity |
82 | | - const activity = TurnContext.applyConversationReference( |
83 | | - { |
84 | | - type: ActivityTypes.Message, |
85 | | - id: (this.nextId++).toString(), |
86 | | - timestamp: new Date(), |
87 | | - text: line |
88 | | - }, |
89 | | - this.reference, |
| 84 | + const activity = Activity.fromObject({type: ActivityTypes.Message, text: line}); |
| 85 | + |
| 86 | + activity.applyConversationReference( |
| 87 | + this.reference, |
90 | 88 | true |
91 | 89 | ); |
92 | 90 | // Create context and run middleware pipe |
93 | 91 | const context = new TurnContext(this, activity); |
94 | | - this.runMiddleware(context, logic).catch(err => { |
| 92 | + await this.runMiddleware(context, logic).catch(err => { |
95 | 93 | this.printError(err.toString()); |
96 | 94 | }); |
97 | 95 | }); |
@@ -125,8 +123,8 @@ class ConsoleAdapter extends BotAdapter { |
125 | 123 | */ |
126 | 124 | continueConversation(reference, logic) { |
127 | 125 | // Create context and run middleware pipe |
128 | | - const activity = TurnContext.applyConversationReference( |
129 | | - {}, |
| 126 | + const activity = new Activity(ActivityTypes.Message); |
| 127 | + activity.applyConversationReference( |
130 | 128 | reference, |
131 | 129 | true |
132 | 130 | ); |
|
0 commit comments