Joseph Combs
Joseph Combs

Reputation: 919

GMail Google Apps Script Plugin "The value returned from Apps Script has a type that cannot be used by the add-ons platform"

In the last 24 hours, a previously working GMail plugin I run has started failing.

I stripped it all the way down to only trying to get the example from the docs working:

var action = CardService.newAction().setFunctionName('composeEmailCallback');
CardService.newTextButton()
    .setText('Compose Email')
    .setComposeAction(action, CardService.ComposedEmailType.REPLY_AS_DRAFT);

// ...

function composeEmailCallback() {
  var thread = GmailApp.getThreadById(e.threadId);
  var draft = thread.createDraftReply('This is a reply');
  return CardService.newComposeActionResponseBuilder()
      .setGmailDraft(draft)
      .build();
}

On BUILD (not on button press), the previously working GMail Addon displays the error message:

The value returned from Apps Script has a type that cannot be used by the add-ons platform. Also make sure to call build on any builder before returning it. Value: values {
  proto_value {
    type_url: "type.googleapis.com/caribou.api.proto.addons.templates.publicapi.ContextualAddOnMarkup.Card"
    value: "...(omitted)"
  }
}

Is this a new, known issue? Does anyone have some troubleshooting steps to share?

Upvotes: 3

Views: 2468

Answers (2)

Switch0025
Switch0025

Reputation: 101

For me the error was was caused by open links not being whitelisted. For example, if you have code like this:

CardService.newOpenLink().setUrl(url)

Then the link returned by 'url' has to be whitelisted in the appscript manifest's openLinkUrlPrefixes list, like so:

"openLinkUrlPrefixes": [
    "https://*.example.com"
]

Upvotes: 10

Joseph Combs
Joseph Combs

Reputation: 919

This problem is caused by Google's silent upgrading of Apps Script to the V8 Runtime. To downgrade from this runtime to the old runtime (Rhino), perform this set of actions:

Run -> Disable New Apps Script runtime powered by Chrome V8

A related issue can be found here.

Upvotes: 0

Related Questions