@microsoft/teamsfx 2.2.1-alpha.cc0bf9f6b.0 → 2.2.1-alpha.e2c6fac1b.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +88 -18
  2. package/package.json +4 -4
package/README.md CHANGED
@@ -547,24 +547,94 @@ Also see [TeamsFx class](#teamsfx-class) for furthur description.
547
547
 
548
548
  From `botbuilder@4.16.0`, `BotFrameworkAdapter` is deprecated, and `CloudAdapter` is recommended to be used instead. You can import `ConversationBot` from `BotBuilderCloudAdapter` to use the latest SDK implemented with `CloudAdapter`.
549
549
 
550
- ```ts
551
- const { BotBuilderCloudAdapter } = require("@microsoft/teamsfx");
552
- const ConversationBot = BotBuilderCloudAdapter.ConversationBot;
553
-
554
- const commandBot = new ConversationBot({
555
- // The bot id and password to create CloudAdapter.
556
- // See https://aka.ms/about-bot-adapter to learn more about adapters.
557
- adapterConfig: {
558
- MicrosoftAppId: config.botId,
559
- MicrosoftAppPassword: config.botPassword,
560
- MicrosoftAppType: "MultiTenant",
561
- },
562
- command: {
563
- enabled: true,
564
- commands: [new HelloWorldCommandHandler()],
565
- },
566
- });
567
- ```
550
+ 1. Install `@microsoft/teamsfx @^2.2.0`, `botbuilder @^4.18.0`, (and `@types/node @^14.0.0` for TS projects) via `npm install` as follows.
551
+
552
+ ```sh
553
+ npm install @microsoft/teamsfx
554
+ npm install botbuilder
555
+
556
+ // For TS projects only
557
+ npm install --save-dev @types/node
558
+ ```
559
+
560
+ 2. Update the import of `ConversationBot` and create a new `ConversationBot` as follows.
561
+
562
+ ```ts
563
+ import { HelloWorldCommandHandler } from "../helloworldCommandHandler";
564
+ import { BotBuilderCloudAdapter } from "@microsoft/teamsfx";
565
+ import ConversationBot = BotBuilderCloudAdapter.ConversationBot;
566
+ import config from "./config";
567
+
568
+ export const commandBot = new ConversationBot({
569
+ // The bot id and password to create CloudAdapter.
570
+ // See https://aka.ms/about-bot-adapter to learn more about adapters.
571
+ adapterConfig: {
572
+ MicrosoftAppId: config.botId,
573
+ MicrosoftAppPassword: config.botPassword,
574
+ MicrosoftAppType: "MultiTenant",
575
+ },
576
+ command: {
577
+ enabled: true,
578
+ commands: [new HelloWorldCommandHandler()],
579
+ },
580
+ });
581
+ ```
582
+
583
+ 3. If the project is using `restify` to create a server, please add the following line after `restify.createServer()`.
584
+
585
+ ```ts
586
+ server.use(restify.plugins.bodyParser());
587
+ ```
588
+
589
+ The complete code will be like
590
+
591
+ ```ts
592
+ // Create HTTP server.
593
+ const server = restify.createServer();
594
+ server.use(restify.plugins.bodyParser());
595
+ server.listen(process.env.port || process.env.PORT || 3978, () => {
596
+ console.log(`\nApp Started, ${server.name} listening to ${server.url}`);
597
+ });
598
+ ```
599
+
600
+ 4. If the project has `responseWrapper.ts`, please update the class `responseWrapper` to the class below.
601
+
602
+ ```ts
603
+ import { Response } from "botbuilder";
604
+
605
+ // A wrapper to convert Azure Functions Response to Bot Builder's Response.
606
+ export class ResponseWrapper implements Response {
607
+ socket: any;
608
+ originalResponse?: any;
609
+ headers?: any;
610
+ body?: any;
611
+
612
+ constructor(functionResponse?: { [key: string]: any }) {
613
+ this.socket = undefined;
614
+ this.originalResponse = functionResponse;
615
+ }
616
+
617
+ end(...args: any[]) {
618
+ // do nothing since res.end() is deprecated in Azure Functions.
619
+ }
620
+
621
+ header(name: string, value: any) {
622
+ this.headers[name] = value;
623
+ }
624
+
625
+ send(body: any) {
626
+ // record the body to be returned later.
627
+ this.body = body;
628
+ this.originalResponse.body = body;
629
+ }
630
+ status(status: number) {
631
+ // call Azure Functions' res.status().
632
+ return this.originalResponse?.status(status);
633
+ }
634
+ }
635
+ ```
636
+
637
+
568
638
 
569
639
  ## Next steps
570
640
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@microsoft/teamsfx",
3
- "version": "2.2.1-alpha.cc0bf9f6b.0",
3
+ "version": "2.2.1-alpha.e2c6fac1b.0",
4
4
  "description": "Microsoft Teams Framework for Node.js and browser.",
5
5
  "main": "dist/index.node.cjs.js",
6
6
  "browser": "dist/index.esm2017.js",
@@ -49,7 +49,7 @@
49
49
  "@azure/identity": "^2.0.1",
50
50
  "@azure/msal-browser": "^2.21.0",
51
51
  "@azure/msal-node": "^1.14.6",
52
- "@microsoft/adaptivecards-tools": "1.3.1-alpha.cc0bf9f6b.0",
52
+ "@microsoft/adaptivecards-tools": "1.3.1-alpha.e2c6fac1b.0",
53
53
  "@microsoft/microsoft-graph-client": "^3.0.1",
54
54
  "axios": "^0.27.2",
55
55
  "botbuilder": ">=4.18.0 <5.0.0",
@@ -70,7 +70,7 @@
70
70
  "@istanbuljs/nyc-config-typescript": "^1.0.1",
71
71
  "@microsoft/api-documenter": "^7.14.1",
72
72
  "@microsoft/api-extractor": "^7.19.4",
73
- "@microsoft/eslint-plugin-teamsfx": "0.0.2-alpha.cc0bf9f6b.0",
73
+ "@microsoft/eslint-plugin-teamsfx": "0.0.2-alpha.e2c6fac1b.0",
74
74
  "@microsoft/teams-js": "^2.7.1",
75
75
  "@rollup/plugin-json": "^4.1.0",
76
76
  "@types/chai": "^4.2.22",
@@ -130,7 +130,7 @@
130
130
  "webpack": "^5.62.1",
131
131
  "yargs": "^17.2.1"
132
132
  },
133
- "gitHead": "6e519c761f42d45cb12fdf37f32f7b89f3091fd2",
133
+ "gitHead": "e87fe38e538ed926fcdf171c6e429cd1f36af365",
134
134
  "publishConfig": {
135
135
  "access": "public"
136
136
  },