TTN Webhooks Integration with Slack

Hello,

I started using The Things Stack a few months ago and so, still discovering many of the available functionalities. I am struggling with Webhooks Integrations functionalities, and would be grateful if someone could help me :slight_smile:

Task Description:

  1. MKRWAN 1310 send messages to the TTN.
  2. Use TTN Webhooks to send messages to Slack.

Configuration:

  1. An end-device (MKRWAN 1310) is sending messages to the TTN. Messages are decoded in the uplink payload formatters using a custom javascript formatter (decodedUplink) function.
  2. Example of a receive message is as follow:
 "received_at": "2023-06-21T12:00:01.843661970Z",
    "uplink_message": {
      "session_key_id": "Axxx...",
      "f_port": 2,
      "f_cnt": 122,
      "frm_payload": "U3RhdHVzIEFjdGl2ZQ==",
      "decoded_payload": {
        "msg": "Status Active"
      },
  1. Webhook has been configured in Slack to be sent to a Slack channel called “lora-test”. Following this Slack tutorial - Sending messages using Incoming Webhooks | Slack. Testing the sample curl request provided by Slack directly from a terminal, a “Hello, World!” message is received in the Slack Channel.
curl -X POST -H 'Content-type: application/json' --data 
'{"text":"Hello, World!"}' 
https://hooks.slack.com/services/Txxx/Bxxx/zxxx
  1. Creating a new custom webhook in the TTN using as BaseURL https://hooks.slack.com/services/Txxx/Bxxx/zxxx and ticking the uplink message box by replacing /path/to/webhook with Txxx/Bxxx/zxxx no messages arrived in the Slack channel.
  2. Testing if messages from TTN are sent using the webhook.site ( https://webhook.site ) mentioned by @descartes in thread Webhook and Payload Formatter I can confirm that the messages arrive.

So if messages arrived on webhook.site, why are the messages not being received on the Slack Channel?

Note that I am only interested in the “decoded_payload: {msg: “”}” part of the content.

Thank you in advance for your help.
Aude

Flattered, but that’s not my site, just a tool I use - would be useful to know where you saw me mention it so I can try & clarify ownership.

Incompatible data structures - like you sent Kanji to a someone in the UAE - Slack needs at a minimum a key of “text” with the text you want, TTS sends lots of loverly payload information with many key-value pairs and arrays and objects and stuff, but no “text”.

And no, you can’t mash it in to co-operation without going via something that will take the TTS payload & completely re-write it - there are NO facilities on TTS to do so - we can add decoded fields but we can’t complete do over the payload JSON.

You may be able to do a translation with IFTTT or you could setup a AWS Lamba using JQ or if you have your own web space that can run PHP, write a bit of code to do it.

Flattered, but that’s not my site, just a tool I use - would be useful to know where you saw me mention it so I can try & clarify ownership.

Apologise for wording this wrongly. I have corrected my post.

Incompatible data structures

Ok. That is a little be sad. I was thinking it would be easier to extract the payload msg from the TTN. In another application, I am using MQTT - telegraf - InfluxDB to retrieve incoming data from the TTN, I might then look to do something similar.

Many thanks for your help :slight_smile: