Send An Adaptive Card from Designer

Design your card using variables

Copy Paste the json on the template node (format: mustache, output: json)

Set variables before the card

set the text message parameters after the card

for urls, encode it before, using https://www.url-encode-decode.com/

[{"id":"7f63bb84.863d34","type":"change","z":"8eb50c91.720f5","name":"Set Data","rules":[{"t":"set","p":"stock.name","pt":"msg","to":"Amazon.com, Inc. (NASDAQ: AMZN)","tot":"str"},{"t":"set","p":"brand","pt":"msg","to":"https%3A%2F%2Fwww.marketplace.org%2Fwp-content%2Fuploads%2F2019%2F07%2Fama2.png","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":280,"y":160,"wires":[["bcd47449.c24b68"]],"info":"Encoded URL"},{"id":"bcd47449.c24b68","type":"template","z":"8eb50c91.720f5","name":"Card template from designer","field":"card","fieldType":"msg","format":"json","syntax":"mustache","template":"{\n    \"$schema\": \"http://adaptivecards.io/schemas/adaptive-card.json\",\n    \"type\": \"AdaptiveCard\",\n    \"version\": \"1.3\",\n    \"speak\": \"Amazon stock is trading at $62.30 a share, which is down .32%\",\n    \"body\": [\n        {\n            \"type\": \"Image\",\n            \"url\": \"{{brand}}\",\n            \"size\": \"Large\",\n            \"horizontalAlignment\": \"Center\"\n        },\n        {\n            \"type\": \"Container\",\n            \"items\": [\n                {\n                    \"type\": \"TextBlock\",\n                    \"text\": \"{{stock.name}}\",\n                    \"size\": \"Medium\",\n                    \"isSubtle\": true\n                },\n                {\n                    \"type\": \"TextBlock\",\n                    \"text\": \"September 19, 4:00 PM EST\",\n                    \"isSubtle\": true\n                }\n            ]\n        },\n        {\n            \"type\": \"Container\",\n            \"spacing\": \"None\",\n            \"items\": [\n                {\n                    \"type\": \"ColumnSet\",\n                    \"columns\": [\n                        {\n                            \"type\": \"Column\",\n                            \"width\": \"stretch\",\n                            \"items\": [\n                                {\n                                    \"type\": \"TextBlock\",\n                                    \"text\": \"75.30\",\n                                    \"size\": \"ExtraLarge\"\n                                },\n                                {\n                                    \"type\": \"TextBlock\",\n                                    \"text\": \"▼ 0.20 (0.32%)\",\n                                    \"size\": \"Small\",\n                                    \"color\": \"Attention\",\n                                    \"spacing\": \"None\"\n                                }\n                            ]\n                        },\n                        {\n                            \"type\": \"Column\",\n                            \"width\": \"auto\",\n                            \"items\": [\n                                {\n                                    \"type\": \"FactSet\",\n                                    \"facts\": [\n                                        {\n                                            \"title\": \"Open\",\n                                            \"value\": \"62.24\"\n                                        },\n                                        {\n                                            \"title\": \"High\",\n                                            \"value\": \"62.98\"\n                                        },\n                                        {\n                                            \"title\": \"Low\",\n                                            \"value\": \"62.20\"\n                                        }\n                                    ]\n                                }\n                            ]\n                        }\n                    ]\n                }\n            ]\n        }\n    ],\n    \"backgroundImage\": {\n        \"horizontalAlignment\": \"Right\",\n        \"verticalAlignment\": \"Center\"\n    },\n    \"verticalContentAlignment\": \"Bottom\"\n}","output":"json","x":480,"y":160,"wires":[["544c770a.0d6878","3f3764b8.b5811c"]],"info":"Use designer to create your adaptive Card:\nhttps://adaptivecards.io/designer/\n\nFor variables, use {{varname}}\n\nexample:\n`                {\n                    \"type\": \"TextBlock\",\n                    \"text\": \"{{name}}\"\n                },`\n"},{"id":"544c770a.0d6878","type":"function","z":"8eb50c91.720f5","name":"","func":"msg.roomId = \"!LAMIpamyCBxUOVQhii:m.tekos.co\"\n\nmsg.url = \"https://\"+env.get(\"BASE_URL\")+\"/_matrix/client/r0/rooms/\"+msg.roomId+\"/send/m.room.message?access_token=\"+env.get(\"TEKOS_BOT_TOKEN\");\nmsg.payload={\n    \"body\": \"\",\n    \"msgtype\": \"m.text\",\n//     \"composer\": true,\n    \"adaptiveCard\":msg.card\n}\n\n\nreturn msg;\n","outputs":1,"noerr":0,"x":670,"y":160,"wires":[["da3a8dc4.e274d"]]},{"id":"da3a8dc4.e274d","type":"http request","z":"8eb50c91.720f5","name":"","method":"POST","ret":"txt","paytoqs":false,"url":"","tls":"","persist":false,"proxy":"","authType":"","x":810,"y":160,"wires":[["546051b4.d9789"]]},{"id":"546051b4.d9789","type":"debug","z":"8eb50c91.720f5","name":"success","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":960,"y":160,"wires":[]},{"id":"c93c388f.040b48","type":"inject","z":"8eb50c91.720f5","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":140,"y":160,"wires":[["7f63bb84.863d34"]]},{"id":"3f3764b8.b5811c","type":"debug","z":"8eb50c91.720f5","name":"success","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":649,"y":100,"wires":[]}]

Flow Info

Created 5 years ago
Rating: not yet rated

Owner

Actions

Rate:

Node Types

Core
  • change (x1)
  • debug (x2)
  • function (x1)
  • http request (x1)
  • inject (x1)
  • template (x1)

Tags

Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option