How do I set-up this workflow? Membership form with Payment > Discourse Invite

AI-generated summary

The discussion revolves around setting up a workflow where users applying to a nonprofit community via a form, making a donation-based contribution, automatically receive a Discourse invite. debryc seeks guidance, and sam suggests using the Discourse API to generate invites, requiring some coding. debryc confirms they have dev resources and asks for examples. simon provides a detailed explanation, including a curl command to send invites via the API, emphasizing the need for an api_key and api_username (defaulting to ‘system’), and the email parameter. Optional parameters like custom_message and group_names can be included. The response for a successful invite is `{

Hi, I run a nonprofit community that has this workflow.

  1. Someone applies to join the nonprofit community via a form of some kind

  2. As part of the application, they are asked to make a donations based contribution that’s up to them, from $0 to the sky’s the limit

  3. After submitting their membership application, I’d like a setup that automatically sends them a Discourse invite to our private Discourse forum

How do I set-up this workflow?

One side of this is that you can generate invite links via the API and make your community require login / approval. Do you have someone doing dev on your side, it is going to require a little bit of coding.

We have some dev talent. Is there example code or documentation, though, that perhaps another discourse forum uses, that we can borrow from?

You can send an invite through the Discourse API by making a POST request to https://forum.example.com/invites

In the body of the request you need to include the All Users api_key and api_username. The All Users api_username defaults to ‘system’. The other parameter that you need to include is email. You can optionally include a custom_message and a group_names parameter. The group_names parameter should be set to a comma separated list (without spaces) of group names for groups that already exist on your forum.

Here is an example API call made with curl. $api_key is set to the All Users API key for my forum. The URL is the URL of my local development forum:

curl -X POST -d "api_key=$api_key&api_username=system&email=johndoe@example.com&custom_message=Thanks for your contribution." http://localhost:3000/invites

The response you should get for a successful invite is {"success":"OK"}.

Once you have this working with curl or Postman, it should be possible to wire up your application to make the request automatically when a user makes a contribution.

You can customize the email templates that are used for sending these invites. The template that is used if a custom message is included is the Custom Invite Forum Mailer template. The template that is used when a custom message is not included is the Invite Forum Mailer.

For details about finding which API request to make to perform a specific action, see the Reverse engineer the Discourse API topic. For details about customizing email templates, see the Customizing specific system email templates topic.