Twitter scrape and count triggers signal

This flow searches Twitter for certain hashtags (in this case water and fail), pushes the Tweet to an output and counts the number of Tweets retrieved. After 5 Tweets, it triggers a signal and resets the counter. It's part of a project that will grow, which will interact with an RPi to control a valve to release water on an accumulation of Tweets.

[{"id":"188722c.7e1afdd","type":"function","name":"Process Tweet","func":"// is it possible to set this to a variable that  is then\n// counted by the other function and then fed back in\n// iteratively??\n// initialise the counter to 0 if it doesn't exist already\ncontext.count = context.count || 0;    \ncontext.count += 1;\n// make it part of the outgoing msg object\nmsg.count = context.count;\nif (msg.count >= 5) {\n  msg.pour = true\n  context.count = 0\n} else {\n  msg.pour = false\n}\nreturn msg;","outputs":"1","x":294,"y":200,"z":"70a58b06.45bd64","wires":[["ad7f9f55.8be2f8"]]}]

Flow Info

Created 10 years, 4 months ago
Updated 9 years, 3 months ago
Rating:

Owner

Actions

Rate:

Node Types

Core
  • function (x1)

Tags

  • twitter
  • count
  • signal
  • trigger
  • reset
  • counter
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option