Dynamics 365 Business Central and Microsoft Teams: how to integrate them?

Microsoft Teams is the new Microsoft’s collaborative platform for team working and I’m 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 (and to add always more integration to its product suite).

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:

AzureFunctionTeams_01.jpg

When the app is added, you can select the channel where it must be activated and then you need to click on Configure:

AzureFunctionTeams_02.jpg

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):

AzureFunctionTeams_03.jpg

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:

AzureFunctionTeams_04.jpg

The message must be sent to this webhook by using a POST HTTP request with the following JSON 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:

AzureFunctionTeams_08.jpg

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 to our Teams channel.

The pagextension object is defined as follows:

AzureFunctionTeams_09.jpg

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:

AzureFunctionTeams_05.jpg

If you click the action, this is the output (the message was sent successfully to Microsoft Teams):

AzureFunctionTeams_06

And what happens on your Teams channel? You have a wonderful new message from a nice new service 🙂 :

AzureFunctionTeams_07.jpg

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?

5 Comments

  1. great input, actually will have this scenario to suggest in our D365BC (SaaS) implementation to our customer, good description, trying to provide further feedback when moved from the backlog side into testing

    Like

  2. Hi! Thx for the nice blog, it’s very useful. Could you just give me a hint how I could add a link, too?
    Now I am sending: text, text, text… MS Teams. http://localhost:8080/BC130/?company=CRONUS%20AG&page=99000768&bookmark=11%3bvaHmBQJ7
    But this text is not recognized as a link by MS Teams. Even with “-Uri” or something before the url it does not work. Sending as html instead of text or using “href” is also not working.
    Thx! Gerald

    Like

  3. Hi Stefano,

    Thanks for your write-up. I stumbled upon this post searching for info on connecting BC to the Teams Phone System. Like being able to simply call out from the customers info within BC, or when a customer calls in automatically get their info presented.

    To me this all seems like a no-brainer to have, but there’s not that much info I can find. Do you know if any of these functionalities are existing?

    Any feedback would be greatly appreciated.

    Cheers,

    Tony

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.