page_type | description | products | languages | extensions | urlFragment | ||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
sample |
Teams catering bot demonstrating how to use Universal bots in Teams |
|
|
|
officedev-microsoft-teams-samples-bot-teams-catering-csharp |
Bot Framework v1.4 TeamsCateringBot sample.
This bot has been created using Bot Framework, it shows how to create a simple bot that accepts food order using Adaptive Cards V2.
Teams Catering bot is a sample app that provides an experience of ordering food and drinks. This sample makes use of Teams platform capabilities like Universal Bots
to bring a restaurant ordering feature to life.
-
.NET Core SDK version 6.0
determine dotnet version
dotnet --version
-
Ngrok (For local environment testing) Latest (any other tunneling software can also be used)
-
Teams Microsoft Teams is installed and you have an account
-
Register a new application in the Azure Active Directory – App Registrations portal.
-
Go to App registrations and create a new app registration in a different tab.
-
Register an application.
- Fill out name and select third option for supported account type and click "Register".
NOTE: Copy and paste the App Id and Tenant ID somewhere safe. You will need it in a future step.
- Create Client Secret.
- Navigate to the "Certificates & secrets" blade and add a client secret by clicking "New Client Secret".
NOTE: Copy and paste the secret somewhere safe. You will need it in a future step:
-
-
Setup for Bot
-
Register a bot with Azure Bot Service, following the instructions here.
-
Ensure that you've enabled the Teams Channel
-
While registering the bot, use
https://<your_ngrok_url>/api/messages
as the messaging endpoint. -
Register a bot with Azure Bot Service, following the instructions here.
-
Ensure that you've enabled the Teams Channel
-
While registering the bot, use
https://<your_ngrok_url>/api/messages
as the messaging endpoint.
Go to the created resource, navigate to channels and add "Microsoft Teams" and “Web chat” channels:
NOTE: When you create your bot you will create an App ID and App password - make sure you keep these for later.
-
-
-
Create Azure Cosoms Database account**
- Create an Azure Cosmos DB account
- Choose an existing resource group or create a new one.
- Choose an account name for your cosmos db account.
- Select
Azure Cosmos DB for NoSQL
as API.
Create an Azure Cosmos DB account:
Azure Cosmos DB for NoSQL:
- Create an Azure Cosmos DB account
-
Get Cosmos DB enpoint
Uri
and read writePrimary Key
- Open your newly created Cosmos DB account. Navigate to "Keys" section.
- Copy paste your URI and read write Primary_Key for further use.
-
Setup NGROK
-
Run ngrok - point to port 3978
# ngrok http -host-header=rewrite 3978
- Setup for code
-
Clone the repository
git clone https://github.com/OfficeDev/Microsoft-Teams-Samples.git
-
Run the bot from a terminal or from Visual Studio:
A) From a terminal, navigate to
samples/bot-teams-catering/csharp
# run the bot dotnet run
B) Or from Visual Studio
- Launch Visual Studio
- File -> Open -> Project/Solution
- Navigate to
samples/bot-teams-catering/csharp
folder - Select
Catering.csproj
file - Press
F5
to run the project
-
Update the appsettings.json files.
-
"MicrosoftAppId:
<<Your Microsoft Bot_Id>>
-
"MicrosoftAppPassword":
<<Your Microsoft Bot_Secret>>
-
"CosmosEndpointUri":
<<Your Cosmos DB enpoint uri>>
-
"CosmosKey":
<<Your Cosmos DB read-write Primary_Key>>
-
"BotServiceUrl:
<<YourBotServiceUrl>>/v3
-
NOTE: The App id to be installed into Teams meeting can be retrieved using the graph explorer. As this sample uses the same app to be added to the teams meeting, app needs to be installed into Teams (follow step 4 on how to package and install the app to teams) and use the app's ID generated by Teams (different from the external ID). For more information, see the List teamsApp refernce article
NOTE: The Bot Service Url needs to be dynamically fetched (and stored) from the Team. Recommendation is to capture the serviceUrl from the bot Payload and later re-use it to send proactive messages. eg: https://smba.trafficmanager.net/amer/v3
7. Setup Manifest for Teams
-
This step is specific to Teams.
- Edit the
manifest.json
contained in theManifest
folder to replace your Microsoft App Id (that was created when you registered your bot earlier) everywhere you see the place holder string<<Your Microsoft App Id>>
(depending on the scenario the Microsoft App Id may occur multiple times in themanifest.json
) - Edit the
manifest.json
forwebsiteUrl
,privacyUrl
,termsOfUseUrl
insideDeveloperTabs
. Replace<yourNgrok.ngrok.io>
with base Url domain. E.g. if you are using ngrok it would behttps://1234.ngrok.io
then your domain-name will be1234.ngrok.io
. - Edit the
manifest.json
forvalidDomains
with base Url domain. E.g. if you are using ngrok it would behttps://1234.ngrok.io
then your domain-name will be1234.ngrok.io
. - Zip up the contents of the
Manifest
folder to create amanifest.zip
(Make sure that zip file does not contains any subfolder otherwise you will get error while uploading your .zip package) - Upload the
manifest.zip
to Teams (In Teams Apps/Manage your apps click "Upload an app". Browse to and Open the .zip file. At the next dialog, click the Add button.) - Add the app to personal/team/groupChat scope (Supported scopes)
- Edit the
Install App:
Select your order UI:
Confirm selected item UI:
Order confirmed:
Select next order UI:
Recent order list UI:
- Ping the bot in 1:1 or channel scope
- Bot will send an Adaptive card to choose food.
- Follow the sequential process of selecting food, drink and submit your choices.
- Bot will keep on updating the adaptive card on each submission.
- Submit your final order on confimation card.
- Bot will update the card to order confirmed card.
- You can click on "Recent Orders" button.
- Bot will update the card to recent orders card.
To learn more about deploying a bot to Azure, see Deploy your bot to Azure for a complete list of deployment instructions.
- Conversational bots in teams
- Conversation Basics
- Universal Bots in Teams
- List Meeting Attendance Reports
- List Attendance Records
- Configure application access policy
- Bot Framework Documentation
- Bot Basics
- Azure Portal
- Add Authentication to Your Bot Via Azure Bot Service
- Activity processing
- Azure Bot Service Introduction
- Azure Bot Service Documentation
- .NET Core CLI tools
- Azure CLI
- Azure Portal
- Language Understanding using LUIS
- Channels and Bot Connector Service
- Microsoft Teams Developer Platform