Discourse Webhooks and Zapier

Hey, @fantasticfears. I’ve a client who wants to email new users, so this seems to fit the bill.

Does this plugin still work? I see that the user created webhook is added, but it doesnt’ seem to be getting triggered.

I invited a couple users on a closed site and it didn’t get triggered when they logged in with an invite URL nor when they clicked the activation link in email or the activate account button.

3 Likes

The plugin isn’t updated for a long time but it should. I didn’t verify that. Perhaps you can find clues in /logs. It should be triggered when they clicked the invite link.

4 Likes

the plugin (user created webhook) doesn’t work currently. there is no trigger for new registered users and nothing in the /log.

2 Likes

Man, this is a real disappointment. I thought I’d found the solution to my email problems. Anybody able to figure out what’s going on with the plugin and get it fixed?

Ok. That’s a really simple plugin. Unfortunately I don’t know Ruby or how Discourse works under the hood, so I can’t fix it, but I imagine that somebody who does could find the issue and fix it in less than 15 minutes, assuming Discourse didn’t make some major changes.

Do you check the user created type in the configuration panel?

I guess you mean something like this:

yes, it has been checked.

2 Likes

Please try the new build.

3 Likes

thanks for the update, but it doesn’t seem to work correctly (at least for me).

when a new user is created nothing happens for the webhook, it only respond “ok” to pings.

1 Like

If so, I need to look into this. Are you willing to sponsor $100 for a migration?

2 Likes

I’ve successfully managed to use this to post new topics to Twitter.

I was confused that the Webhook does not send the full URL of the topic to Zapier.

Although I managed to manually build the URL, I would love to have on single field with the full absolute topic URL delivered by the Webhook.

Is this possible?

5 Likes

This is late for a reply, but I spent some time today working on this. To get access to the header, follow the steps outlined in the OP - select “Catch Raw Hook” and then add a filter. Configure the filter to only continue if the Headers Http X Discourse Event matches the event you are looking for.

The difficulty I had was that the Catch Raw Hook passes the webhook’s raw body. The final action I’m using needs parsed data from the body. What is working for me is to add a Code action after the filter. On the Code Action modal, select “Run Javascript”:

Zapier will create an inputData object that you can add named properties to. Add a name for your property in the left column. From the right column, select “Catch Raw Hook” from the dropdown menu, and then select “Raw Body”:

Scroll down the page to see a code input:

You then need to replace the sample code with some code that parses the Raw Body and returns an object that has the values you need for your final action. Here’s the code I’m using. The object it returns is being used by the Salesforce integration. Salesforce requires a last name, so if no last name exists, an error is returned:

const parsed = JSON.parse(inputData.raw);
if (parsed.user) {
  const user = parsed.user,
        name = user.name,
        userFields = user.user_fields;
  let firstName,
      lastName,
      company;
  
  if (name) {
    const splitName = name.split(' ');
    firstName = splitName[0];
    lastName = splitName[1]
    }
  if (userFields) {
    company = userFields['10'];
  }
  if (lastName) {
    return {id: user.id,
            username: user.username,
            lastName: lastName,
            firstName: firstName,
            email: user.email,
            company: company
           };
  } else {
    return {error: "Missing last name"}
  }
} else {
  return {error: "A user object was not returned"};
}

To avoid making a failed request in the final action, another Zapier filter can be added. Set that filter to only continue if the error field returned by the javascript does not exist:

You can then add your final action. For selecting the fields to be used in the final action, use the properties returned by the Run Javascript action.

If anyone knows of a more straightforward way of doing this, let me know.

10 Likes

Request:

New trigger category:
Log events

User selects which log events trigger webhhooks. Then set up appropriate zaps.

Basically a way for admins to keep an eye on whatever selected log events that occur.
Ie, impersonate user, check private message.

Instead of having to always go look, this is a kind of way to create a notification of watched admin actions amongst other admins

1 Like

I’m struggling with extracting the data from the raw body in Zapier too. All I need is the username value from the user_created event.

Am I right in thinking the only way you’ve managed to extract values from the raw body text @Simon_Cossar is with javascript?

(Sorry for dragging up old thread)

2 Likes

Yes, I recently looked at this again. If you need to use the “Catch Raw Hook” trigger, the only way I’ve found to extract the data from the raw body text is by adding a code step and extracting the data with javascript.

5 Likes

I actually solved my issue of having too much data in the raw body text without using code, just using standard Zapier steps:

  • Stripped out the quotation marks
  • Replaced colons with commas
  • Cleaned up front end of the data to basically look like a long list of comma separated values (removed all the '{'s)
  • Used split text, separated by comma, using custom value (3) for segment index to get the username out
2 Likes

I’m trying to setup a SMS notification each time a post is created in a specific catrgory.

My steps:

  1. Discourse webhook on post event -> Zapier
  2. Zapier receive hook -> Twilio SMS request
  3. Twilio SMS -> Users in list

Now, I ONLY want it to go on a post_created event. But, discourse generates hook for all post events.
I can obviously filter that in Zapier, but that’s more than a 2 step zap, so I can’t use my free account, I’d have to upgrade. This is for very specific, low olume usage, so it’s completely unnecessary to pay for an upgraded Zapier plan.

What I hope the team can add is a dropdown box under all events that trigger webhook.
currently there are classes:

  • Topic Event
  • User Event
  • Category Event
  • Flag Event
  • Post Event
  • Group Event
  • Tag Event
  • Post Approval Event

Ideally, there should be a dropdown with checkboxes (to select as many events within the Top Level Event as the user desires, such as:

  • Post Event
    • post_created
    • post_destroyed
    • etc

Also, is it possible to get another Top Level Event for “Logged Events”
with the ability to select specific log events from a dropdown.
Such as:

  • Logged Event
    • impersonate user
    • check private message
    • download backup
    • etc
3 Likes

Does anyone know how I can pull tag group values into Zapier? Right now it is not pulling this information in, and I can not figure out how to properly pull this field with a webhook. I found the value of “/tag_groups/6” which I assume is what I need to complete this step.

1 Like

There seems to be a missing user verified event. Such an event would really help notify moderators and admins on users they need to approve, for discourse deployments where users must be manually approved. I posted a feature request here regarding that matter:

1 Like

Have you find a way to do this? I’m facing with the same situation (trying to understand how to post to facebook only posts from a specific category/tag).

The easiest way to do this would be to configure the webhook on Discourse to only be triggered by specific categories and tags:

Another possible approach would be to make a request from Zapier to Discourse to get additional details about a post’s topic. See the ‘Add an optional step to retrieve details from Discourse’ section of How to make requests to the Discourse API with Zapier for details about how to set this up.

2 Likes