Using Twitter (X) with Drafts [NO LONGER SUPPORTED]

UPDATE: 2023-06-24
It appears that Twitter has now shut down Drafts access to its APIs. As of this time actions that directly integrate with Twitter via the API will no longer work. To send text from Drafts to Twitter, either use the “Share” action and select Twitter’s native app, or use the Tweet with Twitter app action to open the text in the Twitter app’s compose window.

UPDATE: Twitter seems to be phasing out support for direct integration. Details are still not super clear, but we have posted about what we know.

app-icon

  • App Store
  • URL Scheme: twitter://
  • URL Scheme Documentation: Not officially documented

Twitter is wonderful*, but often you may have something you want to share on Twitter but would prefer to avoid getting sucked into your timeline. More so, you may have an idea for a tweet that is not fully formed. Enter Drafts. Drafts is a great place to jot down and craft those pithy witticisms, and its Twitter integration allows you to post directly from Drafts, without ever launching your Twitter client. This article is a brief review of some of your options for using Drafts with Twitter, including sample actions for more advanced integrations, like the Tweet Storm example action that allows you to craft and post entire threads.

* Your mileage may vary

Direct Posting with the Twitter Action Step [NO LONGER SUPPORTED]

Drafts can post directly to Twitter using the Twitter action step. Example action:

The first time you run this action, you will be directed to Twitter to log in and allow Drafts permissions to post to your account.

Configuring Tweet Actions [NO LONGER SUPPORTED]

Multiple Accounts

Twitter action steps support multiple accounts using the Drafts Credentials system. You can duplicate the Tweet action above, edit the action, selecting the “Twitter” step, and change the credential identifier to target a different account.

The identifier can be any value, but all Twitter action steps with the same identifier will use the same credentials (e.g. post to the same Twitter account). In the case of Twitter, I recommend filling in the Twitter handle you want to target. The first time you use each action with a unique identifier, you will be asked to authenticate again via Safari. Be sure you are logged into the correct account in Safari to complete this process and link the action to the correct Twitter handle.

Templates

The Twitter action step has a template. By default, the value of this template is the Drafts’ [[draft]] tag, which will insert the full text of the current draft. It can also be handy to set up alternate actions for live-tweeting events, and similar, where the template is not only the [[draft]] tag, but also contains a hashtag or other content which will automatically be added when used - like [[draft]] #Oscars. This technique is demonstrated in the Tweet #AppleEvent example action.

After Success

Twitter actions are great candidates to use the After Success settings. For example, you might set your Twitter action to archive the draft and assign the tag “tweet” when run, getting the draft tweet out of your inbox, and making it easy to look up all your tweets later using a tag filter.

URL Actions for Twitter Clients

Twitter used to have a vibrant bunch of third-party clients, with great support for URL schemes like Twitterrific and Tweetbot, but those days are gone. The official Twitter app does, however, have basic URL scheme support for creating posts:

Tweet Storm: Composing Full Threads [NO LONGER SUPPORTED]

The Tweet Storm example action is a great tool for composing entire Twitter threads in Drafts.

The action takes a longer draft, splits it up into paragraphs, and composes a Twitter thread, with a separate tweet for each paragraph. The action adds the (1/3), (2/3), etc. numbering common on Twitter theads, and previews the resulting thread for you to confirm. The preview will validate the content to make sure each paragraph will fit in a tweet, and then if you “Continue” post each resulting tweet in the proper reply structure to be a thread.

Very handy when you have a lot on your mind.

Advanced Twitter API Scripting [NO LONGER SUPPORTED]

Drafts exposes the complete Twitter API to scripting via the Twitter object. The API is too broad to cover here, but you can use it to read information from Twitter, download timelines, etc., as well as post a tweet. Below are two sample actions demonstrating advanced use of the API:

  • Tweet Storm: Breaks a longer draft into paragraphs, shows a preview of how it would be tweeted as a multi-tweet threaded tweet storm - and then posts those tweets if a preview is confirmed.
  • Twitter API: Get Likes: Downloads recent favorite/liked tweets for any user and creates a new draft with their content.
  • Import Twitter Search: Prompts for search text, gets a list of matching tweets, and creates a new draft with a list of tweets in Markdown format.
7 Likes