Google Add-Ons has pivoted towards using CardService widgets. I am trying to create a drop-down menu but the ListBox class is deprecated. The docs forwarded me to HTML services but there's no documentation anywhere about how to use them in the context of CardServices. Here is my code:
GetContextualAddOn.gs
function createReply(e) {
var accessToken = e.messageMetadata.accessToken;
GmailApp.setCurrentMessageAccessToken(accessToken);
var messageId = e.messageMetadata.messageId;
var message = GmailApp.getMessageById(messageId);
var draft = message.createDraftReply("Got your message");
return CardService.newComposeActionResponseBuilder()
.setGmailDraft(draft).build();
}
function getContextualAddOn() {
var card = CardService.newCardBuilder();
card.setHeader(CardService.newCardHeader().setTitle('Respond to Email'));
var section = CardService.newCardSection();
var action = CardService.newAction().setFunctionName('createReply');
function doGet() {
return HtmlService.createHtmlOutputFromFile('dropdown');
}
section.addWidget(CardService
.newTextButton()
.setText('Respond')
.setComposeAction(action, CardService.ComposedEmailType.REPLY_AS_DRAFT));
card.addSection(section);
return [card.build()];
}
the doGet() method shown above is trying to access a dropdown.html file that I created:
**dropdown.html**
<!DOCTYPE html>
<html>
<head>
<base target="_top">
</head>
<body>
<p>test</p>
</body>
</html>
How would I integrate the HTML into my current card.build? Should I be approaching it differently, and if so, can someone provide a code sample?
The CardService service can only be used with Google Workspace add-ons. They are not available in Google Docs add-ons or web apps built with Apps Script.