Build a Twitter logger


This Twitter logger guide will walk you through both read and write integrations with a Portway project. While funneling the raw madness of Twitter into a Portway document may be a questionable endeavor, it does demonstrate how to use Portway as a two-way street, with data in and out.

This integration will allow you to add a tweet url in a Portway document and see replies to the tweet automatically written to the document.

Setup Overview

This guide will walk you through the following setup:

Setting up the Tweet Logger

Create a Twitter app

  1. Sign up and apply for a Twitter Developer Account. Access to the Standard APIs should be approved quickly. You will need a Twitter account.
  2. Once you have an approved Twitter Developer Account, create a new Twitter app. Many of the fields are not required.
  3. Save the Twitter app's API key and API secret key. You will need these to use the Twitter API.

Setup the Portway Tweet Logger app

  1. Clone the Portway Tweet Logger

This assumes you have nvm installed and running locally.

Run the following commands in your terminal:

$ git clone
$ cd portway-tweet-logger
$ nvm use
$ npm install
$ cp example.env .env
  1. Open the .env file in an editor to add the Twitter API keys
    TWITTER_API_KEY=[Value from step 3]
    TWITTER_API_SECRET=[Value from step 3]

Setup a Portway project

  1. Create a Portway project for Tweet logging
  2. Navigate to the Project Settings page and choose the "API Keys" from the menu
  3. Select "Add Project Key" and give your key a name, such as "Portway Twitter Key." Make sure your key has the "Contributor" role so it can read and write data to your project.
  4. Copy the key and in your .env file you edited in Step 5, add the value to PORTWAY_KEY=key
  5. Now add the PORTWAY_PROJECT_ID=projectId to the .env file as well. You can find the project id by looking at the url in Portway when you're viewing the project. You will see a url like, the number after project/ is the project ID.

Run the Portway Tweet Logger app

  1. You should now be able to run the Portway Tweet Logger script, which will periodically check for new documents in your project. From the directory where you cloned the app in Step 4, run npm start

Let's log some Tweets!

Ok, you should now have the Portway Tweet Logger running in your terminal. You should see output logging each attempt to find tweet documents.

Logging a Tweet

  1. In your Portway project, add a new document.
  2. Create a new "String" data field by clicking the "+" icon in the bottom toolbar
  3. Rename the field tweet and set the value to the url of any* Tweet
  4. Open the document outline mode by clicking the gear icon in the upper right. Delete all other fields in the document besides your "tweet" string. By default, new documents will have a text area that needs to be deleted.
  5. Publish your document!
  6. Now watch the Portway Tweet Logger in your terminal, you should see it find the new document. As soon as it does, refresh the document in the Portway app. It will now have additional fields added and replies, if found.

You can keep the Tweet logger script running as long as you want and continue to publish new documents with new Tweets.

The joy of logging Tweets

Now you've gotten a glimpse of the ability to both read and write data from a Portway document. While we don't recommend attempting to log every Tweet published on Twitter (Twitter's API rate limits and Portway's API rate limits won't let you anyway, sorry), the ability to interact with Portway projects through both human and machine interactions can be very powerful.

  • Note that due to Twitter API limitations, to get Tweet replies the Tweet should be from the last 7 days. Replies are most likely to be found on an account that doesn't get too many @mentions, otherwise replies may not be findable through the limited Twitter search API.