如何在我的visual studio代码中实现bot框架?

问题描述 投票:0回答:2

如何在我的visual studio代码中实现bot框架,以及在Visual Studio代码中使用bot框架需要安装哪些软件包?

botframework
2个回答
1
投票

这是一个非常广泛的问题,但我将尝试涵盖所有基础,包括Node / JS / TS和C#的答案。

Create a Bot

你有4个选择:

  1. 在Azure中创建机器人: 在Azure门户中,创建资源> Web App Bot>完成步骤并创建。 enter image description here 打开刚刚创建的“Web App Bot”资源> Build> Download Bot Source Code。 enter image description here
  2. [仅限JS / TS / Node]通过Yeoman创建机器人:(请参阅下面的JavaScript快速入门) npm install -g yo generator-botbuilder yo botbuilder。 按照步骤生成机器人。 Here's an explanation of the bot template options you can choose from 这将自动安装所有必需的包。 enter image description here
  3. [仅限C#]:在Visual Studio中使用VSIX模板:** 下载BotBuilder V4 VSIX template 在Visual Studio中创建一个新项目(您可以在上面的链接中获得有关每个bot模板的更多详细信息)enter image description here
  4. 克隆样本: 克隆一个these samples 我推荐Basic Bot:JS/Node / C#,有点复杂和简单的提示:JS/Node / C#,更方便 按照每个样本的REAMDE.md进行进一步的指导。
  5. 正如@TobiasC所提到的,从头开始创建它。我强烈建议不要走这条路,除非你知道你在做什么。从样本开始要容易得多。如果你想要一些非常简单的东西,使用Yeoman生成一个空机器人是一个很好的途径。

Packages

所需的软件包实际上取决于您对机器人的处理方式。

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">

Run the Bot

从机器人目录(Node / JS / TS)中运行npm start或在Visual Studio(C#)中按F5。默认情况下,机器人将在http://localhost:3978上收听消息

Testing and Debugging

使用BotFramework Emulator进行本地测试。请参阅下面的“Botframework Emulator - 入门”。

General

实际上,我建议尽可能多地使用文档和示例,并在必要时使用SDK参考。以下链接。

References

JavaScript Quickstart

C# Quickstart

Debug a Bot

Botframework Emulator - Getting Started

The Docs

TS SDK Reference

C# SDK Reference


1
投票

有两种方法:使用其中一个模板在Azure中创建一个Bot,然后下载文件或从头开始创建。选择必要的包取决于您的UseCase。但是,基本包应该是:

  • 的RESTify
  • botbuilder
  • botbuilder-人
  • botbuilder的对话框

要在本地运行和测试bot,您还需要Bot框架模拟器。

希望有所帮助

© www.soinside.com 2019 - 2024. All rights reserved.