Invite token bulk email API sample

@codinghorror started a sister topic on general improvements to the invite system.

In some cases these changes just will not cut it.

  • In some cases people may want to send out a batch of invites via a third party tool, mailchimp, boomerang and so on. Many of these platforms are designed for email spam and provide better feedback and statistics.

  • In some cases people may want complete control over, subject and body of the email. They may want to include custom copy that differs to the standard email.

To achieve this we need to amend our API endopoint to allow for generation of tokens.

The spec is quite simple:

  1. Input is the exact same format our CSV invite takes
  2. Output is a CSV containing emails and invite links

###Example

gem install discourse_api
discourse_api --key API_KEY --username USER generate_invite_tokens INPUT.CSV > OUPTUT.CSV

Side project here is making the api gem more usable, having it distribute a binary to run all sorts of tasks like this.

Note:

@techAPJ will be working on this after he is done with general invite improvements.

Feedback @stevebaer @bobmcneel ?

3 Likes

Let me make sure Iā€™m interpreting this correctly. From what I reading, the API call will take a CSV file that contains a list of (email,groups,topic_id)

When the API call is made a CSV file is returned that contains a list of the same length of (email,link) that we can stick in any email body we want for sending out to people.

If this is correct, then that should work great for us.

1 Like

Yes, exactly, @techAPJ will free up to work on this in the next week or so.

1 Like

Extended Spec, email-less tokens. That means that we need an endpoint to generate these.

Email-less tokens get associated on signup, this is the flow

  1. You generate a token which may also confer rights like automatically adding a user to a group
  2. On redemption the redemption link provides an email and optional user / username.

So, we generate the unique one use tokens and the third party fills the blanks, for example:

https://meta.discourse.org/invites/GUID?username=bob&email=bob@bob.com&name=Something

GUIDs can only be redeemed once, we have no idea what the email is until they finally accept it.

2 Likes

Implemented via:

and

Also wrote a how-to for this:

Note:

The URL for disposable invite will be:

https://meta.discourse.org/invites/redeem/GUID?username=bob&email=bob@bob.com&name=Something

Notice the extra redeem in URL.

Great! @sam and @codinghorror we really want to test this as soon as possible. Would it be possible to upgrade our discourse instance with this new feature?

@techAPJ is working on your part of the spec next, should have it done in the next 2 days or so.

Hmmā€¦ okay. Iā€™m confused; it seems like the disposable invite tokens feature pretty much solves what we were looking to do.

You can use that if you wish, but you will need to tack ā€œemails and usernameā€ to every invite you generate, we are building a second part to this that allows you to associate the email with the invite.

Up to you, you can use the disposable tokens if you wish .

I would love to try if possible. We are trying to test this out with an event that is coming up this fall and we want to try and send out emails as soon as possible. Iā€™m assuming our current discourse server does not have the disposable invite feature yet since it was just pushed a few hours ago. Would it be possible to upgrade our server so we can try this?

Thanks; and sorry for being a pain.

I just hit the deploy button so you should have the feature, feel free to try it out, follow @techAPJā€™s howto.

1 Like

I just attempted to run the disposable_invite_tokens.rb example with my settings (site, username, apikey) and get the following error

C:\dev\github\discourse\discourse_api\examples>ruby disposable_invite_tokens.rb

disposable_invite_tokens.rb:12:in <main>': undefined method bodyā€™ for #<Hash:0
x2846be0> (NoMethodError)

I would normally link this to my personal ignorance about ruby, but it looks like much of the script ran and a ā€œNoMethodErrorā€ may be signifying that no method on the server exists (wild ass guessing now.) Can you tell if Iā€™m running the script incorrectly or if our discourse server has not been fully deployed with these changes yet?

Weird. It seems like your Discourse instance is not returning array of tokens.

If you can PM me the API key and Admin username of your Discourse instance, I can help you with this.