page_type | description | products | languages | extensions | urlFragment | ||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
sample |
Sample code for a generic connector that's easy to customize for any system which supports webhooks. |
|
|
|
officedev-microsoft-teams-samples-connector-generic-nodejs |
This contains the source for a generic connector that's easy to customize for any system which supports webhooks.
- Connectors
To complete this tutorial, you need the following tools. If you don't already have them you can install them from these links.
- Git
- Node.js and NPM
- Get any text editor or IDE. You can install and use Visual Studio Code for free.
- An Office 365 account with access to Microsoft Teams, with sideloading enabled.
- If you want to run this code locally, use a tunnelling service. These instructions assume you are using ngrok.
Note these instructions are for running the sample on your local machine.
-
Open a new command prompt window.
-
Change to the directory that contains the ngrok.exe application.
-
In the command prompt
Run ngrok - point to port 3978
ngrok http 3978 --host-header="localhost:3978"
-
Make note of the https:// Forwarding URL. This URL will be your [BASE_URI] like
https://1234.ngrok-free.app
which will be used in later steps. -
Configure your own connector
-
Open Connector Developer Portal and select New Connector.
-
Fill in all the basic details such as name, logo, descriptions etc. for the new connector.
-
For the configuration page, you'll use our sample code's setup endpoint:
https://[BASE_URI]/connector/setup
-
For Valid domains, make enter your domain's http or https URL, e.g. XXXXXXXX.ngrok-free.app.
-
Click on Save. After the save completes, you will see your connector ID in address bar.
- In the
~/views/connectorconfig.jade
file line 27 and replacengrokURL
to the ngrok https forwarding url from the above.
- Install all the dependencies by running
npm install
in root directory.
npm install
- Run the sample using
node server.js
- This step is specific to Teams.
- Edit the
manifest.json
contained in theapp manifest
folder to replace your Microsoft Replace<<CONNECTOR_ID>>
field in~/app manifest/manifest.json
file with your newly registered - Edit the
manifest.json
and update<<AppDomain>>
Example. if you are using ngrok it would behttps://1234.ngrok-free.app
then your app domain-name will be1234.ngrok-free.app
. - Zip up the contents of the
app 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
App list to connect for notifications (Select App from the list which you want to connect for notifications.)
Select App to get notifications (Configure your selected application.)
Selected App configuration (Give some digest name and select topics to get connect)
App is now configured for notification (you will be get notify of that app which is connected with channel.)
For more information about getting started with Teams, please review the following resources:
- Review Office 365 Connectors
- Review Understanding Teams app capabilities
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 opencode@microsoft.com with any additional questions or comments.