Integrate ViewActions/One-Click Actions schemas into Discourse Emails

tl;dr: Buttons that link you to a Discourse post

Continuing the discussion from Make activating an Account Gmail-compatible:

So anyway, Github emails come with some extra html that makes action buttons appear on GMail and in Inbox, possibly even elsewhere but I’m not aware of any. They look like this:

<div itemscope itemtype="http://schema.org/EmailMessage">
  <div itemprop="action" itemscope itemtype="http://schema.org/ViewAction">
    <link itemprop="url" href="https://github.com/syncthing/syncthing/issues/1519#issuecomment-88384950"></link>
    <meta itemprop="name" content="View Issue"></meta>
  </div>
  <meta itemprop="description" content="View this Issue on GitHub"></meta>
</div>
<div itemscope itemtype="http://schema.org/EmailMessage">
<div itemprop="action" itemscope itemtype="http://schema.org/ViewAction">
<link itemprop="url" href="https://github.com/BuildAPC/BuildAPC-docs/pull/46#issuecomment-88387645"></link>
<meta itemprop="name" content="View Pull Request"></meta>
</div>
<meta itemprop="description" content="View this Pull Request on GitHub"></meta>
</div>

So in what I could figure out, the itemprop name and the description are not visible at all on GMail but the corresponding string do appear if you Ctrl+F for them on the page source.

Inbox is even weirder as the itemprop="description" string is visible on the Issue email but not on the Pull Request one. Possibly caused by the mention.

Would be pretty :fire: :fire: :fire: if Discourse would use this schema/code/whatever too!

9 Likes

By the way, I noticed Gmail enables this sort of button for Amazon purchase emails too – But Amazon’s emails don’t even contain this schema. It is also localized depending on your Google Account’s language.

Kinda :angry: that they do this.

Reposting my original post:


##Make Activating Accounts Gmail-compatible

Mailchimp-sent double-in confirmations always send with them some metadata.

GMail uses this metadata to display a button (just like you can see on the screenshot) that users can click to automatically activate the subscription/account without even opening the email.

See the the bottom of the email’s source to see the used schemes/metadata.


Also look Google’s documentation about this and a Mailchimp Blog post about the matter.


The only issue I can see with this is that the Discourse activation links require the user to click on “Activate Account”.

2 Likes

Some example metadata that would work (stolen from a working email but edited):

<div itemscope itemtype="http://schema.org/EmailMessage" style="display:none">
    <div itemprop="action" itemscope itemtype="http://schema.org/ViewAction">
        <link itemprop="url" href="https://meta.discourse.org/t/integrate-viewactions-one-click-actions-schemas-into-discourse-emails/27056" />
        <meta itemprop="name" content="View this thread"/>
    </div>
</div>

Will see if I can scrounge up a PR if I can work out where the email templates are

2 Likes

I’ve made some modifications to the app/views/email/notification.html.erb which adds the basic functionality that this request is after.

My only issue is that it uses the translation for read_full_topic which probably isn’t ideal in this situation. It should probably read View Topic or something along those lines but I’m having issues adding another translation line.

Any other suggestons before I put in a PR?

https://github.com/Mooash/discourse/commit/5b89327d18838691db58ba01d2989157c81d43cd

5 Likes

Is there a possibility to use the user’s language setting? Not sure if it currently does that, but it would be great.

Thanks for working on this :v: :heartpulse:

Thats what using the read_full_topic place holder does. :slight_smile: there isn’t any point putting in a pull request that only displays the English language. :wink:

1 Like

I guess you can submit it and one of the maintainers will look at it :slight_smile:

Edit:

It’s live! :clap: :crown:

2 Likes

Just tried it out on my instance, the schema gets included in the mail but there is no button:


^ Google’s markup tester


Oh god, I should have read the documentation more. You have to register with google so the button shows up at all.

Some points come up which seem really bad to me:

Consistent history of sending a high volume of mail from your domain (order of hundred emails a day minimum to Gmail) for a few weeks at least.

We are currently only approving Go-To actions for very specific high-value usecase with high interaction rate (e.g. Flight Check-in, Shipment tracking links).

Maybe “Read full topic” is too unprecise for this recquirement:

Label of button needs to reflect clear action to be taken and must be true to page the user is going to

1 Like

Shit. I didn’t realise you had to register to use this schema. Thats bogus.

@eviltrout should this turn into a toggle-able option? Having the schema at the bottom of the email doesn’t really change anything since it doesn’t add a large amount to the email (plus its hidden from the clients view)

2 Likes

Technically, you only have to register if you want Gmail to render it in their client. :wink:

:-1:

This sounds basically useless. If Google has to individually approve the button for each domain, and each Discourse instance…

Then we should not include this, as it won’t do anything.

2 Likes

I agree it sounds like we should pull it. It’s useless if every discourse needs to register to have it work.

1 Like

On the other hand, more mail clients will support this when more services include/use the schemas.