Webhooks are a great way for Teams to integrate with external apps. A webhook is essentially a POST request sent to a callback URL. In Teams, outgoing webhooks provide a simple way to allow users to send messages to your web service without having to go through the full process of creating bots via the Microsoft Bot Framework. Outgoing webhooks post data from Teams to any chosen service capable of accepting a JSON payload. Once an outgoing webhook is added to a team, it acts like bot, listening in channels for messages using @mention, sending notifications to external web services, and responding with rich messages that can include cards and images.
- Select the appropriate team and select Manage team from the (•••) drop-down menu.
- Choose the Apps tab from the navigation bar.
- From the window's lower right corner select Create an outgoing webhook.
- In the resulting popup window complete the required fields:
- Name - The webhook title and @mention tap.
- Callback URL - The HTTPS endpoint that accepts JSON payloads and will receive POST requests from Teams.
- Description - A detailed string that will appear in the profile card and the team-level App dashboard.
- Profile Picture (optional) an app icon for your webhook.
- Select the Create button from lower right corner of the pop-up window and the outgoing webhook will be added to the current team's channels.
- The next dialog window will display an Hash-based Message Authentication Code security token that will be used to authenticate calls between Teams and the designated outside service. This token in used in
AuthProvider.cs
. - If the URL is valid and the server and client authentication tokens are equal (i.e., an HMAC handshake), the outgoing webhook will be available to the team's users.
-
Microsoft Teams is installed and you have an account (not a guest account)
-
.NET Core SDK version 3.1
# determine dotnet version dotnet --version
-
ngrok or equivalent tunnelling solution
-
Visual Studio
-
Asp.net Core
Note these instructions are for running the sample on your local machine, the tunnelling solution is required because
-
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/outgoing-webhook/csharp
folder - Select
WebhookSampleBot.sln
file - Update the HMAC in
AuthProvider.cs
file. - Press
F5
to run the project
-
Run ngrok - point to port 3978
ngrok http -host-header=rewrite 3978
-
Run your tab, either from Visual Studio with
F5
or usingdotnet run
in the appropriate folder.