Get only media of a tweet and use Alchemy API to analyze the photo and return what it is

This flow read tweets with a specific # and limits the read to tweets that contains images. It analyses the image using Alchemy API and tweet what it is.

[{"id":"57c5b8ca.f495e8","type":"switch","z":"a953c22f.3362b","name":"Only Media","property":"tweet.entities.media","propertyType":"msg","rules":[{"t":"nnull"}],"checkall":"true","outputs":1,"x":305,"y":283,"wires":[["cd5004e4.be2b7"]]},{"id":"cd5004e4.be2b7","type":"switch","z":"a953c22f.3362b","name":"Only Photos","property":"tweet.entities.media.0.type","propertyType":"msg","rules":[{"t":"eq","v":"photo","vt":"str"}],"checkall":"true","outputs":1,"x":492,"y":283,"wires":[["e4b2c73c.c2b4b"]]},{"id":"e4b2c73c.c2b4b","type":"change","z":"a953c22f.3362b","name":"Send Image URL","rules":[{"t":"set","p":"payload","pt":"msg","to":"tweet.entities.media.0.media_url","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":728.5,"y":282.5,"wires":[["b86d2462.ffa8e"]]},{"id":"a398360a.c2f78","type":"debug","z":"a953c22f.3362b","name":"","active":true,"console":"false","complete":"result","x":911,"y":497,"wires":[]},{"id":"e82db1b3.4bfbe8","type":"twitter out","z":"a953c22f.3362b","twitter":"","name":"Tweet","x":527,"y":420,"wires":[]},{"id":"b86d2462.ffa8e","type":"alchemy-image-analysis","z":"a953c22f.3362b","name":"","apikey":"ef72cfa5d20dc721d032dc5a98b59e297b017486","image-feature":"imageKeywords","x":966,"y":282.5,"wires":[["a398360a.c2f78","62f53a73.14dee4"]]},{"id":"1ce2167d.672422","type":"twitter in","z":"a953c22f.3362b","twitter":"","tags":"what_is_it_pp","user":"false","name":"what_is_it_pp","topic":"tweets","x":104,"y":282,"wires":[["57c5b8ca.f495e8"]]},{"id":"62f53a73.14dee4","type":"change","z":"a953c22f.3362b","name":"Send to Payload","rules":[{"t":"set","p":"payload","pt":"msg","to":"result","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":130,"y":356,"wires":[["fde30523.7fff98","c7b28043.90b69","527f0649.c6d238"]]},{"id":"fde30523.7fff98","type":"function","z":"a953c22f.3362b","name":"","func":"msg.payload= \"@\" + msg.topic.slice(7,30) + \" I think this is a \" + msg.payload[0].text;\nreturn msg;","outputs":1,"noerr":0,"x":366,"y":366,"wires":[["c7551aa4.78722"]]},{"id":"c7551aa4.78722","type":"twitter out","z":"a953c22f.3362b","twitter":"","name":"Tweet","x":530,"y":367,"wires":[]},{"id":"c7b28043.90b69","type":"function","z":"a953c22f.3362b","name":"","func":"msg.payload= \"@\" + msg.topic.slice(7,30) + \" and/or a \" + msg.payload[1].text;\nreturn msg;\n","outputs":1,"noerr":0,"x":364,"y":420.5,"wires":[["e82db1b3.4bfbe8"]]},{"id":"527f0649.c6d238","type":"function","z":"a953c22f.3362b","name":"","func":"msg.payload= \"@\" + msg.topic.slice(7,30) + \" and/or a \" + msg.payload[2].text;\nreturn msg;\n","outputs":1,"noerr":0,"x":369,"y":482,"wires":[["cfe64f74.9826d"]]},{"id":"cfe64f74.9826d","type":"twitter out","z":"a953c22f.3362b","twitter":"","name":"Tweet","x":530,"y":482,"wires":[]}]
priscillaparodi

Flow Info

created 9 months ago

Node Types

Core
  • change (x2)
  • debug (x1)
  • function (x3)
  • switch (x2)
  • twitter in (x1)
  • twitter out (x3)
Other

Tags

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