Search code examples
telegram-botnode-red

Node Red send IP to Telegram BOT


I really need help since I do not understand how to solve this problem.

I want to be able request my public ip with the help of Node Red and Telegram. I want to send /ip in my Telegram Bot and then I would like to get the response back to the same channel.

As you can see on the picture I use an IP function that fetch my IP:

2022-07-19 22:29:2 9node: debug 1
msg.payload : Object
{ 
   internalIPv4: "192.168.1.244", 
   internalIPv6: undefined, 
   publicIPv4: "XXX.XXX.XXX.XX"
}

But my Telegram Sender only give me

2022-07-19 22:29:29node: 0cc0a76d4b287f23
msg : string[25]
"msg.payload.type is empty"

How do I solve this issue. I want to get my IP as the message reply. Does any one know how to solve this?enter image description here


Solution

  • I missed that I needed to insert a function after IP.

    var mess = msg.payload.publicIPv4;
    
    msg.payload = {
        chatId: 'XXXXXXX',
        type: 'message',
        content: mess
    }
    
    return msg;