adunkman / dc311rn.com

Quickly check the status of a DC 311 service request
https://www.dc311rn.com
MIT License
6 stars 0 forks source link

Implement twitter bot to reply to @311dcgov. #5

Closed adunkman closed 6 years ago

adunkman commented 6 years ago

Fixes #3.

This is a simple worker that just runs a poll on a setTimeout. Ideally we’d be streaming and replying immediately, but this is good enough for now.

I’m going to run this on my local machine for the first few hours, since I’m not 100% confident in my strategy to prevent duplicate tweets, and that’ll allow me to kill the process really quickly.

adunkman commented 6 years ago

This has been delayed — DC 311’s service request database has stopped updating the OpenData database as of Friday at 7:33am (most recent OBJECTID is 430410 as reported on the OpenData website).

I didn’t anticipate this would happen, but thankfully this twitter bot has a check to make sure that the service request can be looked up before it tweets a link to it. The result is that even though I ran this bot locally, it didn’t reply to any tweets, because none of them were in the OpenData database. 😅

This tipped me off to the issue in the OpenData database — and resulted in a few tweaks to the 404 page to be less confusing in #6.

I’ll be attempting to find who’s responsible for the OpenData databases and trying to see if they know about the 311 problem — but until then, we can’t successfully production test this, and so I’ll be holding off on merging.

(Maybe it’ll give me the opportunity to write some unit tests!).

adunkman commented 6 years ago

Seems like https://twitter.com/OCTODC is responsible for that data set — https://twitter.com/adunkman/status/988430770992812032.

adunkman commented 6 years ago

They replied this morning that the issue had been fixed — our data set seems to be up-to-date again.

I ran this branch locally with production credentials and noticed that searching for your own tweets doesn’t return your tweets, which meant that the twitter bot was attempting to tweet duplicate statuses (Twitter blocks this and returns a 403, but we shouldn’t even be trying). Found a different endpoint that reliably returns your own tweets, resulting in 332076b.

I’m going to run this on my local machine for the first few hours, since I’m not 100% confident in my strategy to prevent duplicate tweets, and that’ll allow me to kill the process really quickly.

My lack of confidence was correct — it didn’t work. 😅

Rebased against master, and this is ready to :shipit:!