Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member

With the new IoT Services on the SAP HANA Cloud Platform (HCP) it has become very easy to connect any kind of data to the SAP HANA Cloud Platform.

In this post I like to show you, how to use IFTTT and Zapier to connect your iPhone (or any other kind of "smart" thing) via the IoT Service to the SAP HANA Cloud Platform.


The final scenario will look like this:



Unfortunately it is not possible to access directly from IFTTT the HCP because in this channel it is not possible to add some customer REST header data. This is the reason we use Zapier as a Webservice "Trigger".

Agenda

  1. Preparations for IoT Services
  2. Create IoT Service masta data for IFTTT data
  3. Test your service
  4. Configuration of the IFTTT and use zapier as a proxy


Preparations for IoT Services

If you have already a hanatrial account and use the IoT services continue at chapter Create IoT Service for IFTTT data.


Get a free developer account for SAP HANA Cloud Platform

To create a account register at https://hanatrial.ondemand.com

Log on to the SAP HANA Cloud Platform Cockpit https://account.hanatrial.ondemand.com/cockpit

Enable the IoT Service

  1. Switch to the Services navigation tab
  2. Click at the Enable button at the right for the Internet of Things Services
  3. Select Go to Service

Now you see the Internet of Things Services Cockpit

Click on Deploy Message Management Service and enter your Account ID, User Name, Password and Deploy

Confirm that you won't to deploy the message management services

Now you'll notice that a new block will show-up in the screen. You'll find the link to the installed MMS application at the bottom. Click on that link.

The link will bring you to a newly created Java application called iotmms. Assign your own user to the role IoT-MMS-User. To do that click on the Roles tab on the left.

Select the role Iot-MMS-User with a click on the respective row. Now click on the Assign button and add your user to the list of Individual Users.

Click again on the Overview tab your iotmms Java Application and check if the State is Started. Click on the link you find under the Application URLs.

The Message Management Service of the IoT Services is now finally up-and-running on your account.

Create IoT Service masta data for IFTTT data

Before wecan send data to the SAP IoT Service we have to create following master data:

  1. Device Types
  2. Message Types
  3. Devices

Therefore we have to go to the Internet of Things Services Cockpit.

You can access this direct from the service area in the HCP or with the tile View registered devices and device types from the Message Management Service

First create a Device Types by selecting the tile Device Types. Create a new Device Type with the +

Enter the Name "iPhone" and press the Create Button

After that your first device type is created. Go back to the overview area with the back button.

Now create a Message Types by selecting the tile Message Types


Create a new Message Types with the +

  1. Enter the Name "iPhone Message"
  2. Select the Device Type "iPhone"
  3. Select the direction "From Device"
  4. Add a field named "value" with the type "string"

Press the Create Button. After that your first message type is created. Go back to the overview area.

Now create a Device by selecting the tile Devices. Create a new Device with the +

  1. Enter the Name "xxxxx iPhone"
  2. Select the Device Type "iPhone"
  3. Press the Create Button
  4. After that your first device is created.

After the creation an OAuth Access Token is displayed. Please save the Token local.

You will use this later in the IFTTT service. Go back to the overview area.

The master date for your first device is created successfully

Test your service

Switch to the Message Management Service

Select the tile Send and receive messages via HTTP

In this area you can check if your web service work successfull.

Modify the HTTP endpoint with the Device ID from your iPhone e.g.:

https://iotmmsp1941081208trial.hanatrial.ondemand.com/com.sap.iotservices.mms/v1/internal/http/data/ce0d060f-05c1-48a7-ae45-6280cabef8d2

Hint: ce0d060f-05c1-48a7-ae45-6280cabef8d2 IS NOT the TOKEN it is the ID of the device

Change the JSON message e.g.:

{"mode":"sync","messageType":"1b8c3a684f51dfddfe27","messages":[{"value":"First Test"}]}

Hint: 1b8c3a684f51dfddfe27 is the ID of the message type

Hint: value is the field name I used in the message type

Press the POST button, check the results in the lower section and go back to the overview area.

You can find the necessary ID's in the Internet of Things Services Cockpit.

Select the tile display stored message. There you can find the just created table with your test values. The table is automatically created by the first POST message.

Configuration of the IFTTT und use zapier as a proxy

Create an account at Discover new Recipes - IFTTT

Create an account at The best apps. Better together. - Zapier

This a two web application you can use for free.

Download IFTTT from Apple App store and log on with your just created IFTTT account.

(There is a similar IFTTT app availed for android smart phone)

Log on at the Zapier homepage and "MAKE A ZAP".

Select as incoming on the left site Webhooks by Zapier and choose Catch Hook.

Select Webhooks by Zapier also on the right site and choose Custom Request. Continue to the next step.

Save the link for access Zapier webhooks https://zapier.com/hooks/catch/XXXX/

After we contine with Zapier we have to implement the IFTTT part. Log on at your IFTTT account with a web browser and slect "My Recipes". Create a Recipe.

Choose a trigger Channel - in my example I use iOS location, but you can use any kind of trigger you wont.

Select You enter or exit an area in step 2.

Complete the iOS location trigger by searching for a area.

Choose MAKER as action channel.

Hint: Unfortunately it is not possible to access directly with the maker channel the HCP because in this channel it is not possible to add some customer REST header data. This is the reasen we use Zapier as a Webservice "Trigger".

Select Make a web request in step 5.

Enter the Zapier URL you created before.

Set the method to POST

Set the Content Type to application/json

Enter in the body:

{"mode":"sync","messageType":"1b8c3a684f51dfddfe27","messages":"{{EnteredOrExited}} Linz"}

Hint: {{EnteredOrExited}} is a comment from IFTTT.

And Create a Recipe at the last step. The Recipe is now also available at your smart phone.

You can use the THIS statement to connect everything to a web request so feel free to try different thinks out.

Switch back to the Zapier website and continue your ZAP creation

Choose in step 5 as method POST

Enter the URL of your webserive.

Important: You have to change the URL address a little bit from the chapter Test your service

Because we are not in the "internal" HCP network we have to change this with API:

https://iotmmsp1941081208trial.hanatrial.ondemand.com/com.sap.iotservices.mms/v1/api/http/data/ce0d060f-05c1-48a7-ae45-6280cabef8d2

Define the Data with the JSON statement we like to send to our IoT service.

The orange fields are only available after the first sending from IFTTT. So you have to enter or exist your area first 😉


The header parameter we have to define now are the only reason we have to use Zapier. Because they are necessary to access the HCP from outside and in the IFTTT you cannot change it.


Define the header parameter.

Content-Type: application/json

Authorization: Bearer <Token of your device>


Turn Zap on!

After that the scenario is finish . :smile:

You will now get every time you enter or leave the defined area a message in your HCP.

To have a look at the results please check out the display stored message like descripe in the chapter Test your service

4 Comments
Labels in this area