Teams calling and meeting bot
Calling and Meeting bot provides basic functionalities like create a call, join a call, transfer or redirect a call, join a scheduled meeting and invite the participants by integrating cloud communications API Graph API.
Bots can interact with Teams calls and meetings using real time voice, video, and screen sharing. With Microsoft Graph APIs for calls and online meetings, Teams apps can now interact with users using voice and video to enhance the experience. These APIs allow you to add the following new features:
- Interactive Voice Response (IVR).
- Call control.
- Access to real time audio and video streams, including desktop and app sharing.
Create a bot and specify some additional information and permissions to use these Graph APIs in a Teams app.
This step-by-step guide helps you to create a bot with calling and meeting functionality. By the end of this tutorial you can achieve the following output:

Prerequisites
Ensure that you install the following tools and set up your development environment:
- Office 365 tenant
- Ngrok or equivalent tunneling solution
- Visual Studio 2019
- .NET Core SDK version 3.1
- Microsoft Teams with an account (not a guest account)
- Install Windows PowerShell by executing all the commands
Setup Calling and Meeting Bot
Register an application using App registration in the Microsoft Azure portal for your app to integrate with the Microsoft identity platform and call Microsoft Graph. Perform the following:
- Use ngrok to create a tunnel to your web server's endpoints.
- Create Azure Bot resource to register bot with Azure Bot Service.
- Create client secret that enables SSO authentication of the bot.
- Create a policy for a demo tenant user for creating the online meetings using PowerShell.
- Add API permissions for downstream calls.
- Create Bot channel registration in Azure account.
- Add Microsoft Teams channel to deploy the bot to a Teams channel.
- Add messaging endpoint to the ngrok tunnel you created.
Create ngrok tunnel:
Use ngrok to create a tunnel to your locally running web server's publicly available HTTPS endpoints. Run the following command in ngrok:
ngrok http --host-header=rewrite 3978
Register an App in Azure:
Sign in to the Azure portal using your personal Microsoft account.
Select the Azure Active Directory service, and then select App registrations from the left pane, and then select New registration.
Register an application page opens. Enter your application's registration information.
Enter a meaningful application Name that is displayed to users of the app.
In Supported account types, select the accounts you would like your application to support.
In Redirect URI (optional) field, select the type of app Web or Public client(mobile & desktop), and then enter the redirect URI for your application.
Note
For web applications, provide the base URI as
http://localhost:31544. For public client applications, provide the URI used by Azure AD to return token responses asmyapp://auth.Select Register.
To create client secret:
In Overview page of your bot, select Essentials and save the Application client ID (Microsoft App ID) for future reference.
In Manage, select Certificates & secrets section, then select Client secrets and select New client secret. The Add a client secret window appears.
Enter Description and select Add.
In the Value column, select Copy to clipboard and save the client secret ID for future reference.
Run PowerShell script to create a policy:
Create a policy for a demo tenant user for creating the online meetings using the following PowerShell script:
Note
Run Windows PowerShell PSI as an administrator and execute the script.
Replace
azure-client-idwith your Microsoft App ID of your bot andobject-idwith the Tenant ID of your account used to login to the Teams (Copy the link as shown in the following image and you can find the Tenant ID of your Teams account in the link obtained).
Add
PolicyName,azure-client-id,policy-description, andobject-idin the PowerShell script. Login with your Teams account when PowerShell prompts.
Run the following command in PowerShell to verify whether the policy is created successfully or not. Replace the policy name with your defined policy name.
Get-CsApplicationAccessPolicy -Identity “<<policy-identity/policy-name>>”
To add API permissions for downstream calls:
Note
Make sure that your account can grant admin consent for Microsoft. After adding permissions, select Grant admin consent for Microsoft to know the status of the consent.
In Manage pane of your bot, select API permissions.
Select Add a permission. Request API permissions window appears.
Select Microsoft APIs and select Microsoft Graph.
Select Application permissions, and then select permissions.
Add following Graph API Applications permissions to your Azure App and grant admin consent.
Calls.AccessMedia.AllCalls.Initiate.AllCalls.InitiateGroupCall.AllCalls.JoinGroupCall.AllCalls.JoinGroupCallAsGuest.AllOnlineMeetings.ReadWrite.All
Select Add permissions.
Create Bot channel registration in Azure account:
Open Azure portal.
Select Create a resource.
Search for Azure Bot in the search box.
Select Azure Bot.
Select Create.
Enter bot handle name in Bot handle field.
Select your Subscription from the dropdown list.
Select your Resource group from the dropdown list.
To create a new resource group, select Create new, enter resource name, select OK, and select required location from New resource group location dropdown list.
Select Type of App as Multi Tenant for Microsoft App ID.
Note
In
Creation typeof Microsoft App ID section,Create new Microsoft App IDis already selected to create a new bot. You can also selectUse existing app registration, if you've already registered a bot. Enter Microsoft App ID inExisting app idfield, and enter value inExisting app passwordfield.Select Use existing app registration and enter App ID and App secret of your Azure app registered in demo tenant.
Select Review + create.
If the validation passes, select Create.
It takes a few moments for your bot service to be provisioned.
Select Go to resource. The bot and the related resources are listed in the resource group.
Now your Azure bot has been created.
To add the Microsoft Teams channel:
Go to Home.
Open your bot, which is listed in the Recent resources section.
Select Channels in the left pane and select Microsoft Teams
from the list of available channels.
Select the checkbox to accept the terms of service and select Agree.
Select Save.
Select Microsoft Teams and select Calling tab on Teams channel page.
Select Enable calling, and then update Webhook with your HTTPS ngrok URL (https://yourNgrok/api/callback) and add
/api/callbackat the end.
Select Save.
To add messaging endpoint:
Go to Home page of your bot and select Configuration under Settings from the left pane.
Go to ngrok.
Copy the HTTPS URL (https to io) as shown in the following image:
In Messaging endpoint, add the HTTPS URL available from ngrok and at the end of the URL add /api/messages.
Select Apply.
You have successfully set up a bot in Azure Bot Service and now you need to set up bot service connection.
Update and create Teams App Package
Configure the bot sample to understand how to authenticate conversational bot in Microsoft Teams and create the Teams App Package and upload it to the organization.
- Update appsettings.json in Visual Studio.
- Update manifest.json in Visual Studio and compress it to the zip file in File explorer.
Update appsettings for calling Bot:
Go to the repo https://github.com/OfficeDev/Microsoft-Teams-Samples.git.
Select Code and select the dropdown.
Select Download ZIP.
Ensure to note the Path of the repository that is downloaded.
In the File Explorer, go to Microsoft-Teams-Samples-main > samples > bot-calling-meeting > csharp folder.
Open the appsettings.json file in Visual Studio and update configuration for the bot.
You can obtain the
MicrosoftAppIdfrom the bot's configuration page. TheMicrosoftAppPasswordis the Value for client secret ID that you saved previously.You can obtain the
Tenant IDorUserIdfrom the link of the account used to login to the Teams. Follow the path in the image to get the link fortenant id.
You can obtain the
DisplayNameandUserIdfrom Microsoft Graph Explorer site.- Login to the page using your Teams account and add
Usersat the end of the URl in the search box and select Run query. - Display names and User IDs linked to your account are generated.
- Pick any three accounts and add them to the
DisplayNameandUserIdin appsettings.json.
- Login to the page using your Teams account and add
Note
Tenant IDorUserIdof the Teams account denotes from where you want to initiate the call, andDisplayNameandUserIdof the users denotes to whom you want to redirect or transfer the call.Replace
MicrosoftAppId,ClientId,AppIdwith your Application (client) ID andMicrosoftAppPassword,ClientSecret, andAppSecretwith your Value.Update
BotBaseUrlwith yourngrokURL.Update
Tenant IDandUserId.Update
DisplayNameandUserId.
Select Save.
To update manifest:
In the File Explorer, go to Microsoft-Teams-Samples-main > samples > bot-calling-meeting > csharp > Manifest folder.
Open the
manifest.jsonfile in Visual Studio.In the
manifest.jsonfile, find {id}, {BotId} and add your Microsoft App ID.Add your ngrok url in validDomains excluding https:// and save.
Zip the contents of the Manifest folder to create
manifest.zip.Note
The
manifest.zipshouldn't contain any extra folders in it. It should havemanifest jsonsource file,coloricon, andoutlineicon inside the zip folder. Upload your manifest in your demo tenant for organization or your Teams account and run your solution in Visual Studio.Go to Teams.
To upload
manifest.zip, select Store > Manage your apps > Upload a custom app and openmanifest.zipfrom the repo folder in File explorer.Select Add to install Calling bot in Teams.
You can interact with this bot after debugging in Visual Studio.
Interaction with the Calling and Meeting Bot
Bot allows you to access services and content in a dedicated space within a channel or in a chat.
Follow the steps to use the bot:
In the left pane of the Teams, select the ellipses ●●● and choose your app from the list.
Bot will send welcome Text with Adaptive Card as shown below.
You can ask bot to Create a call.
You can ask bot to Transfer the call.
You can ask bot to Schedule a Meeting and invite the participants.
Complete challenge
Did you come up with something like this?

Congratulations!
You've completed the tutorial to get started with bot calling and meeting app for Microsoft Teams.
Have an issue with this section? If so, please give us some feedback so we can improve this section.
Feedback
Submit and view feedback for