Cannot get TTN Webhook integration to forward sensor data to Azure function

Hi,

I have followed 2 different guides on setting up Azure IoT Central bridge for The Things Network but seem to have issue with the TTN Webhook integration. I have managed to stream sensor data to TTN from two different nodes ( Tektelic Smart Room Sensor - Base and Microchip rn2483a). However, it seems the data cannot be forwarded to my Azure function through the TTN Webhook integration as nothing happens in the output log of my Azure function and there is no data in my Azure application. View attached image to se my Webhook integration setting.
webhook setting

I got the Base URL from Function app → Functions → Code + Test → Get function URL

The guides I have followed are the following: Azure IoT Central bridge for The Things Network – Sander van de Velde
Deploy the Azure IoT Central device bridge | Microsoft Docs

I hope you can help with this one!

Kind regards,
Sohran

You haven’t Enabled any messages …

Thanks Nick!

How do I enable messages? What do I have to fill in more? I am pretty new to TTN and IoT in general.

Please suggest a solution and send some informative links if you have some, would really appreciate it!

I’m not sure this is really a TTN or IoT thing, more a Homer Simpson moment.

If you look at your own screen shot you should see the answer staring you in the face, hopefully the check boxes under the words Enabled messages will cause the “Doh” moment.

@kschiffer: perhaps that hint can be made a bit more clear. Maybe we can make it

Select the message types for which you want to trigger this webhook. For each enabled message type, an optional path can be defined which will be appended to the base URL.

2 Likes

Or if anyone tries to save the settings without enabling anything it pops up a “are you sure” dialog.

Thanks guys, I noticed my “Doh” mistake :upside_down_face: Now, my azure function is getting triggered, however I get the following error: Cannot read property ‘toLowerCase’ of undefined.

This is the code I have added just before handleMessage:
req.body = {
device: {
deviceId: req.body.hardware_serial.toLowerCase()
},
measurements: req.body.payload_fields
};

Any suggestion on what is going wrong?

This looks like a vanilla JavaScript error on Azure, so not TTN issue really.

But it is saying that the req.body.hardware_serial isn’t defined. I don’t recognise that as any of the JSON that is sent by a WebHook.

To get it to work I had do change the code to the following:

req.body = {
    device: {
        deviceId: req.body.**end_device_ids**.**device_id**
    },
    measurements: req.body.**uplink_message**.**decoded_payload**
};

I noticed the necessary changes (highlighted in the code) I needed to make by first outputing the incoming message body using context.log(req.body); which gave me the following output:

[Information] { end_device_ids:{ device_id: ‘647fda00000053c7’,application_ids: { application_id: ‘58-a0-cb-ff-fe-80-2b-0e’ },dev_eui: ‘647FDA00000053C7’,join_eui: ‘647FDA8010000100’,dev_addr: ‘260B003F’ },correlation_ids:[ ‘as:up:01F9EJJMHH4MNRY9T1FZWESQBA’,‘ns:uplink:01F9EJJMAT2HB7CF0T85HNS3PA’,‘pba:conn:up:01F993GZ60XW1CC91B2200N3MT’,‘pba:uplink:01F9EJJMAPCV60M0MJ4Y6VDH5K’,‘rpc:/ttn.lorawan.v3.GsNs/HandleUplink:01F9EJJMATN68ZVCH8XA0RPGKT’,‘rpc:/ttn.lorawan.v3.NsAs/HandleUplink:01F9EJJMHG3AFN9N46CN0YBKV9’ ],received_at: ‘2021-06-30T13:43:46.994031808Z’,uplink_message:{ session_key_id: ‘AXpSUBNK/MOoAdXsWk8/yw==’,f_port: 10,f_cnt: 194,frm_payload: ‘AQAACAQAAQ==’,decoded_payload: { reed_count: 1, reed_state: 0 },rx_metadata: [ [Object] ],settings:{ data_rate: [Object],data_rate_index: 5,coding_rate: ‘4/5’,frequency: ‘867500000’ },received_at: ‘2021-06-30T13:43:46.778399431Z’,consumed_airtime: ‘0.056576s’,version_ids:{ brand_id: ‘tektelic’,model_id: ‘t000489x-smart-room-base’,hardware_version: ‘D’,firmware_version: ‘D’,band_id: ‘EU_863_870’ } } }

I highlighted the parameters that I used in the code to extract the necessary information in order to forward data to my central application.
It does work now but not sure if this was the proper way to do it :slight_smile: