Skip to content
This repository was archived by the owner on Jan 5, 2026. It is now read-only.

Commit 3f3b422

Browse files
committed
Merge branch 'rido/console' into u/rido/update-to-agentssdk
2 parents 683b292 + 347ba56 commit 3f3b422

2 files changed

Lines changed: 15 additions & 17 deletions

File tree

samples/javascript_nodejs/01.console-echo/consoleAdapter.js

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@
55

66
// @ts-check
77

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')
1011
const readline = require('readline');
11-
12+
const { text } = require('stream/consumers');
13+
const BotAdapter = CloudAdapter;
1214
/**
1315
* Lets a user communicate with a bot from a console window.
1416
*
@@ -36,7 +38,7 @@ class ConsoleAdapter extends BotAdapter {
3638
this.reference = {
3739
channelId: 'console',
3840
user: { id: 'user', name: 'User1' },
39-
bot: { id: 'bot', name: 'Bot' },
41+
agent: { id: 'bot', name: 'Bot' },
4042
conversation: { id: 'convo1', name: '', isGroup: false },
4143
serviceUrl: '',
4244
...reference
@@ -77,21 +79,17 @@ class ConsoleAdapter extends BotAdapter {
7779
output: process.stdout,
7880
terminal: false
7981
});
80-
rl.on('line', line => {
82+
rl.on('line', async line => {
8183
// 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,
9088
true
9189
);
9290
// Create context and run middleware pipe
9391
const context = new TurnContext(this, activity);
94-
this.runMiddleware(context, logic).catch(err => {
92+
await this.runMiddleware(context, logic).catch(err => {
9593
this.printError(err.toString());
9694
});
9795
});
@@ -125,8 +123,8 @@ class ConsoleAdapter extends BotAdapter {
125123
*/
126124
continueConversation(reference, logic) {
127125
// Create context and run middleware pipe
128-
const activity = TurnContext.applyConversationReference(
129-
{},
126+
const activity = new Activity(ActivityTypes.Message);
127+
activity.applyConversationReference(
130128
reference,
131129
true
132130
);

samples/javascript_nodejs/01.console-echo/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"url": "https://github.com/Microsoft/BotBuilder-Samples.git"
1717
},
1818
"dependencies": {
19-
"botbuilder-core": "~4.23.0",
19+
"@microsoft/agents-hosting": "~1.0.0",
2020
"dotenv": "^8.2.0",
2121
"path": "^0.12.7",
2222
"readline": "^1.3.0"

0 commit comments

Comments
 (0)