你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

使用 Azure CLI 将机器人连接到通道

通道是通信应用程序与机器人之间的连接。 在 Azure 注册的机器人可使用通道实现与用户的通信。 本文中的命令将机器人连接到各种通道。 有关详细信息,请参阅将机器人连接到通道

先决条件

示例命令

以下部分使用 Azure CLI 命令将机器人连接到通道。 这些示例使用ContosoBotRG资源组中命名为ContosoBot的机器人。

其中一些通道要求使用该命令与应用程序连接以进行身份验证。 如果出于测试目的运行这些命令,且不使用实际值,则测试可能会失败。

Direct Line

Direct Line 将机器人集成到移动应用、网页或其他应用程序中。 有关详细信息,请参阅关于 Direct Line

这些示例命令使用 az bot directline create 创建与 Direct Line 通道的连接。 该示例显示控制台中的连接并删除连接。

az bot directline create --resource-group ContosoBotRG --name ContosoBot --disablev1
az bot directline show --resource-group ContosoBotRG --name ContosoBot
az bot directline delete --resource-group ContosoBotRG --name ContosoBot

Office 365 电子邮件

可以使用 Office 365电子邮件使机器人能够与用户通信。 有关详细信息,请参阅将机器人连接到 Office 365邮件

这些示例命令使用 az bot email create 命令为 office 365电子邮件创建通道连接。 该示例显示控制台中的连接并删除连接。

az bot email create --resource-group ContosoBotRG --name ContosoBot \
   --email-address ContosoBot@outlook.com --password <password>
az bot email show --resource-group ContosoBotRG --name ContosoBot
az bot email delete --resource-group ContosoBotRG --name ContosoBot

Facebook

可以将机器人连接到 Facebook Messenger 和 Facebook Workplace。 它可以与这两个平台上的用户通信。 有关详细信息,请参阅将机器人连接到 Facebook

这些示例命令使用 az bot facebook create命令创建与 Facebook 通道的连接。 该示例显示控制台中的连接并删除连接。

az bot facebook create --resource-group ContosoBotRG --name ContosoBot --appid <myAppId> \
   --page-id <myPageId> --secret <secret> --token <token>
az bot facebook show --resource-group ContosoBotRG --name ContosoBot
az bot facebook delete --resource-group ContosoBotRG --name ContosoBot 

Microsoft Teams

可以将配置机器人与 Microsoft Teams 通信。 有关详细信息,请参阅将机器人连接到 Microsoft Teams

这些示例命令使用 az bot msteams create命令创建与 Microsoft Teams 通道的连接。 该示例显示控制台中的连接并删除连接。

az bot msteams create --resource-group ContosoBotRG --name ContosoBot --calling-web-hook https://www.contosoapp.com/ \
   --enable-calling 
az bot msteams show --resource-group ContosoBotRG --name ContosoBot 
az bot msteams delete --resource-group ContosoBotRG --name ContosoBot

Skype

可以配置机器人与 Skype 通信。 有关详细信息,请参阅将机器人连接到 Skype

这些示例命令使用 az bot skype create 创建与 Skype 通道的连接。 该示例显示控制台中的连接并删除连接。

az bot skype create --resource-group ContosoBotRG --name ContosoBot --enable-messaging --enable-screen-sharing
az bot skype show --resource-group ContosoBotRG --name ContosoBot 
az bot skype delete --resource-group ContosoBotRG --name ContosoBot

Slack

可以配置机器人,通过 Slack 让机器人与用户通信。 有关详细信息,请参阅将机器人连接到 Slack

这些示例命令使用 az bot slack create 创建与 Slack 通道的连接。 该示例显示控制台中的连接并删除连接。

az bot slack create --resource-group ContosoBotRG --name ContosoBot --client-id <clientid> \
   --client-secret <secret> --verification-token <token>
az bot slack show --resource-group ContosoBotRG --name ContosoBot
az bot slack delete --resource-group ContosoBotRG --name ContosoBot

SMS

这些示例命令使用 az bot sms create 创建与 SMS 通道的连接。 该示例显示控制台中的连接并删除连接。

az bot sms create --resource-group ContosoBotRG --name ContosoBot --account-sid <sid> --auth-token <token> \
   --phone <smsphonenumber> --is-validated
az bot sms show --resource-group BotRG
az bot sms delete --resource-group BotRG

Telegram

配置机器人,使其与使用 Telegram 消息传递应用的用户进行通信。 有关详细信息,请参阅将机器人连接到 Telegram

这些示例命令使用 az bot telegram create 创建与 Telegram 通道的连接。 该示例显示控制台中的连接并删除连接。

az bot telegram create --resource-group ContosoBotRG --name ContosoBot --access-token <token> --is-validated
az bot telegram show --resource-group ContosoBotRG --name ContosoBot 
az bot telegram delete --resource-group ContosoBotRG --name ContosoBot 

清理部署

如果创建了用于测试的资源组,请运行 az group delete 命令以删除资源组及其包含的所有内容。

az group delete --name ContosoBotRG

若要删除与通道的连接,请使用相应的 delete 命令。

本文中使用的 Azure CLI 命令

本文使用以下 Azure CLI 命令:

后续步骤