How to get your data from various services to MS Teams Channel

Home > Blogs > MS Teams > How to get your data from various services to MS Teams Channel
Posted by: Nadir Riyani
Category: MS Teams
How to get your data from various services to MS Teams Channel

MS Teams allows users to create a webhook that allows users to post data into the channel. The user can expose any HTTPS endpoint and design your own connectors. Microsoft has made an easy process to design the connector. You can make your life easy using a connector. It’s a simple way to get content from external sources to the Teams channel. 

There are two ways you may create a connector. One inbuilt App is available in the store which you may use. And one you may design your own custom connector.

(Connector Configuration and Subscription model)

Microsoft gives the Javascript SDK to design the connector in easy form. You just need to inherit the SDK and create the connector by extending the javascript methods. The inbuilt method will give the unique Incoming webhook URL. This URL has a direct connection with your channel. Any engine can post the content to the channel using the Incoming webhook URL. Once the engine starts sending content to the channel, users will receive an alert in the channel. Of Course, the user who creates the connector has the rights to discontinue the service, But until the user removes the connection the user will continue to receive a message from the configured sources. In other words, We may say, It allows users to subscribe to receive notifications and messages from your web services. They expose an HTTPS endpoint for your service to post messages to the channel. Let’s review some code samples.

Initialize the Teams SDK

//Initialize the MS Teams library
microsoftTeams.initialize();

Get Incoming webhook URL

microsoftTeams.settings.getSettings(function (settings) {
    $("#webhookUrl").val(settings.webhookUrl);
});

Set Incoming webhook URL

microsoftTeams.settings.registerOnSaveHandler(function (saveEvent) {

 url = "https://" + window.location.hostname;

 microsoftTeams.getContext(function (context) {
            entity = `connector-${context.teamId}-${context.channelId}`;
 });

You may refer to more functions in Teams Javascript SDK here

You may connect your Teams channel with any service outside the world. The service may be Twitter, Trello, Github, Azure or any custom applications.

POST your content to Channels

Teams accept standard format to receive content via Incoming webhooks. You can POST JSON payload as a message to the webhook URL. Teams connector supports Message card format. 

Users may format the message card using Markdown format. You may find designing guidelines in Microsoft doc. Users may add quick actions to the message card. The action would bond the user with MS Teams and their services. There are four types of actions available in the Message card.

  • OpenUri
  • HttpPOST
  • ActionCard
  • InvokeAddInCommand

OpenUri: It allows users to navigate from MS Teams to the user’s portal. This will increase user engagement and productivity towards the application.

HttpPOST: Users may POST content to any service from MS Teams to custom service. The target service needs to authenticate the POST call requested from MS Teams. Microsoft adds the bearer token in all the HTTP requests. The token is a JSON web token(JWT) signed by Microsoft and it includes Tenant and user’s identification.

ActionCard: This can be used with HttpPOST. You may wish to take some input from the user along with action buttons. Generally, this can be used when you take a small survey, adding comments or take users’ choice of actions. Users can post their views along with actions in Teams.

InvokeAddInCommand: This action results in Microsoft outlook. Outlook opens the requests from Teams and makes the initialization context specified by the action available to the add-in.

In conclusion, MS Teams connector is an easy option to get your organization data to Teams and perform the bidirectional action between Teams and your service.

mm
Author: Nadir Riyani
Nadir Riyani is a Technical Lead at Crest Data Systems, with 12+ years of experience in Software development. He has successfully delivered software products for Financial, Inventory, Sales, Manufacturing, and Transportation domains. At Crest Data Systems, Nadir has worked with several cloud providers and frameworks like AWS, Azure, and Splunk. Prior to Crest, Nadir has worked as a Team Lead for MSBC Group.
This website uses cookies and asks your personal data to enhance your browsing experience.