function onLinkPreview(event) {
  const hostApp = event.hostApp;
  if (!event[hostApp].matchedUrl.url) {
    return;
  }
  const url = event[hostApp].matchedUrl.url;
  try {
    const info = getPageSummary(url);
    const card = buildCard(info.title, info.summary);
    const linkPreview = CardService.newLinkPreview()
      .setPreviewCard(card)
      .setTitle(info.title)
      .setLinkPreviewTitle(info.title);
    return linkPreview;
  } catch (error) {
    // Log the error  
    console.error("Error occurred:", error);
    const errorCard = buildErrorCard();
    return CardService.newActionResponseBuilder()
    .setNavigation(CardService.newNavigation().updateCard(errorCard))
    .build();
  }
}
Creates a link preview card for Google developer documentation links.

@param {!Object} event
@return {!Card}