Connect your bot to channels with Azure CLI
A channel is a connection between a communication application and a bot. A bot, registered with Azure, uses channels to enable communication with users. The commands in this article connect a bot to various channels. For more information, see Connect a bot to channels.
Prerequisites
Use the Bash environment in Azure Cloud Shell. For more information, see Quickstart for Bash in Azure Cloud Shell.
If you prefer to run CLI reference commands locally, install the Azure CLI. If you're running on Windows or macOS, consider running Azure CLI in a Docker container. For more information, see How to run the Azure CLI in a Docker container.
If you're using a local installation, sign in to the Azure CLI by using the az login command. To finish the authentication process, follow the steps displayed in your terminal. For other sign-in options, see Sign in with the Azure CLI.
When you're prompted, install the Azure CLI extension on first use. For more information about extensions, see Use extensions with the Azure CLI.
Run az version to find the version and dependent libraries that are installed. To upgrade to the latest version, run az upgrade.
- A bot deployed to Azure. If you don't have one yet, see Tutorial: Provision a bot in Azure and Tutorial: Publish a basic bot.
Sample commands
The following sections use Azure CLI commands to connect a bot to a channel. These examples use a bot named ContosoBot
in the ContosoBotRG
resource group.
Some of these channels require the command to connect with the application to authenticate. If you're running these commands for testing purposes, they can fail if you don't use real values.
Direct Line
Direct Line integrates your bot into a mobile app, web page, or other applications. For more information, see About Direct Line.
These sample commands create a connection to the Direct Line channel by using az bot directline create. The example shows the connection in the console and deletes the connection.
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 email
You can enable your bot to communicate with users by using Office 365 email. For more information, see Connect a bot to Office 365 email.
These sample commands create a connection to the channel for Office 365 email by using az bot email create. The example shows the connection in the console and deletes the connection.
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
You can connect your bot to both Facebook Messenger and Facebook Workplace. It can communicate with users on both platforms. For more information, see Connect a bot to Facebook.
These sample commands create a connection to the channel for Facebook by using az bot facebook create. The example shows the connection in the console and deletes the connection.
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
You can configure your bot to communicate with Microsoft Teams. For more information, see Connect a bot to Microsoft Teams.
These sample commands create a connection to the channel for Microsoft Teams by using az bot msteams create. The example shows the connection in the console and deletes the connection.
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
You can configure your bot to communicate with Skype. For more information, see Connect a bot to Skype.
These sample commands create a connection to the channel for Skype by using az bot skype create. The example shows the connection in the console and deletes the connection.
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
You can configure your bot to communicate with users through Slack. For more information, see Connect a bot to Slack.
These sample commands create a connection to the channel for Slack by using az bot slack create. The example shows the connection in the console and deletes the connection.
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
These sample commands create a connection to the channel for SMS by using az bot sms create. The example shows the connection in the console and deletes the connection.
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
You can configure your bot to communicate with users through Telegram. For more information, see Connect a bot to Telegram.
These sample commands create a connection to the channel for Telegram by using az bot telegram create. The example shows the connection in the console and deletes the connection.
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
Clean up deployment
If you created a resource group for testing, run the az group delete command to remove the resource group and everything it contains.
az group delete --name ContosoBotRG
To remove a connection to a channel, use the appropriate delete command.
Azure CLI commands used in this article
This article uses the following Azure CLI commands:
- az bot directline create
- az bot directline delete
- az bot directline show
- az bot email create
- az bot email delete
- az bot email show
- az bot facebook create
- az bot facebook delete
- az bot facebook show
- az bot msteams create
- az bot msteams delete
- az bot msteams show
- az bot skype create
- az bot skype delete
- az bot skype show
- az bot slack create
- az bot slack delete
- az bot slack show
- az bot sms create
- az bot sms delete
- az bot sms show
- az bot telegram create
- az bot telegram delete
- az bot telegram show
- az group delete