Search code examples
node.jsslacknode-red

NodeRed: How to get reply from Slack app interactive message


I'm trying to make it so that NodeRed uses a webhook to send an interactive message to a slack app to ask permission to activate something. I can POST to the webhook without any issues from my custom node, but how do I get the reply?

Do I need to use the "http in" node to create an endpoint Slack can use? Is there a way to handle it from the same node that POSTs the message?

Also, I'm running NodeRed locally. Can I use ngrok so that Slack can access the http endpoint (in case I need to use that)?


Solution

  • You can define your own http endpoints that are private to your custom node, this is how nodes that need to do oAuth handle the callback. Also nodes like the serial port node do this to supply information to the config dialog.

    Make sure to give the endpoint a unique route so it's unlikely to clash with any other nodes.

    You can look at the source for the serial port node here

    How you ensure that Node-RED is safely made accessible from the internet should be a separate question.