如何在我的visual studio代码中实现bot框架,以及在Visual Studio代码中使用bot框架需要安装哪些软件包?
这是一个非常广泛的问题,但我将尝试涵盖所有基础,包括Node / JS / TS和C#的答案。
你有4个选择:
npm install -g yo generator-botbuilder
yo botbuilder
。
按照步骤生成机器人。
Here's an explanation of the bot template options you can choose from
这将自动安装所有必需的包。 REAMDE.md
进行进一步的指导。所需的软件包实际上取决于您对机器人的处理方式。
JS / TS / Node:这是Basic Bot的package.json
片段,显示了它使用的所有软件包:
"dependencies": {
"botbuilder": "^4.2.0",
"botbuilder-ai": "^4.2.0",
"botbuilder-dialogs": "^4.2.0",
"botframework-config": "^4.2.0",
"dotenv": "^6.1.0",
"restify": "^7.2.3"
},
"devDependencies": {
"eslint": "^5.9.0",
"eslint-config-standard": "^12.0.0",
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-node": "^8.0.0",
"eslint-plugin-promise": "^4.0.1",
"eslint-plugin-standard": "^4.0.0",
"nodemon": "^1.18.6"
}
C#这是.csproj
文件中Basic Bot的NuGet包列表:
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.1.1" />
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.9" />
<PackageReference Include="Microsoft.Azure.CognitiveServices.ContentModerator" Version="0.12.1-preview" />
<PackageReference Include="Microsoft.Azure.CognitiveServices.Language" Version="1.0.1-preview" />
<PackageReference Include="Microsoft.Bot.Builder" Version="4.2.2" />
<PackageReference Include="Microsoft.Bot.Builder.AI.Luis" Version="4.2.2" />
<PackageReference Include="Microsoft.Bot.Builder.Azure" Version="4.2.2" />
<PackageReference Include="Microsoft.Bot.Builder.Dialogs" Version="4.2.2" />
<PackageReference Include="Microsoft.Bot.Builder.Integration.AspNet.Core" Version="4.2.2" />
<PackageReference Include="Microsoft.Bot.Configuration" Version="4.2.2" />
<PackageReference Include="Microsoft.Bot.Connector" Version="4.2.2" />
<PackageReference Include="Microsoft.Bot.Schema" Version="4.2.2" />
<PackageReference Include="Microsoft.Graph" Version="1.10.0" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.0-beta008">
从机器人目录(Node / JS / TS)中运行npm start
或在Visual Studio(C#)中按F5。默认情况下,机器人将在http://localhost:3978
上收听消息
使用BotFramework Emulator进行本地测试。请参阅下面的“Botframework Emulator - 入门”。
实际上,我建议尽可能多地使用文档和示例,并在必要时使用SDK参考。以下链接。
有两种方法:使用其中一个模板在Azure中创建一个Bot,然后下载文件或从头开始创建。选择必要的包取决于您的UseCase。但是,基本包应该是:
要在本地运行和测试bot,您还需要Bot框架模拟器。
希望有所帮助