This is an example to show how to write a connector for Microsoft Teams.
All required source code are located in the ./src
folder:
client
client side codeserver
server side codepublic
static files for the web sitemanifest
for the Microsoft Teams app manifest
Connector files and pages:
./src/server/connector.ts
- implementation of the Connector that manages registering new subscriptions (Connect()
) as well as a sample method to send a message to all subscribers (Ping()
)../src/public/config.html
- the configuration of the Connector ../src/client/connectorConfig.tsx
- React component of the configuration page.
Connector APIs:
For the Connector you will have two generated end-points, defined in ./src/server/server.ts
.
/api/connector/connect
- this is the end-point that is connected to theConnect
method of the Connector implementation and is used when registering a Connector./api/connector/ping
- this is a test end-point to demonstrate how to invoke the Connector using a simple HTTP GET operation. It is highly recommended that you remove this end-point and implement your own logic for invoking the connector.
- Node.js - v12.* (or higher)
- NPM (installed with Node.js) - v6.* (or higher)
- Gulp - v4.* (or higher)
- Yeoman Generator for Microsoft Teams - v3.2.0 (or higher)
- M365 account with Teams sideloading permission enabled.
- In a terminal, navigate to the project root.
- Run
npm install
to install node modules for this project. - Run
gulp ngrok-serve
to start the project and get the ngrok tunnelling endpoint (e.g. https://[replace].ngrok.io). - Register a new connector in the Connector Developer Portal
- 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://[replace].ngrok.io/config.html
- For Valid domains, make enter your domain's http or https URL, e.g. XXXXXXXX.ngrok.io.
- Enable the action on connector card by selecting the Yes radio button and enter the update endpoint:
https://[replace].ngrok.io/config.html
- Click on Save. After the save completes, you will see your connector id.
- Within your project, locate and open the ./.env file. Set the CONNECTOR_ID to the ID of the Connector you just created.
- The manifest zip package under .package folder will be automatically refresh with the connector id.
- Now you can sideload your app package under .package folder to test your new connector.
You can refer to this tutorial for more details on the above steps.
To create the Microsoft Teams Apps manifest, run the manifest
Gulp task. This will generate and validate the package and finally create the package (a zip file) in the package
folder. The manifest will be validated against the schema and dynamically populated with values from the .env
file.
gulp manifest
Using the yoteams-deploy
plugin, automatically added to the project, deployment of the manifest to the Teams App store can be done manually using gulp tenant:deploy
or by passing the --publish
flag to any of the serve
tasks.
For more information about getting started with Teams, please review the following resources: