Using the Zapier Discourse Zap Templates

Zapier has released 10 official Discourse zap templates. These templates make it possible to connect Discourse with an external application with minimal configuration. You can find them here:

Scroll down that page to see the list of the currently available integrations.

These templates are divided into two types. In the first type, Discourse is the trigger app. These templates allow you to publish Discourse posts to Slack, Mattermost, Discord, Rocket.Chat, Facebook Groups, Facebook Pages, and Twitter. In the second type of template, Discourse is the action app. With these templates you can publish posts from WordPress, and Ghost to Discourse. There is also a template for publishing Twitch live streams to Discourse.

Adding your Discourse credentials on Zapier

To use any of the Zapier Discourse integrations, you will need to add your forum’s base URL, as well as your Discourse username and API Key when you first setup the Zap.

For most cases, the Zap should be configured by a site admin with their Discourse username and API Key. API Keys can be generated on Discourse in the Permissions section of an Admin / User page. API Keys can be retrieved from that page when they are first created, or from the Admin / API page if you need to retrieve them at a later time.

After adding your Discourse credentials to Zapier, click the Continue button. You should see a Success message on the screen.

Configuring which posts the Zap will retrieve

When Discourse is the trigger app, by default all new posts on your site will trigger the Zap. You can limit the Zap to only be triggered for posts created in a specific topic, or to only be triggered for posts created by a specific user, in the optional ‘Edit Options’ step.

Use the step’s Topic dropdown menu to select a specific topic that should trigger the Zap. When this is configured, only posts created in the chosen topic will be retrieved by Zapier. Use the step’s Author dropdown menu to select a username for the Zap. When configured, only posts created by this user will be retrieved by Zapier.

Adding a filter step for finer control over posts

If the ‘Edit Options’ step doesn’t give you enough control over which posts are used to trigger the Zap, you can add an optional Filter step to the Zap. An example of what can be done with a Filter is that you could choose to only have the Zap continue if the post is the first post in a specific category. To add a Filter, click the :heavy_plus_sign: icon that’s below the Trigger, and then select ‘Filter’ from the menu.

The filter will allow you to set the conditions under which the Zap should continue. The example below will only continue if the post is the first post in a topic that is in the category with an ID of 2.

Selecting the Discourse content to publish

When publishing posts from Discourse to another application, Zapier will allow you to select which part of the post you’d like to publish. What you choose to publish will depend on the application you are publishing to. I’ll use publishing a Discourse post to a Facebook Group as an example.

The form’s Message field sets the content that will be published. To publish the full post content, select the ‘Raw’ field from the Message dropdown. To just publish the topic’s title, select ‘Topic Title’ from the dropdown.

Constructing a link to a post or a topic

When publishing a Discourse post to an external application, you may need to construct a link to the post or its topic from the data that is returned from Discourse. To do this, enter your site’s base URL into the field you’re adding the link to, followed by /t/. For example, if your site’s URL is https://discourse.example.com, enter https://discourse.example.com/t/ into the form.

Now open the field’s dropdown menu and select Topic Slug from the menu.

Zapier will add a placeholder for the topic slug to the field.

Now enter a slash (/) after the topic slug placeholder and then select Topic ID from the dropdown menu.

The final result will look similar to the screenshot below.

To construct a link to specific posts in a topic, add another slash (/) to the field and then select Post Number from the menu.

Note that the values of any placeholders you use in setting up the Zap will be replaced by the values passed from Discourse when a new post is published.

Creating integrations without a template

The Zapier templates that are listed on their integrations page are designed to make it easy to connect Discourse with an external application. If you would like to connect Discourse to an application that doesn’t have a template, or if you would like to create a Zap that listens for a Discourse webhook, or makes a POST request to the Discourse API, you can do that by following or modifying one of the guides listed here:

15 Likes

Getting the following on the add credentials zapier screen

We hit an error adding your new account

authentication failed: Error code 500: {“status”:500,“error”:“Internal Server Error”}

All details are correct.

Discourse reports successful use of the API key:

And the following error log:

Message

Draft::OutOfSequence (Draft::OutOfSequence)
/var/www/discourse/app/models/draft.rb:124:in `get'

Backtrace

/var/www/discourse/app/models/draft.rb:124:in `get'
/var/www/discourse/lib/topic_list_responder.rb:11:in `respond_with_list'
/var/www/discourse/app/controllers/list_controller.rb:152:in `block in generate_message_route'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/actionpack-6.0.3/lib/action_controller/metal/basic_implicit_render.rb:6:in `send_action'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/actionpack-6.0.3/lib/abstract_controller/base.rb:195:in `process_action'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/actionpack-6.0.3/lib/action_controller/metal/rendering.rb:30:in `process_action'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/actionpack-6.0.3/lib/abstract_controller/callbacks.rb:42:in `block in process_action'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activesupport-6.0.3/lib/active_support/callbacks.rb:135:in `run_callbacks'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/actionpack-6.0.3/lib/abstract_controller/callbacks.rb:41:in `process_action'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/actionpack-6.0.3/lib/action_controller/metal/rescue.rb:22:in `process_action'

Env

HTTP HOSTS: discuss.bevry.me

Running 2.5.0.beta4 ( 811bc3544f )


That said, refreshing the add zap page that prompted the popup, results in the following:

So seems it was added successfully despite the error


However, selecting one of the added entries just prompts the auth flow again:

2 Likes

Are you using a Discourse All Users API Key and the username of an admin user on your site? I am not sure if that is what is required, but I setup a new Zapier Discourse account with admin API credentials last week. It worked for me then.

1 Like

We ran across this issue as well.

It is now edit: was impossible to do anything (well, a lot) with a user with a negative ID, due to this change:

@tgxworld It would be cool if it was possible to disable this new behavior, and/or to whitelist accounts.

3 Likes

That was a bug and has been fixed in

3 Likes

It was indeed something we ran into yesterday :laughing: .
Thanks!! (and I should have checked before making this post)

3 Likes