Bot Framework v4 Teams Messaging Extension Action sample.
This Messaging Extension has been created using Bot Framework. It shows how to create a simple Card based on parameters entered by the user, and how to Share a message through a Messaging Extension.
-
.NET Core SDK version 2.1
# determine dotnet version dotnet --version
-
Microsoft Teams is installed and you have an account
-
Clone the repository
git clone https://github.com/Microsoft/botbuilder-samples.git
- Download and install ngrok
- In terminal navigate to where ngrok is installed and run:
ngrok http -host-header=rewrite 3978
- Copy/paste the
https
NOT thehttp
web address into notepad as you will need it later
- Create a new bot here
- Enter a
Display name
andBot handle
- In the
Messaging endpoint
enter the https address from Ngrok and add/api/messages
to the end- EX:
https://7d899fbb.ngrok.io/api/messages
- EX:
- Open the
Create Microsoft App ID and password
link in a new tab - Click on the
New registration
button - Enter a name, and select the
Accounts in any organizational directory (Any Azure AD directory - Multitenant) and personal Microsoft accounts (e.g. Skype, Xbox)
- Click
Register
- Copy & paste the
Application (client) ID
field into notepad. This is your botID. - Click on
Certificates & secrets
tab on the left - Click
New client secret
- Enter a name, select
Never
, and clickAdd
- Copy & paste the password into notepad. This is your app password.
- Go back to the bot registration tab and enter the
botID
into the app ID field - Scroll down, agree to the Terms, and click
Register
- Click the
Microsoft Teams
icon on the next screen - Click
Save
-
Launch Visual Studio
-
Navigate to and open the
samples/csharp_dotnet/51.teams-messaging-extensions-action
directory -
Open the
appsettings.json
file -
Paste your botID value into the
MicrosoftAppId
field -
Put the password into the
MicrosoftAppPassword
field -
Save the file
-
Open the
manifest.json
-
Replace your botID everywhere you see the place holder string
<YOUR-BOT-ID>
-
Run the bot:
A) From a terminal
# run the bot
dotnet run
B) Or from Visual Studio
- File -> Open -> Project/Solution
- Navigate to
samples/csharp_dotnetcore/51.teams-messaging-extensions-action
folder - Select
TeamsMessagingExtensionsAction.csproj
file - Press
F5
to run the project
- Launch Microsoft Teams
- In the bar at the top of Teams search for and select
App Studio
- Click the
Manifest editor
tab - Click
Import an existing app
- Navigate to and select the
manifest.json
file from the previous step - Click on the
Action Messaging Extension
card - Click
Test and distribute
on the left hand side - Click the
Install
button - Click
Add
button
- Selecting the Create Card command from the Compose Box command list. The parameters dialog will be displayed and can be submitted to initiate the card creation within the Messaging Extension code.
or
- Selecting the Share Message command from the Message command list.