Automate Business Processes with Multi Cloud Data Streamer and Integromat

06.05.2021
guide-image

Low-code/ No-code integrations are a life saver when you want to automate your business processes. Integromat is one such platform which can help you take direct actions on important data coming from your IoT devices. With the EMnify Multi Cloud Data Streamer, you can stream connectivity events, usage data and more from your EMnify connected devices and create automations with it using Integromat.

Prerequisites

  • A device with a cellular modem and EMnify SIM card
  • An Integromat account

Benefits

  • Connectivity metadata available into Integromat to unify all IoT operations dashboards in one place
  • Easy low-code integration
  • Set up triggers on receiving events or usage data from your SIM
  • One-time set up needed for multiple processes
  • Processing handled on the Integromat platform. No processing required at your server.
  • Can take actions like sending email or triggering API calls or DB queries etc. on events like device disconnected
  • Provides a one stop solution to monitor your IoT devices for preemptive maintenance, everyday operations or breakdown

Use Case

When you have a device with an EMnify SIM sending data, you can set the amount of data a particular device can consume in a month. You can set this limit from the EMnify portal for security reasons or from a data consumption point of view. Once this data limit is reached, the SIM will still try to connect to the network and create a PDP context but will fail to do so. It will send an event in this case stating why it isn't able to connect. We then use this event to trigger an email using Integromat to take further actions.

Prepping your Integromat Scenario to accept the Data Streamer

In your Integromat account, click on `+ Create a new scenario` and select the service Webhooks. On the Scenario building pages, click on the Webhooks icon to select Custom webhook.
Custom_webhook
Under the Webhook title in the box, click on Add and give your webhook an appropriate name.
name_webhook
On saving this you will see a url that is generated. Copy this url as we will need it in the next step to connect it to the Data Streamer.

Creating an event stream with the EMnify Data Streamer

Once you have prepped the Integromat, go to the EMnify Portal to create a data stream. Log in with your credentials and click on the Integrate button on the left hand side menu. Then go ahead and click on ADD NEW STREAM.
add_stream
Select Webhook as your stream of choice and choose the source Stream events.
The PDP Context create event is triggered when the SIM tries to create a data channel in the network. Now if your SIM has used up all the alloted data, it won't be able to send data through this channel. The event will reflect this and will serve you the reason why it wasn't able to create the PDP context.
Which is why under the EVENT OPTIONS in the create Data Streams, you need to choose just the Create PDP Context event.
In the target URL, enter the url copied when you created a webhook module in Integromat.
Click on Create to create the stream with the Multi Cloud Data Streamer (MCDS).
*You can also create a data stream using the EMnify API.create_stream

Triggering an E-mail on receiving the Data used-up event

After creating the Stream, you want to trigger an action when the event arrives. To do that, we need to provide the format of the event to the Webhooks module in Integromat, so it knows in what format to expect. You can do this by lowering the limit to 1MB of one of your devices and using some data on it. After that let the device connect again by restarting the device.
You can also use this test event as a template.


{
    "id": 17083431062,
    "timestamp": "2021-05-06T08:54:00Z",
    "event_source": {
        "id": 1,
        "description": "Policy Control"
    },
    "event_severity": {
        "id": 1,
        "description": "WARN"
    },
    "event_type": {
        "id": 3,
        "description": "Create PDP Context"
    },
    "organisation": {
        "id": 12345,
        "name": "EMnify Demo"
    },
    "user": null,
    "alert": 1,
    "description": "PDP Context Request rejected, because endpoint is currently blocked due to exceeded traffic limit.",
    "endpoint": {
        "id": 10872562,
        "imei": "865182030****600",
        "name": "Shruti_MIA1",
        "tags": null,
        "ip_address": "10.***.**.**"
    },
    "sim": {
        "id": 3580921,
        "iccid": "898830*****05**7064",
        "msisdn": "4236****0988978",
        "production_date": "2020-12-23T13:04:40Z"
    },
    "imsi": {
        "id": 10786386,
        "imsi": "2950900*****658",
        "import_date": "2020-12-23T13:04:40Z"
    },
   "detail": {
        "id": null,
        "name": null,
        "country": {
            "id": null,
            "mcc": null,
            "name": null,
            "iso_code": null,
            "country_code": null
        },
        "pdp_context": {
            "ci": null,
            "apn": null,
            "lac": null,
            "mcc": null,
            "mnc": null,
            "rac": null,
            "sac": null,
            "imsi": null,
            "nsapi": null,
            "imeisv": null,
            "region": null,
            "rx_teid": null,
            "rat_type": null,
            "tariff_id": null,
            "breakout_ip": null,
            "gtp_version": null,
            "operator_id": null,
            "ratezone_id": null,
            "ue_ip_address": null,
            "pdp_context_id": null,
            "tunnel_created": null,
            "tariff_profile_id": null,
            "tx_teid_data_plane": null,
            "tx_teid_control_plane": null,
            "ggsn_data_plane_ip_address": null,
            "sgsn_data_plane_ip_address": null,
            "ggsn_control_plane_ip_address": null,
            "sgsn_control_plane_ip_address": null
        }
    }
}

The webhook module will show that it has successfully determined the format.
format_detected
We will now trigger an email on the Integromat platform upon receiving the event. Next to the webhook module in the Integromat scenario, click on the plus sign to add another module.
add_email_as_module
Select the Email module (you can choose any email service like Google email or Microsoft 365 email) and click on Send me an Email. In the subject line, you can choose elements from the event which was read by your Integromat webhook module.
compose_email_1
Click on OK and run your integration once to test it out. you should get an email when your device which has used up all the allocated data, tries to use data again.
File
You can use this template to automate many other events, such as creating an invoice, recharging your account, or checking for activity when the device enters a new country.

Related Posts