Slack has become one of the most widely used collaboration tools in the world today. Slack has made its mark in part by functioning as an information hub for users through integrating to hundreds of other applications. So why not integrate Slack with your industrial manufacturing plant software or SCADA system? Here's how to do it with the WinCC OA SCADA software from Siemens.
1. If you don't already have have a Slack account, you will need to sign up for one. Creating a new account is quick, and the basic account is free.
2. Add an application to your Slack instance. The easiest way is to go to https://api.slack.com/slack-apps and click the create Slack application.
3. Give your application a name and attach it to your work space.
4. After the application has been created, you need to enable web hooks to POST from WinCC OA.
5. Add a new web hook. This button is on the bottom of the page. From here, select a channel you would like the POST from OA to go to. When this is complete you will receive a Webhook URL. Remember this URL as you will need it soon.
6. Create a new project or open an existing project in OA and add the following logic. I added this to the Initialize script in a blank panel. Key points to this script are that you need a JSON encoded string that has a “text” property. Slack expects this property and will not accept it without this. Second, you need to have the “Content-Type, application/json” header.
work(string dp,int a)
string s =" Datapoint " +dp + " has a value of "+ (string)a;
mapping mMappe = makeMapping("text",s);
string s = jsonEncode(mMappe, 1);
netPost("YOUR WEBHOOK URL", makeMapping("content",s, "headers", makeMapping("Content-Type", "application/json")),m);
7. You should now be able to change your connected data point, and it will appear in your Slack channel. Remember that the OA application must have an internet connect to the web to talk to Slack.
From here you can create more advanced applications, but this will create the connection and get you started.
Learn more about Vertech's expertise with Siemens products and solutions here. Check out another SCADA web integration showing how to build a front end web app for Ignition SCADA using React.