Calling and Meeting Bot provides basic functionality like Create Call, Join a call, Transfer/Redirect a call, Join a scheduled meeting and invite the participants by integrating cloud communications API Graph API.
-
Microsoft Teams is installed and you have an account
-
.NET Core SDK version 3.1
-
ngrok or equivalent tunnelling solution
-
Clone the repository
git clone https://github.com/OfficeDev/Microsoft-Teams-Samples.git
-
If you are using Visual Studio
- Launch Visual Studio
- File -> Open -> Project/Solution
- Navigate to
samples/bot-calling-meeting/csharp
folder - Select
CallingBotSample.csproj
file
-
Run ngrok - point to port 3978
ngrok http -host-header=rewrite 3978
THIS CODE IS PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
- Register an App in Azure using demo tenant
- Create
client_secret
for your app - Copy
client_Id
client_secret
for your app in Notepad. - Create a policy for a demo tenant user for creating the online meeting on behalf of that user using the following powershell script
Import-Module MicrosoftTeams
$userCredential = Get-Credential
Connect-MicrosoftTeams -Credential $userCredential
New-CsApplicationAccessPolicy -Identity “<<policy-identity/policy-name>>” -AppIds "<<azure-client-id>>" -Description "<<Policy-description>>"
Grant-CsApplicationAccessPolicy -PolicyName “<<policy-identity/policy-name>>” -Identity "<<object-id-of-the-user-to-whom-policy-need-to-be-granted >>"
ex:
Import-Module MicrosoftTeams
$userCredential = Get-Credential
Connect-MicrosoftTeams -Credential $userCredential
New-CsApplicationAccessPolicy -Identity Meeting-policy-dev -AppIds "d0bdaa0f-8be2-4e85-9e0d-2e446676b88c" -Description "Online meeting policy - contoso town"
Grant-CsApplicationAccessPolicy -PolicyName Meeting-policy-dev -Identity "782f076f-f6f9-4bff-9673-ea1997283e9c"
- Update
PolicyName
,azure-client-id
,policy-description
,object-id for user
in powershell script. - Run
Windows Powershell PSI
as an administrator and execute above script. - Run following command to verify policy is create successfully or not
Get-CsApplicationAccessPolicy -PolicyName Meeting-policy-dev -Identity "<<azure-client-Id>>"
- Add following Graph API Applications permissions to your Azure App.
Calls.AccessMedia.All
Calls.Initiate.All
Calls.InitiateGroupCall.All
Calls.JoinGroupCall.All
Calls.JoinGroupCallAsGuest.All
OnlineMeetings.ReadWrite.All
-
Grant Admin consent for the above permissions
-
Create
Bot Channel Registeration
in Azure account which have subscription enabled. -
Provide
App-Name
,Resource Group
and other required information -
Update messgaing endpoint
https://{yourngrok}/api/messages
-
Click on Create AppId and Secret
-
Enter
Client_Id and Client_Secret
of your azure app registered in demo tenant -
Add the Teams channel.
-
Select the Calling tab on the Teams channel page. Select Enable calling, and then update Webhook (for calling) with your HTTPS URL (
https://yourNgrok/api/callback
) where you receive incoming notifications, for examplehttps://contoso.com/teamsapp/api/callback
. -
Save your changes.
{
"MicrosoftAppId": "",
"MicrosoftAppPassword": "",
"BotBaseUrl": "https://{yourngrok}.ngrok.io",
"AzureAd": {
"Instance": "https://login.microsoftonline.com/",
"TenantId": "",
"ClientId": "",
"ClientSecret": ""
},
"Bot": {
"AppId": "",
"AppSecret": "",
"PlaceCallEndpointUrl": "https://graph.microsoft.com/v1.0",
"BotBaseUrl": "https://{yourngrok}.ngrok.io",
"GraphApiResourceUrl": "https://graph.microsoft.com",
"MicrosoftLoginUrl": "https://login.microsoftonline.com/"
},
"UserId": "",
"Users": [
{
"DisplayName": "",
"Id": ""
},
{
"DisplayName": "",
"Id": ""
},
{
"DisplayName": "",
"Id": ""
}
]
}
- Update
MicrosoftAppId, MicrosoftAppPassword, AppId, AppSecret
with your client_id and client_secret app registered in demo tenant. - Update
BotBaseUrl
with yourngrok
URL. - Update
UserId
andDisplayName
of the users from where you want to initiate the call and to whom you want to redirect or transfer the call
- Open your project in Visual Studio
- Go to
Manifest folder
- Update your Bot Id with client_Id and base URL with
ngrok URL
. - Zip your manifest along with two icons
- upload your manifest in your demo tenant for organisation in run your solution in Visual studio.