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 project is an implementation of a very simple Outgoing Webhook for Microsoft Teams.
office-teams
office
office-365
javascript
contentType createdDate
samples
12/05/2017 06:03:13 PM
officedev-microsoft-teams-samples-outgoing-webhook-nodejs

Outgoing Webhook Sample Node.js

Summary

This project is an implementation of a very simple Outgoing Webhook for Microsoft Teams. All it does is verify that what's sending messages matches the Outgoing Webhook that was created in Teams, and it echoes back whatever is sent to it.

Interaction with app

Broadcast from user

Prerequisites

  • Microsoft Teams is installed and you have an account (not a guest account)
  • NodeJS
  • dev tunnel or ngrok latest version or equivalent tunnelling solution
  • M365 developer account or access to a Teams account with the appropriate permissions to install an app.

Setup

  1. Create Webhook
  • Create the Outgoing Webhook in Teams using the instructions here. Paste the tunneling service URL from the previous step into the "Callback URL" box. After you press the Create button, copy/paste the security token that Teams generates to the clipboard.

  • Paste the security token generated by Teams as the value of sharedSecret in app.js. When you're done, it should look something like this:

    const sharedSecret = "+ZaRRMC8+mpnfGaGsBOmkIFt98bttL5YQRq3p2tXgcE=";  ```
  • In the directory in which you installed this project, type node app.js

  • In Microsoft Teams, in any channel in the team in which you created the Outgoing Webhook, you can type @<botname> <card-type> then it will respond back a card with specified card type.

    Supported : "adaptive-card", "hero-card", "list-card", "o365-card", "thumbnail-card"

  1. Setup NGROK
  • Run ngrok - point to port 3978

    ngrok http 3978 --host-header="localhost:3978"

    Alternatively, you can also use the dev tunnels. Please follow Create and host a dev tunnel and host the tunnel with anonymous user access command as shown below:

    devtunnel host -p 3978 --allow-anonymous
  1. Setup Code
  • In a terminal, navigate to samples/outgoing-webhook/nodejs

  • Install modules

    npm install
  • Install modules

    npm install
  • Run your bot at the command line:

    npm start

Running the sample

  • Example screenshot to show Hero card: Hero card
  • Supported : "adaptive-card", "hero-card", "list-card", "o365-card", "thumbnail-card"

  • If you type anything else apart from above mentioned type, it will echo back what you typed.

  • Example screenshot to show Echo message: Echo message

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com.

When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.