创建 botCreate a bot

重要

本节中的文章基于 v3 Bot 框架 SDK。The articles in this section are based on the v3 Bot Framework SDK. 如果您要查找当前文档(SDK 版本4.6 或更高版本),请参阅 "对话 bot " 部分。If you're looking for current documentation (version 4.6 or later of the SDK) see the Conversational Bots section.

使用 Microsoft Bot 框架创建的所有 bot 都已配置好并可在 Microsoft 团队中工作。All bots created using the Microsoft Bot Framework are configured and ready to work in Microsoft Teams.

有关 bot 的一般信息,请参阅Bot 框架文档See the Bot Framework Documentation for general information on bots.

为 Microsoft Teams 创建自动程序Create a bot for Microsoft Teams

团队应用程序 Studio是一种可帮助创建你的 bot 的工具,以及一个引用你的 bot 的应用程序包。Teams App Studio is a tool that can help create your bot, and an app package that references your bot. 它还包含 React 控件库和卡的可配置示例。It also contains a React control library and configurable samples for cards. 请参阅开始使用 Teams App StudioSee Getting started with Teams App Studio. 下面的步骤假定您要手动配置你的 bot,而不是使用团队应用程序 StudioThe steps that follow assume that you are hand configuring your bot and not using Teams App Studio.

  1. 使用此链接创建 bot: https://dev.botframework.com/bots/new。Create the bot using this link: https://dev.botframework.com/bots/new. 创建自动程序后,请确保从特色频道列表中将 Microsoft Teams 添加为频道。Be sure to add Microsoft Teams as a channel from the featured channels list after creating your bot. 如果你已经创建应用程序包/清单,请随意重复使用你生成的任何 Microsoft 应用 ID。Feel free to re-use any Microsoft App ID you generated if you've already created your app package/manifest.

    Bot Framework 注册页面

备注

如果您不想在 Azure 中创建你的 bot,则必须使用此链接创建新的 bot: https://dev.botframework.com/bots/new。If you do not wish to create your bot in Azure, you must use this link to create a new bot: https://dev.botframework.com/bots/new. 如果你改为单击 Bot 框架门户中的 "创建机器人" 按钮,则会改为在 Microsoft Azure 中创建你的 botIf you click on the Create a bot button in the Bot Framework portal instead, you will create your bot in Microsoft Azure instead.

  1. 使用 " Microsoft bot. 团队" NuGet 包、 bot 框架 SDKbot 连接器 API构建机器人。Build the bot using the Microsoft.Bot.Connector.Teams NuGet package, the Bot Framework SDK, or the Bot Connector API. 另请参阅 Bot 框架示例See also Bot Framework samples.

  2. 使用Bot 框架仿真程序测试机器人。Test the bot using the Bot Framework Emulator.

  3. 将机器人部署到云服务,如Microsoft AzureDeploy the bot to a cloud service, such as Microsoft Azure. 也可以在本地运行应用程序,并使用隧道服务(例如, ngrok )为你的 bot 公开 https://终结https://45az0eb1.ngrok.io/api/messages点。Alternatively, run your app locally and use a tunneling service such ngrok to expose an https:// endpoint for your bot, such as https://45az0eb1.ngrok.io/api/messages.

备注

Bot 和 Microsoft AzureBots and Microsoft Azure

从2017年12月到,已针对在 Microsoft Azure 中注册 bot 而优化了 Bot 框架门户。As of December, 2017, the Bot Framework portal is optimized for registering bots in Microsoft Azure. 以下是几个注意事项:Here are some things to know:

  • 在 Azure 中注册的自动程序的 Microsoft Teams 频道是免费的。The Microsoft Teams channel for bots registered on Azure is free. 通过团队频道发送的邮件不会计送到这些 bot 的已消耗邮件。Messages sent over the Teams channel will not count towards the consumed messages for the bot.
  • 虽然可以在不使用 Azure 的情况下创建新的 Bot 框架自动程序,但必须使用该https://dev.botframework.com/bots/new)URL (不会再在 Bot 框架门户中公开)。While it's possible to create a new Bot Framework bot without using Azure, you must use that URL (https://dev.botframework.com/bots/new), which is no longer exposed in the Bot Framework portal.
  • 当您在 Bot 框架(如 "消息终结点")中编辑 bot 的属性时,这在首次开发 bot 时很常见,尤其是在使用ngrok时,您将看到 "迁移状态" 列和一个蓝色的 "迁移" 按钮,该按钮将转到 Microsoft Azure 门户。When you edit the properties of an existing bot in the list of your bots in Bot Framework such as its "messaging endpoint," which is common when first developing a bot, especially if you use ngrok, you will see "Migration status" column and a blue "Migrate" button that will take you into the Microsoft Azure portal. 请勿单击 "迁移" 按钮,除非您要执行的操作;而是单击 bot 的名称,然后可以编辑其属性:Don't click on the "Migrate" button unless that's what you want to do; instead, click on the name of the bot and you can edit its properties:
    编辑自动程序属性Edit Bot Properties
  • 如果你使用 Microsoft Azure 注册你的 bot,则无需在 Microsoft Azure 上托管你的 bot 代码。If you register your bot using Microsoft Azure, your bot code does not need to be hosted on Microsoft Azure.
  • 如果你使用 Microsoft Azure 门户注册自动程序,则必须拥有 Microsoft Azure 帐户。If you do register a bot using Microsoft Azure portal, you must have a Microsoft Azure account. 你可以免费创建一个You can create one for free. 若要在创建一个时验证你的身份,你必须提供一个信用卡,但不会被收取费用;在 Microsoft 团队中,始终可以免费创建和使用 bot。To verify your identity when you create one, you must provide a credit card, but it won't be charged; it's always free to create and use bots with Microsoft Teams.
  • 现在,你可以使用应用程序 Studio 直接在 Microsoft 团队中注册/更新 App 和机器人信息。You can now use App Studio to register/update app and bot information directly within Microsoft Teams. 您只需使用 Microsoft Azure 门户添加/配置其他机器人框架通道(如直接线路、Web 聊天、Skype 和 Facebook Messenger)。You'll only have to use the Microsoft Azure portal for adding/configuring other Bot Framework channels such as Direct Line, Web Chat, Skype, and Facebook Messenger.