TWITTER

The Twitter integration connects your Roam graph to Twitter! The name of the script is twitter.

Installation

You could use the Copy Extension button below to individually install this extension. To install, just paste anywhere in your Roam graph and click "Yes, I Know What I'm Doing".

Manual Installation

If instead you prefer to manually install, first create a block with the text {{[[roam/js]]}} on any page in your Roam DB. Then, copy and paste this code block as a child of the block.

var existing = document.getElementById("twitter");
if (!existing) {
  var extension = document.createElement("script");
  extension.src = "https://roamjs.com/twitter.js";
  extension.id = "twitter";
  extension.async = true;
  extension.type = "text/javascript";
  document.getElementsByTagName("head")[0].appendChild(extension);
}

Usage

The Twitter extension supports a few features, including sending and searching tweets.

Sending Tweets

When navigating to a roam/js/twitter page, a log in with Twitter button will be rendered on the screen.

Clicking the button will create a popup window, prompting you to authorize RoamJS to be able to send tweets on your behalf. You may need to allow popups from Roam for this to work. After authorizing RoamJS, a block will be created in your roam/js/twitter page:

This block contains access tokens that RoamJS could use to send Tweets. DO NOT SHARE THIS BLOCK WITH ANYONE.

To send a tweet, create a {{tweet}} button and nest the content of the tweet as a child.

The button will be replaced with a Twitter icon. Clicking the icon will render an overlay with a "Send Tweet" button.

Clicking "Send Tweet" will send the first child as the content of the Tweet!

If the tweet button has multiple children, clicking "Send Tweet" will send each block as a tweet as part of a single Tweet thread.

If you include an image, gif, or video in the block, that piece of media will be sent as an attachment of the tweet! The ![](url) block text will be stripped from the tweet content.

After Sending

It could be useful to denote which blocks in Roam have already been sent as tweets. On the roam/js/twitter page, you could add a block that says 'Sent' with a block reference as a child.

This will move all the blocks sent as children of this block upon sending.

The label by which Sent tweets are nested under could be configured with a block that says 'Label'.

The child of that block will be used as the label. {now} will be replaced with the time the tweet was successfully sent.

Instead of moving blocks, tweeted blocks could also be edited upon sending. This could be configured with a block that says 'Append Text'.

The child will be appended to the end of the tweeted block. {link} will be replaced with the link of the created tweet.

Demo

Searching Tweets

The script supports the following configuration attributes, to be added in the [[roam/js/twitter]] page:

  • Username - (Required) This is your twitter handle.

Here's an example configuration page:

In any page, create a Twitter References button by typing in {{twitter references}} (case-insensitive) in a block. Upon clicking the button, the extension will clear the button and fill the page in with the tweets where you've mentioned that page title. So, if you've tweeted about books a lot on twitter, you can head over to the books page on roam, and then pull all your tweets about books!

One caveat is that this can only pull tweets made in the last 7 days.

Demo

Contributors

A special thanks to those who's contributions helped make this extension possible:

Emoji Key

Other Extensions