Calvin Hamus May, 22

Integrating Slack with WinCC OA SCADA Software

In a previous post, I shared a method to send data from the Siemens WinCC OA SCADA software package to the Slack messaging service. I then thought about how cool it would be to do the same thing but to send messages from Slack to WinCC OA.  Using a bi-directional connection, WinCC OA can push things like event notifications, periodic production information, or maintenance requests to Slack, and then recipients can acknowledge receipt and take action. This could even be used for alarm acknowledgement, and that's the use case I'll focus on in this post.

This post assumes that you have read the previous post, and configured Slack to have the initial connection and application created. Keep in mind that this exact code is not intended for a production environment; There is no security attached at all.  For this to work, your OA installation must be available to the internet or a set of security rules need to be created for all the parts to communicate.

To start out we will need to do a bit of coding to make the connection between Slack and OA easier.  We will begin on the WinCC OA server by creating a new project and then creating a single Control Script.  The script will be simple and only contain a few lines of code.  Let’s go through it a little bit.  The script starts out by checking if you have the license needed to run a httpServer in your version of OA and establishing the port that will be open to the outside world.  We then create an endpoint with the httpConnect(“ackAlarm”,”/ack”); command.  This opens up an endpoint so it can be reached by the outside world.  Finally, inside the ackAlarm function, we are simply taking the tag that Slack will be sending to us and acknowledging all the alerts on it.



Once this script is written add it to your console and start it up. If successful, you should get this in your log:



Next, we will create an intermediary server.  Slack sends its web requests out in a very specific format. Making OA meet this format is difficult, so having an intermediary server makes it easier.  Start out by downloading NodeJs from and install the software.  Once that is installed, create a new file directory on your computer. Copy the text below and name the file package.json.



Then copy the next set of code and name this file index.js.  You will need to replace the white box with the name or IP Address of your server.  What the code below is doing is starting a separate web server that we can use to forward our commands from Slack to OA (With a few extra lines of code that I left in 😊).



After you have created these files, open a command prompt in that folder. Run the command  npm install;  this will read from the package.json file and install the packages defined inside of it.  Once that is complete, run node index if everything was successful you should have a command prompt that looks like this.



Now we can finally go to the Slack Service that was created in the last post and select the Slash Commands option from the side menu.



Once inside this page you can fill out the commands that you would like to use for the user to call the command.  Again, replacing node_server with the address of the server that Node is running on or the IP of that server.


Then you are ready to test this out. The way this example is configured is to pass a tag path using the /ack command in Slack like so. 


This command will send the ack message on the tag that has a path of ExampleDP_AlertHdl1.

To test this, trigger an alarm on this tag to get it blinking, then run the command in Slack and watch the alarm become acknowledged.  If everything went smoothly you should get a response like this one.



With this post, you should once again see the power that WinCC OA is capable of with very little configuration or extra work and the openness it provides to create awesome applications.

Learn more about Vertech's expertise with Siemens products and software, here



Sign up to get the latest from Vertech delivered right to your inbox.