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

余生颓废 提交于 2021-01-04 04:36:22

问题


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?


回答1:


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"
]



回答2:


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.



来源:https://stackoverflow.com/questions/60518015/gmail-google-apps-script-plugin-the-value-returned-from-apps-script-has-a-type

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!