Using Discourse to publish to my Blog

Part of what makes contributing to a Discourse forum a genuine joy for me is the writing experience. Many worthwhile opportunities in my life have stemmed from using this forum software. Why? Of course it was the communities, the social aspect I’ve written about again and again. But I want to give the software some credit here. Discourse’s editor made writing up topics and replies pleasurable, enabling me to participate in communities that I never thought I’d be a part of, in ways I couldn’t anticipate. This gratefulness led to an interesting question.

If you like the Discourse editor so much, why not publish to your blog from it?

So this post here is the product of an answer to that question. I created a simple Glitch app that takes advantage of Discourse’s nifty webhook feature. When the app receives a webhook, it takes the text from the Discourse message and posts it to my blog. But how does it know which message to publish to your blog? Because a webhook is a fire hose of data coming in. This webhook in particular was set to trigger at a Post event. That means every time a post is published or deleted or updated, the webhook will send each post’s data to my Glitch app. Every post action that happened on the forum – a fire hose indeed. So I needed to write some code that would find a droplet from the cascade of water coming from the hose.

My solution? Give the app some if/else logic. If the message sent from the webhook was authored by this user (me) and the message has this title (“Message to myself”), then take the message’s data and make a blog post from it. If not, then don’t do anything with the message. This specificity allowed me to then play around with the message data so that it formatted correctly on my blog.

The app still has some kinks to work through but I thought it exercised a curiosity of mine – being able to publish to my blog from any editor. There are so many text editors out there, each for different purposes and with different strengths to boot. Why not be able to craft some connective tissue in-between so you can publish to your blog from any where? Why not create a hypertext polygraph?