Posting to Workplace from Azure Data Factory

We recently started using Workplace (by Facebook) at work, so I wanted to check if I can add some data from our data warehouse as posts in groups. This turned out to be very easy, but worth a post.

To set it up you go into workplace and settings for the group you want to add posts to, and click this button in the bottom. This will provide you with an URL and token for publishing posts, and must be done for every group you want to post to.

Setup in Workplace

Next you go into Data Factory to find the data you want to post. I have created a simple pipeline that first does a lookup against an SQL Server. This is done with a query that returns the number of members we have at NHO the current day. Next you add a pipeline variable that sets the actual message content, and this is defined as:

@concat(‘**Memberstatus**;
Today we have ‘,activity(‘Lookup SQL’).output.firstRow.memberCount,’ members
As always, you can find all the numbers in [Power BI](powerbi.com)
‘)

Variable for message content. This is formatted with Markdown

Next I lookup the token from KeyVault with a web activity that uses MSI authentication, and add the message with a URL like this:

@concat(‘https://graph.workplace.com/v3.0/group/feed?message=’,variables(‘messageText’),’&formatting=MARKDOWN&access_token=’,activity(‘Get Token from KeyVault’).output.value)

URL for adding posts, important to add &formatting=MARKDOWN

My entire pipeline looks like this:

Pipeline to post to Workplace

Depending on your group settings post will appear when this is run (it might have to be approved).

Leave a Reply

Your email address will not be published.

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