Search code examples
ibm-cloudiotopenwhisk

How to invoke an OpenWhisk action from IoT Platform in Bluemix


We would like to know how to invoke an OpenWhisk action from IoT Platform in Bluemix. What we want to accomplish is:

  1. Send an event data from a device to IoT Platform
  2. Subscribe the event
  3. Call an OpenWhisk action.

We are assuming the event data is JSON format. We know we can develop an application that subscribes to an event on the IoT Platform like: https://console.bluemix.net/docs/services/IoT/applications/libraries/java.html#java. However, we believe that there must be a more simpler way.

If we look at IoT Platform, we can create an action such as IFTTT, Webhook action, Forward event to cloud, etc. Generally speaking, which way do you recommend to invoke an OpenWhisk action from IoT Platform?

Any comments or suggestions must be appreciated. Thank you.


Solution

  • IBM Message Hub can automatically bridge messages between the Watson IoT platform and OpenWhisk.

    Watson IoT service provides an integration to forward all incoming topics messages to IBM Message Hub. IBM Message Hub is an Apache Kafka-as-a-Service offering on IBM Bluemix.

    Here are the instructions for connecting and configuring a historian service for the Watson IoT platform using IBM Message Hub. https://console.bluemix.net/docs/services/IoT/message_hub.html#messagehub_main

    OpenWhisk has a trigger feed service for IBM Message Hub. You can have triggers subscribe to messages from a Message Hub topic. Actions can then be bound to triggers to fire automatically for each event.

    Here's an example walking you through connecting an OpenWhisk action to the Message Hub topic: https://github.com/IBM/openwhisk-message-hub-trigger