Adding IFTTT webhook key to docker

I'm using docker as a first time user on a new home server. I've used Node-red, but it's been at least 5 years since I last messed with it. I've got Node-red running successfully as a container and am in the process of setting up several flows.

The issue I'm having is pulling an environment variable into Nodered. I've been on a lot of websites and message boards, but all fall just short of giving me what I need. I set my webhooks key as a docker environment in the Node-red container, and this is verified. If my key is IFTTTKey="xxx3235a", how do I pull that into a flow without having to enter it directly into Node-red?

A basic http request might be POST Webhooks Integrations - Connect Your Apps with IFTTT. The only information I find on all the various forums, websites, message boards, etc., is to either use ${IFTTTKey} or {{IFTTTKey}}, but neither one works. If I put the key directly into Node-red, it works fine, but I would prefer to keep it as a separate environment variable. Since severalf friends and I share docker configuration set-ups and Node-red flows, I'd really rather not have my key entered into Node-red and just pull it as I need from the environmental file.

Is there a reason that you are using docker? Unless you have a good reason them don't, it just adds complexity.

If you mean that the key will be available as an environment variable then there are several ways of accessing that in the flows. See Using environment variables : Node-RED

I've got several reasons I'm doing it this way.

Ove been on this site several times. That's the last one I was using. For some reason, Node red isn't picking up the variable.

Show us the code you are using to pick it up. What happens if you use an exec node to get the env var?

Try this, it fetches the PATH environment variable and sends it to a debug node.
If that works then change it you your var name.

[{"id":"7b282960a75737cd","type":"inject","z":"bdd7be38.d3b55","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":260,"y":2940,"wires":[["be4767e2a5f8b1f1"]]},{"id":"be4767e2a5f8b1f1","type":"function","z":"bdd7be38.d3b55","name":"Get env var","func":"msg.payload = env.get(\"PATH\")\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":450,"y":2940,"wires":[["83f55b8a2662507b"]]},{"id":"83f55b8a2662507b","type":"debug","z":"bdd7be38.d3b55","name":"debug 2535","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":640,"y":2940,"wires":[]}]

I figured it out. For anyone else who is interested in the final solution:

  1. Edit the settings.js file in your main nodered directory
  2. on the first line, process.env.IFTTTKey = "insert key here" (the quotes are very important!)
  3. In your flow, choose inject (to start the flow off)
    a) change the inject type to env variable (drop-down box) and type IFTTTKey as the string.
    b) change msg.payload to msg.topic
  4. in the html request, instead of entering your key, the line will instead read:
    https://(maker.ifttt.com)/trigger//with/key/{{topic}}
    (take out the ( ) in the line above...it triggered a link instead of what I wanted it to say)

It should trigger whatever function you need. By changing the payload type to topic, you can use the same Key throughout the flow. If you leave the msg.payload as payload, it only works for the first http request, then erases the payload. Changing it to topic (or something else) allows it to persist for that particular flow.

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