Sending arbitrary data via courier push?

Hello there-

We want to have the ability to use courier push to send arbitrary data. For example, we could think of the functionality of trying to add a priority system to our push messages, where priority 1 might be rendered with a red color, whereas priority 2 might be blue. I’ve tried sending data in the request from the backend, but I’m not sure where I would put it in the template so that it propagates down to the end client, because currently it doesn’t appear to do so.

Not sure if there’s an easy way to do what we want here; one work around is encoding this into the brand of the notification but we’d like to avoid that if possible as we may want to use brand for its intended purpose instead.

Hi @jacob :wave: ,

It sounds like you want to supply your own react component to overwrite the rendering for your inbox.

Hi Rodrigo,

We do already have a custom react component, but what we need is a way for the backend that sends the message to signal to the frontend how to render the message. Normally we would put text or a title in the message, but in this case we want to put a custom priority field onto the message somehow at the point that the message is sent from the backend and then have the frontend understand that the message needs to be rendered a certain way.

Thanks,
JM

@jacob did you find a way to send custom data

@rodrigo below is the image of the message object received from the courier for in-app notification


can we pass custom data in the data field

Hi there,

How are you currently passing your custom data in the request? Does your request have a "data’ object?

{
    "message": {
      "template": "NOTIFICATION_TEMPLATE",
      "to": {
        "data": {
          "foo": "bar"
        }
      }
    }
  }

I am passing data object at template level. As you mentioned above I also tried adding data object inside to object which didn’t have any effect.

{
    "message": {
        "template": "NOTIFICATION_TEMPLATE",
        "to": {
            "user_id": "XXXXXXXX",
            "courier": {
                "channel": "XXXXXXXX"
            },
            "data": {
                "title": "title",
                "data": "this is data",
                "imagePath": "https://picsum.photos/200"
            }
        },
        "data": {
            "title": "title",
            "data": "this is data",
            "imagePath": "https://picsum.photos/200"
        }
    }
}

Hi there, you can setup a data mapping template inside the studio. Here you can decide what data from your request will get passed through to the provider.

Thanks, the data is populated. don’t know why previously it wasn’t populated.