Skip to content

OPC Router Tutorial Teams

Following the tenth part of the OPC Router tutorial, I’m presenting how to interact with industrial automation systems via the Microsoft Teams communication platform. Remember, we’re configuring and running a project for “Papín”, a fictional potato bread factory.

Why an OPC Router tutorial with Teams?

Because “learning by doing” with examples is fun. Also, this functionality can provide us with a modern use case: the versatility to receive events notifications to your corporate chat group via the Teams application, which is an excellent option when we want to add a business messaging system to manage your production data environment better. See below a list of posts that complete this tutorial:

  1. Getting Started with OPC Router
  2. Connect an OPC DA server to Microsoft SQL Server
  3. Connect an MQTT data source to InfluxDB Cloud
  4. Perform multiple calculations within OPC Router
  5. Run an OPC Router application with Linux and Docker
  6. Build a process data simulator with Python, CSV and OPC Router
  7. Explore basic RESTful web services within OPC Router
  8. Build a Telegram basic interaction within OPC Router
  9. Build an SMS basic interaction within OPC Router
  10. Build a WhatsApp basic interaction within OPC Router
  11. Build a Teams basic interaction within OPC Router (this post)
  12. Explore advanced RESTful web services within OPC Router
  13. Run an OPC Router application with Portainer

Considerations

From this point on, we must download and install OPC Router v4.27.5016.75 or later to make this feature work appropriately. Also, OPC Router Config was renamed to OPC Router Management.

Prerequisites

Firstly, you’ll need:

  • A Microsoft account 🧾
  • Microsoft Teams desktop application 💬
  • FactoryTalk Linx Gateway as OPC DA server 🛤️
  • ControlLogix 1756-L61 as Programmable Automation Controller (PAC) 🤖
  • An Internet connection 🌐
  • Schematic diagram 📝
  • OPC Router Management application 💻

Schematic Diagram

To illustrate this idea better, look at this:

opc router tutorial teams 1

Every event notification will look like a “message card” in Teams:

opc router tutorial teams 2

What is Teams?

opc router tutorial teams 3

Microsoft Teams is a proprietary business communication platform developed by Microsoft as part of the Microsoft 365 family of products. It’s a workspace for real-time collaboration, meetings, application sharing, and more. In Teams, teamwork and communication happen in channels. A channel is a single place for a team to share messages, tools, and files.

Working with Microsoft Teams

Creating a Teams channel

  • Initially, run the Microsoft Teams application on your computer.
opc router tutorial teams 4
opc router tutorial teams 5
  • Click “Teams” and then, “Join or create a team” to start the creation of a new team.
opc router tutorial teams 6
opc router tutorial teams 7
  • Following this, press the “Create team” button.
opc router tutorial teams 8
  • Then, choose “From scratch” to create a basic team.
opc router tutorial teams 9
  • After that, select “Private” for people to need permission to join.
opc router tutorial teams 10
  • At this point, enter your team name and description.
opc router tutorial teams 11
  • Wait until the team is created.
opc router tutorial teams 12
  • Add members to the group later.
opc router tutorial teams 13
  • You should see the new private team and the “General” channel.
opc router tutorial teams 14

Add and configure a Teams connector

  • In the contextual menu for “General”, click the “Connectors” entry.
opc router tutorial teams 15
  • Add the “Incoming Webhook” connector to the channel.
opc router tutorial teams 16
  • Complete the process by clicking the second “Add” button.
opc router tutorial teams 17
  • At this instant, go back and click the “Connectors” entry.
opc router tutorial teams 18
  • Then, start to configure the “Incoming Webhook” connector.
opc router tutorial teams 19
  • Provide a name and click the “Create” button.
opc router tutorial teams 20
  • Copy the URL to the clipboard for the service that receives data in Teams and click “Done” to finish the process.
opc router tutorial teams 21
  • Paste from the clipboard and notice the URL has this form:
https://3leautomation.webhook.office.com/webhookb2/ec2adf...1bce8@f80b5f...b394/IncomingWebhook/09f7e8...d007/5324c1...7096
  • For our application, you’ll need to identify two main fields (“Host-URL” and “URL-Endpoint”):
Host-URL:
https://3leautomation.webhook.office.com/

URL-Endpoint:
webhookb2/ec2adf...1bce8@f80b5f...b394/IncomingWebhook/09f7e8...d007/5324c1...7096
  • Close the “Connectors” window.
opc router tutorial teams 22
  • Finally, watch the initial status message for the team.
opc router tutorial teams 23

Check your main data channel

  • Make sure to check OPC topic “P_PBF19_PA01” for 1756-L61 controller through Factory Talk Linx Gateway OPC DA interface.
opc router tutorial teams 24
  • Monitor variable within “Controller Tags” tab:
opc router tutorial teams 25

Working with OPC Router, OPC Classic and REST

Knowing your Plugins

  • To begin with, the configuration of OPC Router starts with your licensed plugins. There are several categories such as “Cloud / IoT”, “Topfloor”, “Shopfloor”, “Storage”, “Advanced”, “Messaging” and “Printer”.
opc router tutorial teams 26
opc router tutorial teams 27
  • Make sure to notice OPC Classic and REST.

Knowing your Transfer Objects

  • At this point, we’re going to need seven (7) transfer objects to solve our use case:
opc router tutorial teams 28
  • Specifically, make sure to notice OPC Data Access, Data Change trigger, Variables, Constant Values, Text Replace, JSON Write and REST.

Configuring your Plugins

  • Following identification, OPC Router needs to configure every licensed plugin. Let’s start creating a new plug-in instance with REST (double click on the object) and the REST connections tab:
opc router tutorial teams 29
opc router tutorial teams 30
  • Make sure to copy the beginning part of your own host URL for Teams:
https://3leautomation.webhook.office.com/
  • At this time, define a new REST connection for our system:
  • Download the plugin and run the service:

Checking your Plugins

  • Following identification, OPC Router needs to configure every licensed plugin. Let’s check the plug-in instance with OPC Classic (double click on the object):
  • At this point, check a local OPC Classic connection using a Factory Talk Linx Gateway OPC DA server, with an update rate of 6 seconds.

Creating your Ninth Template

  • In similar fashion to the tenth part of the tutorial, a template is the correct approach once again. Let’s create a new Microsoft Teams messaging template PLNMode within MSTS folder (production line mode):
  • Watch an empty design panel so you can start building your template:
  • Then, drag and drop these seven blocks as shown here:
  • Edit the OPC Data Access block and add a template variable:
  • Confirm the configured OPC Data Access block:
  • Edit the Constant Values block to have template variables for the symbol and unit of the variable, and the physical location:
  • Confirm the configured Constant Values block:
  • Edit the Variables block and choose the global variable “SystemTime”:
  • Confirm the configured Variables block:
  • Edit the Text Replace block to start preparing the format of the message to send:
  • Start creating placeholders:
  • Also, verify placeholders:
  • Give the desired format to the Microsoft Teams message you want to send:
Production capacity {ds_symbol} at PLN0{cd_location3} changed to {qt_value} {ds_unit} | Date/Time: {dt_timestamp}.
  • Confirm the configured Text Replace block:
  • Edit the Data Change trigger block to detect any value change for PLNMode (production line mode):
  • Confirm the configured Data Change trigger block:
  • Edit the JSON Write block to transform the text to a JSON structure. Start by clicking the “Edit” button:
  • Notice the JSON file to use:
{
  "@type": "MessageCard",
  "@context": "http://schema.org/extensions",
  "themeColor": "F6AC5D",
  "summary": "TeamsMessage",
  "sections": [
    {
      "text": "Here you see the text for an event notification."
    }
  ],
  "potentialAction": [
    {
      "@type": "OpenUri",
      "name": "Display trend",
      "targets": [
        {
          "os": "default",
          "uri": "http://appserver/PPN_PBF_19/PLNMode.aspx"
        }
      ]
    }
  ]
}
  • Copy and paste the JSON file in the edit window:
  • Click the “Edit” button again and then, press the “Add expression to data field” button for the “text” attribute:
  • Make sure the expression is visible in the data fields:
  • Save changes by pressing the “OK” button.
  • Confirm the configured JSON Write block:
  • Edit the REST block to set the Microsoft Teams connection:
  • Make sure to choose this format for the request:
application/json
  • Confirm the configured REST block:
  • Finally, make sure to link blocks as shown here:
  • Additionally, create the connections folder “MSTS” within “PLN01”:

Working with Instances from Templates

  • With your ninth template, a new instance is required now. Start creating it by using the contextual menu:
  • At this time, check the new instance:
  • In the design panel, double click to verify values in template variables according to actual OPC item, physical location, symbol and unit:

Compile, Save and Publish your OPC Router Project Configuration with Teams

  • At this time, you need to compile, save and publish the connection you just created by clicking the “Go productive” button:
  • Meanwhile, the project is saved and published:
  • After that, press the “Yes” button to start the OPC Router service and run your application:
  • Lastly, watch both the initial and operational connection states:

Visualize Online Data in PAC

  • Make sure to notice normal PLNMode values:
  • Then, watch how the production line capacity (PLNMode) changes three times: 80%, 85% and 90%. Each time, a data change trigger the event notification:

Visualize Online Data in OPC Router

  • Also, you can watch live values here:
  • At this point, you should notice an execution time visually:

Verify Message Transfer to Microsoft Teams

  • Notice an event notification on the Microsoft Teams application of a desktop computer:
  • Finally, watch how the OPC Router tutorial allows us to send Microsoft Teams messages to a channel every time a data change for PLNMode is triggered, with a button for a potential action:

Did you enjoy this OPC Router tutorial with Teams? I’d love to hear from you.

Stay tuned and follow part 12 of this tutorial! 😎

For other articles like this one in English, click here. To see them in Spanish, click here.

Share this post