Hi all,
I'm trying together with Peter to get this thing going. As mentioned in the tickets we indeed have a learning curve....
From the suggested approaches I've tried two paths. One in a regular function, and the other a 'change' node.
However, we still struggle with the result.
But let me first write down some facts.
-
Our data is coming from a SQL query. This query results in an array looking like this:
[{"zoektekst":"A1 XXXX YYY : 15146","city_id":15023,"lat":52.0533,"lon":4.48868}]
also:
[
{
"zoektekst": "A1 XXXX YYY : 15146",
"city_id": 15023,
"lat": 52.0533,
"lon": 4.48868
}
]
-
My first approach was a function:
if (msg.payload[0].zoektekst !== undefined)
{
var bla_lon = msg.payload[0].lon;
var bla_lat = msg.payload[0].lat;
msg.payload = {
name : "latitude",
content : {}
};
msg.payload = {
name : "longitude",
content : {}
};
msg.payload.content.longitude = bla_lon;
msg.payload.content.latitude = bla_lat;
return msg;
}
However, we could not get that filled properly.
-
Tried with a 'change node' to get the variables filled with the following 'SET' rules:
msg.payload.content.longitude
to
msg.payload[0].lat
msg.payload.content.latitude
to
msg.payload[0].lon
msg.payload.zoektekst
to
msg.payload[0].zoektekst
The last item 'msg.payload.zoektekst' does get properly set, and this value we can use within the Telegram template using:
{
"chatId": "-000000",
"type": "message",
"content": "{{{ payload.zoektekst }}}",
"options": {
"parse_mode": "MarkdownV2"
}
}
however, using the same approach, the lon/lat do not get filled if we use another Telegram template with:
{
"chatId": "-419956486",
"type": "location",
"content": "{{{ payload.content }}}"
}
resulting in:
{"chatId":"-419956486","type":"location","content":"[object Object]"}
So if I / we interpreted the suggestions correctly to get the required values in their proper positions with correct properties we should be in the correct direction, but we are missing something...
Please have a quick look, and if we are missing something obvious please let us know... (from our code you guys most probably can guess we are no programmers...)
Many thanks in advance,
Ron