SOLVED: Can I inject variables into an expression?

[{"id":"c58f1b32e4c13aec","type":"tab","label":"Flow 1","disabled":false,"info":"","env":[]},{"id":"0ec49712b3fdc8e6","type":"api-call-service","z":"c58f1b32e4c13aec","name":"Call","server":"ab3e2c53.e3491","version":4,"debugenabled":false,"domain":"notify","service":"twilio_calls","target":{"entityId":[],"areaId":[],"deviceId":[]},"data":"{\t   \"message\":'Testing123',\t   \"target\":\"+18675309\"\t}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":440,"y":180,"wires":[[]]},{"id":"6d114073ae9da645","type":"inject","z":"c58f1b32e4c13aec","name":"","props":[{"p":"payload"},{"p":"message","v":"Testing 123","vt":"str"},{"p":"number","v":"18675309","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":235,"y":180,"wires":[["0ec49712b3fdc8e6"]]},{"id":"ab3e2c53.e3491","type":"server","name":"AvilaSmartHome","version":2,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":30}]

I use Twilio to send calls out when certain things are triggered. I am wondering if rather than making a service node for each event, I can have just one service node with variables in the expression.

So heres my service node, that works perfectly fine.

But in a perfect world, I’d want the service node to look like this and then for simplicity sake of the question, an inject node before it that would tell the service node what number to call and what message to say.


Just remove the quotes from the templates ( {{message}} for example).

Edit:
Number would probably need to be something like "target": "+" & {{ number}}

Tried just doing the number first and I got an error message.


image

Sorry…

{
   "message": msg.message, 
   "target":  "+" & msg.number 
}

I just tried it with a notify and the above syntax worked

2 Likes

Sweetness. That worked!