Integrating Microsoft Teams and Dialogflow using Azure Bot Service

Microsoft Teams and Dialogflow are integrated through the Azure bot service. Azure bot service is a managed bot development service that helps you connect to users via different channels.

Azure Bot creation

  • Create a Microsoft Azure Account and add a subscription to your account.
  • Create an Azure bot in Microsoft Azure.
    • Go to the Azure portal and click on the menu option.
    • Click on Create a resource.
    • Search for Azure bot.
    • Select Azure bot and click Create.
    • Fill in the details and click Review + create.
  • Once the bot is created, the following page appears:
  • Add teams to the Azure bot channel.
    • Go to the channels under the settings of the bot.
    • Add teams and click Save.
  • Get the bot embed URL
    • Click Get bot embed codes.
    • Get the HTTP part of the code as shown.
  • Paste the HTTP link on your browser to open your MS Teams bot

Get App ID and App Password

When Azure creates the Azure Bot resource, it stores the app password in Azure Key Vault. To get the password, follow the instructions below:

  • Open key vault resource that is created along with the Azure bot.
  • Click on “secrets” option under Settings.
  • Click on the “visible secret.”
  • If you get the “operation ‘list’ is not enabled in this key vault’s access policy” error we need to create an Access policy
    • Click on “Access Policies” under settings in the key vault resource.
    • Click on Add Access Policy.
    • Choose the configuration, for secret access select ‘Secret Management.
    • For secret permissions, Select “List” and Get.
    • Add the member you want to give access to Select principal.
    • Click “Add”, to add the policy and make sure to save the changes.
  • Click on the “latest version” and scroll to the bottom.
  • Click on “show secret value”, copy and store the App password.

Connecting Azure bot with Dialogflow

The Azure bot is connected to Dialogflow using the cloud function.

  • Add the cloud function trigger as the endpoint to the Azure bot.
    • Go to the Azure portal and click on the “Menu” option.
    • Click on All resources.
    • Click on the bot.
    • Go to “Configurations” under “Settings.”
    • Add the cloud function URL as Messaging endpoint and enable the streaming endpoint.
    • Click on “Apply” to save the endpoint.
  • BotFrameworkAdapter is used for sending and receiving the messages from the bot to the cloud function.

let adapter = new BotFrameworkAdapter({ appId: appId,
appPassword: appPassword,
adapter.processActivity (req, res, async (turnContext) => {
console.log(“turnContext.activity.type “)
if (turnContext.activity.type === ‘message’) { console.log(turnContext.activity);
if (turnContext.activity.text) { utterance turnContext.activity.text;

  • After receiving the messages from the user, the messages are forwarded to Dialogflow to get a reply using detect intent.
  • To get different messages in Teams (buttons, single select, Multi-select) Adaptive cards are used.

let adaptiveCard {
“$schema”: “”,
“type”: “AdaptiveCard”,
“version”: “1.0”,
“body”: [
“type”: “Input.ChoiceSet”,
“id”: “option”,
“style”: “compact”,
“isMultiSelect”: false,
“value”: “”,
“choices”: choice.
“actions”: [
“type”: “Action.Submit”,
“title”: “Submit”
const card CardFactory.adaptiveCard (adaptiveCard)
await turnContext.sendActivity({
attachments: [card]

That’s it! You’re ready to build, configure and test your own Azure bot and use it to integrate Microsoft teams and Dialogflow. Feel free to contact SpringML for more information or questions regarding integrating Teams with Dialogflow using Azure Bot Service.

Thought Leadership