Posting to BlueSky using Node-RED

More refined solution - all variables are in the inject node

[{"id":"f6871b4e1aa213a6","type":"inject","z":"dd99f8450c6d098a","name":"","props":[{"p":"text","v":"This is  test post using Node RED","vt":"str"},{"p":"name","v":"name.bsky.social","vt":"str"},{"p":"appPassword","v":"xxxx","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":170,"y":420,"wires":[["7610b4a9a9d2acc2"]]},{"id":"b372b4db22cc3b08","type":"debug","z":"dd99f8450c6d098a","name":"debug 453","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1020,"y":470,"wires":[]},{"id":"26da7c2cbf874038","type":"http request","z":"dd99f8450c6d098a","name":"","method":"POST","ret":"obj","paytoqs":"ignore","url":"https://bsky.social/xrpc/com.atproto.server.createSession","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[{"keyType":"Content-Type","keyValue":"","valueType":"application/json","valueValue":""}],"x":640,"y":420,"wires":[["ae8f8676f19ea089","aad6e2ec64ae6d05"]]},{"id":"0dd74070eaad543e","type":"json","z":"dd99f8450c6d098a","name":"","property":"payload","action":"","pretty":false,"x":490,"y":420,"wires":[["26da7c2cbf874038","63a3342de6697c6e"]]},{"id":"5d3dcdb6c2d70ac6","type":"debug","z":"dd99f8450c6d098a","name":"debug 454","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1030,"y":520,"wires":[]},{"id":"f6ab72588f1cd251","type":"http request","z":"dd99f8450c6d098a","name":"","method":"POST","ret":"obj","paytoqs":"ignore","url":"https://bsky.social/xrpc/com.atproto.repo.createRecord","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[{"keyType":"Content-Type","keyValue":"","valueType":"application/json","valueValue":""}],"x":660,"y":520,"wires":[["5d3dcdb6c2d70ac6"]]},{"id":"a4575fe3c3a7fda8","type":"json","z":"dd99f8450c6d098a","name":"","property":"payload","action":"obj","pretty":false,"x":190,"y":520,"wires":[["230dbb7e57bcfb7d"]]},{"id":"afbf8e17a961ff95","type":"debug","z":"dd99f8450c6d098a","name":"debug 455","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":660,"y":570,"wires":[]},{"id":"5aa74fb53755a2e1","type":"template","z":"dd99f8450c6d098a","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{ \"repo\": \"{{flow.did}}\",\"collection\": \"app.bsky.feed.post\",   \"record\": {       \"$type\": \"app.bsky.feed.post\",\"text\": \"{{text}}\",\"createdAt\": \"{{myymd}}T{{mytimes}}.{{mymillis}}Z\"   } }","output":"str","x":580,"y":470,"wires":[["a4575fe3c3a7fda8","b372b4db22cc3b08"]]},{"id":"32bb10207125f7e9","type":"simpletime","z":"dd99f8450c6d098a","name":"","mydate":false,"myymd":true,"myyear":false,"mymonth":false,"mymonthn":false,"mydom":false,"mydoy":false,"myday":false,"myhourpm":false,"myhour":false,"mytime":false,"mytimes":true,"myminute":false,"myminutes":false,"mysecond":false,"mymillis":true,"myepoch":false,"myrawdate":false,"mypm":false,"x":410,"y":470,"wires":[["5aa74fb53755a2e1"]]},{"id":"ae8f8676f19ea089","type":"change","z":"dd99f8450c6d098a","name":"","rules":[{"t":"set","p":"did","pt":"flow","to":"payload.did","tot":"msg","dc":true},{"t":"set","p":"accessJwt","pt":"flow","to":"payload.accessJwt","tot":"msg","dc":true}],"action":"","property":"","from":"","to":"","reg":false,"x":840,"y":420,"wires":[["8a88406b2a5b1090"]]},{"id":"8a88406b2a5b1090","type":"change","z":"dd99f8450c6d098a","name":"","rules":[{"t":"delete","p":"headers","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":210,"y":470,"wires":[["32bb10207125f7e9"]]},{"id":"230dbb7e57bcfb7d","type":"template","z":"dd99f8450c6d098a","name":"","field":"headers","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{ \"Authorization\":\"Bearer {{flow.accessJwt}}\" }","output":"str","x":340,"y":520,"wires":[["b676a50613a5bc22"]]},{"id":"b676a50613a5bc22","type":"json","z":"dd99f8450c6d098a","name":"","property":"headers","action":"obj","pretty":false,"x":480,"y":520,"wires":[["afbf8e17a961ff95","f6ab72588f1cd251"]]},{"id":"7610b4a9a9d2acc2","type":"template","z":"dd99f8450c6d098a","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{\"identifier\":\"{{name}}\",\"password\":\"{{appPassword}}\"}","output":"str","x":330,"y":420,"wires":[["0dd74070eaad543e"]]},{"id":"63a3342de6697c6e","type":"debug","z":"dd99f8450c6d098a","name":"debug 456","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":640,"y":370,"wires":[]},{"id":"aad6e2ec64ae6d05","type":"debug","z":"dd99f8450c6d098a","name":"debug 457","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":830,"y":370,"wires":[]}]

Doesn't handle putting any links #tags or handles in the text - just plain text only at moment

Commentary on whats going on
You edit inject node with text you want to post, the bksy.social handle - cymplecy.bsky.social in my case and an app password (as explained in 1st post)

It then sends a http request off that returns some values that are needed to do the real post.

I then add in the time and the other variable values needed and make a 2nd http request (to a different endpoint) that does the actual post

A lot of the information I used to find this out came from here

[edit]19Nov 2024
If you want to include mentions of other accounts and #tags - there's another level of complexity to goto -I've done it manually but now trying to do it within the flow!

1 Like