JSON type in Telegram

Describe the problem/error/question

Hello, I’m new to N8N and I’m having a problem that I don’t know how to solve.

I’m creating a system where the user sends a Token on the Telegram Channel or Group, and when I receive it I need to get the ID, Type (channel or group), and Text to check if the Token is the same as the one generated on my platform.

However, the Channel and Group JSON are different, and I cannot use a switch to perform an action if it is a Channel or a Group.

Below are the formats received by Telegram.

Group:

[
{
“update_id”: 898806400,
“message”: {
“message_id”: 41,
“from”: {
“id”: xxxxxxxxx,
“is_bot”: false,
“first_name”: “John Souza”,
“username”: “JohnGyn91”,
“language_code”: “en”
},
“chat”: {
“id”: -xxxxxxxxxx,
“title”: “Aposta Certa Grupo”,
“type”: “group”,
“all_members_are_administrators”: true
},
“date”: 1698348166,
“text”: “IU-65”
}
}
]

Channel

[
{
“update_id”: 898806401,
“channel_post”: {
“message_id”: 28,
“sender_chat”: {
“id”: -xxxxxxxxxxxxx,
“title”: “Aposta Certa Canal”,
“type”: “channel”
},
“chat”: {
“id”: -xxxxxxxxxxxx,
“title”: “Aposta Certa Canal”,
“type”: “channel”
},
“date”: 1698351671,
“text”: “IU-67”
}
}
]

I can’t send the flow here, as I can’t get past the first step.

I would be very grateful if someone could help me

Hey @JohnGyn,

One thing you can do is check what type it is using chat.type. Based on the type, you can then move forward with your flow.

2 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.