Microsoft Teams is the new Microsoft’s collaborative platform for collaborative working and I’m quite sure that quite soon everyone of you will use this platform as a Skype replacement (at least for business). One of the request I’m receiving often is why Microsoft has not directly integrated Teams on Dynamics 365 Business Central. I agree, I think that this is something that Microsoft should do in order to add collaborative features to D365BC. But despite these considerations, is it so difficult to integrate Teams with Dynamics 365 Business Central? Microsoft Teams offers REST APIs for interaction and it exposes “connectors” for interacting with channels. An interesting connector exposed by Teams is the Incoming Webhook connector. When activated on a channel, this connector permits you to have a webhook that can be used to send HTTP calls to that channel. So, why not use it from Dynamics 365 Business Central for sending messaging to a Team channel? To show this, in this post I want to create an extension that permits you to send a message to a Teams channel from a Dynamics 365 Business Central page action. You can extend this scenario as you want The main step here is to activate the Incoming Webhook connector on your Teams channel. Select your Teams channel, go to the team properties, select App and then add the Incoming Webhook app: When the app is added, you can select te channel where it must be activated and then you need to click on Configure : In the app configuration page, select an app name and (optionally) select an image for the app (this will appear on your channel when a message is posted): After the Incoming Webhook app configuration, you receive an URL (your webhook) that you have to use from Dynamics 365 Business Central for sending your messages to Teams: The message must be sent on this webhook by using a POST HTTP request with the following payload: {"text": "Hello from Dynamics 365 Business Central"} Now it’s time to create the extension for Dynamics 365 Business Central. Our extension here is quite simple: we have a codeunit that exposes a method for sending a message to Microsoft Teams by calling the webhhok we have a pageextension object that adds an action for sending a message to your Microsoft Teams channel The codeunit code is as follows: Here, we create an HttpClient object and we send a POST request to the webhook by passing a JSON payload that contains our message that we want to send in Teams. The pagextension object is defined as follows: If you deploy this extension to Dynamics 365 Business Central, on the Customer List you have a new button for sending a message to Teams: If you click the action, this is the output (the message was sent successfully to Microsoft Teams): And what happens on your Teams channel? You have a wonderful new message from a nice new service : As you can see, it’s quite simple to integrate Teams and with few lines of code you can have a more interactive Dynamics 365 Business Central than ever. Obviously, this is a simple scenario but you can extend it to be more “business related”. For example, you can have a different Teams channel for department and automatically write on this channel some business informations that comes from your Dynamics 365 Business Central tenant in real-time. Teams webhooks are also very interesting because you can for example start them also from an Azure Function and maybe interact with other Azure resources in real-time. Nice and very useful for a complete company collabouration isn’t it?
↧