Skip to content

Commit

Permalink
feat: Use link preview builder from Card Service
Browse files Browse the repository at this point in the history
  • Loading branch information
PierrickVoulet authored Feb 23, 2024
1 parent ece111d commit 6a4bec9
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions apps-script/3p-resources/3p-resources.gs
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,15 @@ function caseLinkPreview(event) {
.setTitle(`Case ${caseDetails["name"][0]}`);
const caseDescription = CardService.newTextParagraph()
.setText(caseDetails["description"][0]);

// Returns the card.
// Uses the text from the card's header for the title of the smart chip.
return CardService.newCardBuilder()
const card = CardService.newCardBuilder()
.setHeader(caseHeader)
.addSection(CardService.newCardSection().addWidget(caseDescription))
.build();

// Returns the link preview smart chip with its dedicated title.
return CardService.newLinkPreview()
.setTitle(`Case ${caseDetails["name"][0]} - caseDetails["description"][0]`)
.setPreviewCard(card);
}
}

Expand Down Expand Up @@ -268,4 +270,4 @@ function createLinkRenderAction(title, url) {
}

// [END add_ons_3p_resources_link_render_action]
// [END add_ons_3p_resources]
// [END add_ons_3p_resources]

0 comments on commit 6a4bec9

Please sign in to comment.