Subscribe to Topics with Flows
You have the following options for subscribing to topics in flows.
The following steps describe how to subscribe to a single topic from a connected DeviceHub device. See the following to learn more:
To subscribe to a single topic:
- Get the topic name to configure the DataHub Subscribe node in Flows.
- Go to DeviceHub and select the Tags pane from the menu bar.
Click the Copy icon next to the RAW Topic from which you wish to receive data.
- In the navigation menu, click Flows Manager.
To access an existing flow canvas, click the Go To Flow Definition icon next to the flow status. For creating a new flow, refer to Step 2: Create Individual Flow in Create a Flow to learn more. The Flow canvas opens in a new browser tab.
Drag the DataHub Subscribe Node and Debug Node on the canvas and connect them.
- Double-click the DataHub Subscribe node to open the Edit DataHub Subscribe node dialog box. Configure the node by following these steps:
- Copy and paste the topic from DeviceHub > Tags into the Topic field.
- If needed, configure the Datahub Subscribe connection. See the Step 3: Configure Connector Nodes section in Create a Flow to learn more.
Enter a name in the Name field and click Done.
- Click the Deploy button located at the top-right corner of the screen to save the flow.
Expand the message window beneath the flow.
Click the Debug icon to view the data output.
Review the data payload in the message window.
Use Wildcards to subscribe to multiple topics at once.
> Wildcard Character: Use the > wildcard character to subscribe to messages from multiple tags. Example: devicehub.alias.> will subscribe to every topic in the DeviceHub.
* Wildcard Character: Use the * wildcard character to match a single topic between . characters in tags. Example: devicehub.alias.*.* matches topics with two-character sequences after each of the two . characters.
Note: Using just the > wildcard character subscribes to all topics, which can cause slowdowns when sending data to databases or clouds. Consider using Function Nodes to trim data or file nodes for efficiency.
To subscribe to multiple topics in flows, replace the topic name in step five of "Subscribe to a Single Topic" with the information about topic wildcards as below.
To use wildcards to subscribe to multiple topics:
- Complete steps 1-5 from "Subscribe to a Single Topic" above.
Replace the topic name with the desired wildcard-based topic. Syntax Examples: devicehub.alias.> (Subscribe to all topics in DeviceHub) devicehub.alias.{Device_ID}.> (Subscribe to all tags from a specific DeviceHub device) devicehub.alias.*.test_tag (Subscribe to all tags named test_tag from every DeviceHub device)
- Click Done and save the flow by clicking the Deploy button at the top-right corner of the screen.
Expand the message window beneath the flow.
Click the Debug icon to view the data output.
Review the data payload in the message window.