Skip to content

Latest commit

 

History

History
 
 

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
page_type description products languages extensions urlFragment
sample
This sample illustrates usage of incoming webhook.
office-teams
office
office-365
csharp
contentType createdDate
samples
04/01/2022 02:36:57 PM
officedev-microsoft-teams-samples-incoming-webhook-csharp

Incoming webhook

This sample demos UI to type in Incoming Webhook URL and message card payload, which send the card in the team also demonstrates the HttpPOST action in the card.

tab

card by webhook

  • HttpPOST action response
  • Note: To see Post action please set target as https://{{base-url}}/api/save

post action response

Prerequisites

  • .NET Core SDK version 3.1

    # determine dotnet version
    dotnet --version
  • Ngrok (For local environment testing) Latest (any other tunneling software can also be used)

    # run ngrok locally
    ngrok http -host-header=localhost 3978
  • Teams Microsoft Teams is installed and you have an account

To try this sample

  1. Create a incoming webhook. Create incoming webhooks. Keep this webhook URL handy while running the sample.

  2. Clone the repository

    git clone https://github.com/OfficeDev/Microsoft-Teams-Samples.git
  3. In a terminal, navigate to samples/incoming-webhook/csharp

    # change into project folder
    cd # IncomingWebhook
  4. Run ngrok - point to port 3978

    # ngrok http -host-header=rewrite 3978
  5. Modify the manifest.json in the /AppPackage folder and replace the following details

    • <<App-ID>> with some unique GUID
    • <<BASE-URL>> with your application's base url, e.g. https://1234.ngrok.io
    • <<VALID DOMAIN>> with your app domain e.g. *.ngrok.io
  6. Zip the contents of AppPackage folder into a manifest.zip, and use the manifest.zip to deploy in app store or add to Teams.

  7. Run the app from a terminal or from Visual Studio, choose option A or B.

A) From a terminal

# run the app
dotnet run

B) Or from Visual Studio

  • Launch Visual Studio
  • File -> Open -> Project/Solution
  • Navigate to IncomingWebhook folder
  • Select IncomingWebhook.csproj file
  • Press F5 to run the project
  1. Upload the manifest.zip to Teams (in the Apps view click "Upload a custom app")
    • Go to Microsoft Teams. From the lower left corner, select Apps
    • From the lower left corner, choose Upload a custom App
    • Go to your project directory, the ./AppPackage folder, select the zip folder, and choose Open.

Features of the sample

  • Open Incoming webhook tab.
  • Update webhook URL in Enter webhook URL input field and card payload in Card payload editor.
  • Click on send button. You will get a card from webhook in the team where incoming webhook is added.

Further reading