Posting to a Discourse forum from iOS Shortcuts

how-to
shortcuts

(Mark Alldritt) #1

UPDATE: See also: Posting to a Discourse forum using AppleScript.

I’ve been experimenting with accessing the Discourse API using various scripting systems. I’ll post my AppleScript code shortly, but today I’m going to show you how to do this using iOS Shortcuts.

I’ve probably made this more complex than it needs to be, but I felt like I had to break the task up into manageable pieces. The first step is to get the data needed to access the LNS forum:

  • API_ADDRESS - https://forum.latenightsw.com
  • API_USERNAME - your forum username
  • API_KEY - the hex key string needed to access the API - you’ll need to obtain this form the forum operator

I decided to go with a JSON configuration file since Shortcuts has built-in support for JSON files. I placed a file called Discouse.json into my iCloud Drive /Shortcuts folder:

{
	"API_ADDRESS":"https://forum.latenightsw.com",
	"API_KEY":"your-api-key",
	"API_USERNAME": "your-username"
}

From there, I built three Shortcuts to read the various values from this JSON file:

GetAPI_KEY

With these Shortcuts in hand, I wrote a Shortcut to query the forum for the available topic categories and prompt the user to choose a category: “Choose Discourse Category”

And finally, I have the pieces I need to create a shortcut to post a new topic to the forum:

This shortcut is configured to appear in Share sheets and accepts files and text. This way, you can post to Discourse using the Share feature of most iOS apps.

I’m surprised at how powerful Shortcuts is. You have to think in a different way in order to find solutions to seemingly easy problems, but once your mind begins to work in the Shortcuts way, it flows well. I have to say that Shortcuts feels much more tractable than Automator ever did for me.

Anyway, I’ll probably post a few more Shortcuts experiments as time goes on.


Posting to a Discourse forum from AppleScript