Skip to Content

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:


/wp-content/uploads/2015/09/i2_796870.png


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

1.JPG

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

2.JPG

Now you see the Internet of Things Services Cockpit

3.JPG

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

4.JPG

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.

5.JPG

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.

6.JPG

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.

8.JPG

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

9.JPG

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

10.JPG

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.

11.JPG

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.

13.JPG

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.

15.JPG

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.

16.JPG

The master date for your first device is created successfully

17.JPG

Test your service

Switch to the Message Management Service

Select the tile Send and receive messages via HTTP

9.JPG

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.

x1.JPG

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.

x2.JPG

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)

/wp-content/uploads/2015/09/i1_796867.png

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.

z1.JPG

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

z2.JPG

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.

if1.JPG

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

if2.JPG

Select You enter or exit an area in step 2.

Complete the iOS location trigger by searching for a area.

if4.JPG

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”.

if5.JPG

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.

if7.JPG

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.

if8.JPG

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 ๐Ÿ˜‰


z3.JPG

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>

z4.JPG


Turn Zap on!

After that the scenario is finish . ๐Ÿ™‚

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

To report this post you need to login first.

4 Comments

You must be Logged on to comment or reply to a post.

  1. Pallavi Shah

    Hi ,

    I tried to replicate the above scenario , but while using the URL in zaiper with “api” keyword instead of internal( the way you mentioned it above), it returns (400) Bad Request and said nothing,

    URL used : https://iotmmspxxxxxxxxxtrial.hanatrial.ondemand.com/com.sap.iotservices.mms/v1/api/http/data/89099088765xxxxxxxxxx

    while the same is working fine with Chrome Postman , ie i am able to post the message without any error and can see the same in IOT table.

    (0) 
  2. Arun Iyer

    Curious to know if the above example has worked for anybody? I have tried it many times since yesterday but unsuccessful.ย Zappier says post is successful but found no entry in HCP-display stored messages.

     

    (0) 

Leave a Reply