If you're trying to do this, you came to the right place!
See this code in action here: https://twitter.com/CodingDoug/status/948225623939473413
These instructions assume that you already have a Firebase project, and you've provisioned Firestore in it.
-
Create a project workspace with the Fireabse CLI with Hosting, Firestore rules, and Functions enabled (with TypeScript).
-
Allow global read no write access to Realtime Database and Storage. Copy
firestore.rules
from this gist over the one in your project. -
Copy
index.html
andfollow.js
to yourpublic
web content folder. -
Copy
index.ts
to thefunctions/src
folder. -
npm install firebase-functions firebase-admin moment
-
Deploy everything with
firebase deploy
. Note the public URL of the "iffft" function. -
Create an account with IFTTT.
-
Create a new applet. For "this", select "Twitter", then "New tweet from search". Authorize IFTTT to use a Twitter account to perform searches.
-
Type the search term you want to receive results for (e.g. Firebase).
-
For "that", select "Webhooks", then "Make a web request"
-
URL: The public function url from the earlier deploy
-
Method: POST
-
Content Type: text/plain
-
Body: use the following text with no extra whitespace and on a single line:
text={{Text}}|*|*|firstLinkUrl={{FirstLinkUrl}}|*|*|userName={{UserName}}|*|*|userImageUrl={{UserImageUrl}}|*|*|linkToTweet={{LinkToTweet}}|*|*|tweetEmbedCode={{TweetEmbedCode}}|*|*|createdAt={{CreatedAt}}
-
Save the applet.
-
Keep an eye on your functions logs to see when it gets invoked. It may take a few minutes to get the first one.
-
The IFTTT applet for Twitter search will periodically call the function endpoint with the payload. The payload contains all available "ingredient" values. (Note: IFTTT doesn't know how to escape strings for use in JSON, which is why I'm choosing to use a delimited string to deliver them as key/value pairs.)
-
When the function is invoked, it will parse the body payload, massage the incoming data, and write a document to Firestore in the
tweets
collection. -
The web client is always listening to
tweets
, so when a new document becomes available, it will render a new tweet to the list, inserting it at the top. -
You can have multiple applets each delivering results for diffrent searches to the same function (e.g. one for Firebase and another for Firestore). It will aggregate the results for all of them in the same place.
Hi, I've a small problem, I tried running this and got the following error after giving the "firebase deploy" command:
Error: HTTP Error: 400, This operation is not available for Cloud Firestore projects in Datastore Mode.
Could anyone please help me out? I'm a newbie. I'm trying to use this in firebase project to stream tweets in realtime. Thanks in advance