Microsoft Access and Slack Integration

It’s always fun and interesting to perform tasks using Microsoft Access that seem well outside the bounds of Access. A customer asked recently about the possibility of sending Slack messages to one of their Slack groups from an Access application based on certain events occurring in the Access application. After a couple of hours coding/testing, the feature was ready to go.

The first step is to create a Slack app and Webhook url in a Slack account.
https://api.slack.com/messaging/webhooks

Once that is in place, the lines of code below are all you need, +/- your unique requirements.

Set oXMLHTTP = CreateObject(“MSXML2.XMLHTTP.6.0”)
Set oXMLDoc = CreateObject(“MSXML2.DOMDocument”)

strEnvelope = “payload={“”SlackGroup””: “”API test””, “”text””: “”This is a Slack API msg test.””}”

Call oXMLHTTP.Open(“POST”, “https://hooks.slack.com/services/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”, False)
Call oXMLHTTP.setRequestHeader(“Content-Type”, “application/x-www-form-urlencoded”)
Call oXMLHTTP.send(strEnvelope)

Dim szResponse: szResponse = oXMLHTTP.responseText
Call oXMLDoc.loadXML(szResponse)