预览链接

使用集合让一切井井有条 根据您的偏好保存内容并对其进行分类。

为防止用户在 Google Chat 中分享链接时发生的上下文切换,Chat 应用可以预览该链接,只需在消息中附加一张卡片即可提供更多信息,让用户可以直接通过 Google Chat 执行操作。

例如,假设有一个 Google Chat 聊天室,其中包含公司的所有客户服务代理,以及一个名为 Case-y 的聊天应用。客服人员经常在 Chat 聊天室中分享客户服务案例的链接,他们每次操作时,同事都需要打开请求链接,以查看分配对象、状态和主题等详细信息。同样地,如果有人想要获得支持请求的所有权或更改状态,则需要打开链接。

借助链接预览,该聊天室中的常驻 Chat 应用 Case-y 可以在用户分享支持请求链接后附加显示分配对象、状态和主题的卡片。客服人员可以通过卡片上的按钮直接处理请求,并直接在聊天信息流中更改状态。

当有人向他们的消息添加链接时,系统会显示一个贴块,告诉 Chat 应用可能会预览该链接。

表示 Chat 应用可能会预览链接的条状标签

发送消息后,系统会向 Chat 应用发送链接,然后该应用会生成卡片并将其附加到用户消息中。

聊天应用通过将卡片附加到消息来预览链接

该卡片的旁边会显示链接的更多信息,包括按钮等互动元素。您的 Chat 应用可以更新附加的卡片,以响应用户互动(例如按钮点击)。

如果用户不希望 Chat 应用通过将卡片附加到消息中来预览链接,可以点击预览贴块上的 以禁止预览。用户可以随时点击移除预览,以移除附加的卡片。

在 Google Cloud Console 的 Chat 应用配置页面上,将特定链接(例如 example.comsupport.example.comsupport.example.com/cases/)注册为网址格式,以便您的 Chat 应用能够预览它们。

链接预览配置菜单

  1. 打开 Google Cloud 控制台
  2. 点击“Google Cloud Platform”旁边的向下箭头 ,然后打开您的 Chat 应用项目。
  3. 在搜索字段中输入 Google Chat API,然后点击 Google Chat API
  4. 点击管理 > 配置
  5. 在“链接预览”下方,添加或修改网址格式。
    1. 要为新的网址格式配置链接预览,请点击添加网址格式
    2. 如需修改现有网址格式的配置,请点击向下箭头
  6. 主机模式字段中,输入网址格式的网域。Chat 应用会预览指向此网域的链接。

    要让特定子网域(如 subdomain.example.com)的 Chat 应用预览链接,请添加该子网域。

    要在整个网域内提供 Chat 应用预览链接,请指定通配符(带有星号 (*) 作为子网域)。例如,*.example.comsubdomain.example.comany.number.of.subdomains.example.com 匹配。

  7. 路径前缀字段中,输入要附加到主机模式网域的路径。

    要匹配主机模式网域中的所有网址,请将路径前缀留空。

    例如,如果主机格式为 support.example.com,若要匹配在 support.example.com/cases/ 上托管的支持请求的网址,请输入 cases/

  8. 点击完成

  9. 点击保存

现在,每当有人添加与链接预览网址格式匹配 Chat 聊天室消息(包含您的 Chat 应用)的链接时,您的应用都会预览该链接。

您为给定链接配置链接预览后,您的聊天应用可以通过向该链接附加更多信息来识别和预览该链接。

在包含 Chat 应用的 Chat 聊天室内,当有人的消息中包含与链接预览网址格式匹配的链接时,该链接将作为 message 对象上的 matchedUrl 属性发送到您的 Chat 应用:

JSON

message {

  . . . // other message attributes redacted

  "matchedUrl": {
     "url": "https://support.example.com/cases/case123"
   },

  . . . // other message attributes redacted

}

通过检查 message 对象中是否存在 matchedUrl 属性,您的 Chat 应用可以通过预览链接向消息中添加信息。您的聊天应用可以使用简单的短信回复,或附加卡片

回复短信

对于简单回复,Chat 应用可以通过向链接回复简单的短信来预览链接。此示例附加了一条重复网址的消息,该网址与链接预览网址格式匹配。

Node.js

node/preview-link/simple-text-message.js
/**
 * Responds to messages that have links whose URLs match URL patterns
 * configured for link previewing.
 *
 * @param {Object} req Request sent from Google Chat.
 * @param {Object} res Response to send back.
 */
exports.onMessage = (req, res) => {
  if (req.method === 'GET' || !req.body.message) {
    res.send(
        'Hello! This function is meant to be used in a Google Chat Space.');
  }

  // Checks for the presence of event.message.matchedUrl and responds with a
  // text message if present
  if (req.body.message.matchedUrl) {
    res.json({
      'text': 'req.body.message.matchedUrl.url: ' +
                req.body.message.matchedUrl.url,
    });
  }

  // If the Chat app doesn’t detect a link preview URL pattern, it says so.
  res.json({'text': 'No matchedUrl detected.'});
};

Apps 脚本

apps-script/preview-link/simple-text-message.gs
/**
 * Responds to messages that have links whose URLs match URL patterns
 * configured for link previewing.
 *
 * @param {Object} event The event object from Chat API.
 *
 * @return {Object} Response from the Chat app attached to the message with
 * the previewed link.
 */
function onMessage(event) {
  // Checks for the presence of event.message.matchedUrl and responds with a
  // text message if present
  if (event.message.matchedUrl) {
    return {
      'text': 'event.message.matchedUrl.url: ' + event.message.matchedUrl.url,
    };
  }

  // If the Chat app doesn’t detect a link preview URL pattern, it says so.
  return {'text': 'No matchedUrl detected.'};
}

附加卡

要将卡片附加到预览链接,请返回类型为 UPDATE_USER_MESSAGE_CARDSActionResponse。此示例附加了一张简单的卡片。

聊天应用通过将卡片附加到消息来预览链接

Node.js

node/preview-link/attach-card.js
/**
 * Responds to messages that have links whose URLs match URL patterns
 * configured for link previewing.
 *
 * @param {Object} req Request sent from Google Chat.
 * @param {Object} res Response to send back.
 */
exports.onMessage = (req, res) => {
  if (req.method === 'GET' || !req.body.message) {
    res.send(
        'Hello! This function is meant to be used in a Google Chat Space.');
  }

  // Checks for the presence of event.message.matchedUrl and attaches a card
  // if present
  if (req.body.message.matchedUrl) {
    res.json({
      'actionResponse': {'type': 'UPDATE_USER_MESSAGE_CARDS'},
      'cards': [
        {
          'header': {
            'title': 'Example Customer Service Case',
            'subtitle': 'Case basics',
          },
          'sections': [
            {
              'widgets': [
                {'keyValue': {'topLabel': 'Case ID', 'content': 'case123'}},
                {'keyValue': {'topLabel': 'Assignee', 'content': 'Charlie'}},
                {'keyValue': {'topLabel': 'Status', 'content': 'Open'}},
                {'keyValue': {
                  'topLabel': 'Subject', 'content': 'It won"t turn on...',
                }},
              ],
            },
            {
              'widgets': [
                {
                  'buttons': [
                    {
                      'textButton': {
                        'text': 'OPEN CASE',
                        'onClick': {
                          'openLink': {
                            'url': 'https://support.example.com/orders/case123',
                          },
                        },
                      },
                    },
                    {
                      'textButton': {
                        'text': 'RESOLVE CASE',
                        'onClick': {
                          'openLink': {
                            'url': 'https://support.example.com/orders/case123?resolved=y',
                          },
                        },
                      },
                    },
                    {
                      'textButton': {
                        'text': 'ASSIGN TO ME',
                        'onClick': {
                          'action': {
                            'actionMethodName': 'assign',
                          },
                        },
                      },
                    },
                  ],
                },
              ],
            },
          ],
        },
      ],
    });
  }

  // If the Chat app doesn’t detect a link preview URL pattern, it says so.
  res.json({'text': 'No matchedUrl detected.'});
};

Apps 脚本

apps-script/preview-link/attach-card.gs
/**
 * Responds to messages that have links whose URLs match URL patterns
 * configured for link previewing.
 *
 * @param {Object} event The event object from Chat API.
 * @return {Object} Response from the Chat app attached to the message with
 * the previewed link.
 */
function onMessage(event) {
  // Checks for the presence of event.message.matchedUrl and attaches a card
  // if present
  if (event.message.matchedUrl) {
    return {
      'actionResponse': {
        'type': 'UPDATE_USER_MESSAGE_CARDS',
      },
      'cards': [
        {
          'header': {
            'title': 'Example Customer Service Case',
            'subtitle': 'Case basics',
          },
          'sections': [{
            'widgets': [
              {'keyValue': {'topLabel': 'Case ID', 'content': 'case123'}},
              {'keyValue': {'topLabel': 'Assignee', 'content': 'Charlie'}},
              {'keyValue': {'topLabel': 'Status', 'content': 'Open'}},
              {
                'keyValue': {
                  'topLabel': 'Subject', 'content': 'It won\'t turn on...',
                },
              },
            ],
          },
          {
            'widgets': [{
              'buttons': [
                {
                  'textButton': {
                    'text': 'OPEN CASE',
                    'onClick': {
                      'openLink': {
                        'url': 'https://support.example.com/orders/case123',
                      },
                    },
                  },
                },
                {
                  'textButton': {
                    'text': 'RESOLVE CASE',
                    'onClick': {
                      'openLink': {
                        'url': 'https://support.example.com/orders/case123?resolved=y',
                      },
                    },
                  },
                },
                {
                  'textButton': {
                    'text': 'ASSIGN TO ME',
                    'onClick': {
                      'action': {
                        'actionMethodName': 'assign',
                      },
                    },
                  },
                },
              ],
            },
            ],
          },
          ],
        },
      ],
    };
  }

  // If the Chat app doesn’t detect a link preview URL pattern, it says so.
  return {'text': 'No matchedUrl detected.'};
}

更新卡

如需更新附加到预览链接的卡片,请返回 UPDATE_USER_MESSAGE_CARDS 类型的 ActionResponse。附加到预览链接的卡片只有在收到聊天事件的同步请求时才会更新。不支持通过 Chat REST API 对附加到预览链接的卡片执行异步请求。

链接预览不支持返回 UPDATE_MESSAGE 类型的 ActionResponse。由于 UPDATE_MESSAGE 会更新整条消息(而不仅仅是卡片),因此只有当 Chat 应用创建原始消息时,它才会起作用。链接预览会将卡片附加到用户创建的消息中,因此 Chat 应用无权更新该卡片。

为了确保函数同时更新 Chat 信息流中用户创建和应用创建的卡片,请根据 Chat 应用或用户创建的消息动态设置 ActionResponse

  • 如果相应消息是由用户创建的,请将 ActionResponse 设置为 UPDATE_USER_MESSAGE_CARDS
  • 如果 Chat 应用创建了消息,请将 ActionResponse 设置为 UPDATE_MESSAGE

您可以通过以下两种方式执行此操作:在附加卡的 onclick 属性中指定和检查自定义 actionMethodName(可将消息标识为用户创建),或者检查消息是否由用户创建。

方法 1:检查是否存在 actionMethodName

如需使用 actionMethodName 正确处理预览卡片上的卡片点击事件,请在所附卡片的 onclick 属性中设置自定义 actionMethodName

JSON

. . . // Preview card details
{
  "textButton": {
    "text": "ASSIGN TO ME",
    "onClick": {

      // actionMethodName identifies the button to help determine the
      // appropriate ActionResponse.
      "action": {
        "actionMethodName": "assign",
      }
    }
  }
}
. . . // Preview card details

通过在链接预览中识别 "actionMethodName": "assign" 按钮,可以通过检查是否存在匹配的 actionMethodName 来动态返回正确的 ActionResponse

Node.js

node/preview-link/update-card.js
/**
 * Responds to messages that have links whose URLs match URL patterns
 * configured for link previewing.
 *
 * @param {Object} req Request sent from Google Chat.
 * @param {Object} res Response to send back.
 */
exports.onMessage = (req, res) => {
  if (req.method === 'GET' || !req.body.message) {
    res.send(
        'Hello! This function is meant to be used in a Google Chat Space.');
  }

  // Respond to button clicks on attached cards
  if (req.body.type === 'CARD_CLICKED') {
    // Checks for the presence of "actionMethodName": "assign" and sets
    // actionResponse.type to "UPDATE_USER"MESSAGE_CARDS" if present or
    // "UPDATE_MESSAGE" if absent.
    const actionResponseType = req.body.action.actionMethodName === 'assign' ?
      'UPDATE_USER_MESSAGE_CARDS' :
      'UPDATE_MESSAGE';

    if (req.body.action.actionMethodName === 'assign') {
      res.json({
        'actionResponse': {

          // Dynamically returns the correct actionResponse type.
          'type': actionResponseType,
        },

        // Preview card details
        'cards': [{}],
      });
    }
  }
};

Apps 脚本

apps-script/preview-link/update-card.gs
/**
 * Updates a card that was attached to a message with a previewed link.
 *
 * @param {Object} event The event object from Chat API.
 * @return {Object} Response from the Chat app. Either a new card attached to
 * the message with the previewed link, or an update to an existing card.
 */
function onCardClick(event) {
  // Checks for the presence of "actionMethodName": "assign" and sets
  // actionResponse.type to "UPDATE_USER"MESSAGE_CARDS" if present or
  // "UPDATE_MESSAGE" if absent.
  const actionResponseType = event.action.actionMethodName === 'assign' ?
    'UPDATE_USER_MESSAGE_CARDS' :
    'UPDATE_MESSAGE';

  if (event.action.actionMethodName === 'assign') {
    return assignCase(actionResponseType);
  }
}

/**
 * Updates a card to say that "You" are the assignee after clicking the Assign
 * to Me button.
 *
 * @param {String} actionResponseType Which actionResponse the Chat app should
 * use to update the attached card based on who created the message.
 * @return {Object} Response from the Chat app. Updates the card attached to
 * the message with the previewed link.
 */
function assignCase(actionResponseType) {
  return {
    'actionResponse': {

      // Dynamically returns the correct actionResponse type.
      'type': actionResponseType,
    },
    // Preview card details
    'cards': [{}],
  };
}

方法 2:检查发件人类型

检查 message.sender.typeHUMAN 还是 BOT。如果为 HUMAN,请将 ActionResponse 设置为 UPDATE_USER_MESSAGE_CARDS,否则将 ActionResponse 设置为 UPDATE_MESSAGE。具体方法如下:

Node.js

node/preview-link/sender-type.js
/**
 * Responds to messages that have links whose URLs match URL patterns
 * configured for link previewing.
 *
 * @param {Object} req Request sent from Google Chat.
 * @param {Object} res Response to send back.
 */
exports.onMessage = (req, res) => {
  if (req.method === 'GET' || !req.body.message) {
    res.send(
        'Hello! This function is meant to be used in a Google Chat Space.');
  }

  // Respond to button clicks on attached cards
  if (req.body.type === 'CARD_CLICKED') {
    // Checks whether the message event originated from a human or a Chat app
    // and sets actionResponse.type to "UPDATE_USER_MESSAGE_CARDS if human or
    // "UPDATE_MESSAGE" if Chat app.
    const actionResponseType = req.body.action.actionMethodName === 'HUMAN' ?
      'UPDATE_USER_MESSAGE_CARDS' :
      'UPDATE_MESSAGE';

    res.json({
      'actionResponse': {

        // Dynamically returns the correct actionResponse type.
        'type': actionResponseType,
      },

      // Preview card details
      'cards': [{}],
    });
  }
};

Apps 脚本

apps-script/preview-link/sender-type.gs
/**
 * Updates a card that was attached to a message with a previewed link.
 *
 * @param {Object} event The event object from Chat API.
 * @return {Object} Response from the Chat app. Either a new card attached to
 * the message with the previewed link, or an update to an existing card.
 */
function onCardClick(event) {
  // Checks whether the message event originated from a human or a Chat app
  // and sets actionResponse.type to "UPDATE_USER_MESSAGE_CARDS if human or
  // "UPDATE_MESSAGE" if Chat app.
  const actionResponseType = event.message.sender.type === 'HUMAN' ?
    'UPDATE_USER_MESSAGE_CARDS' :
    'UPDATE_MESSAGE';

  return assignCase(actionResponseType);
}

/**
 * Updates a card to say that "You" are the assignee after clicking the Assign
 * to Me button.
 *
 * @param {String} actionResponseType Which actionResponse the Chat app should
 * use to update the attached card based on who created the message.
 * @return {Object} Response from the Chat app. Updates the card attached to
 * the message with the previewed link.
 */
function assignCase(actionResponseType) {
  return {
    'actionResponse': {

      // Dynamically returns the correct actionResponse type.
      'type': actionResponseType,
    },
    // Preview card details
    'cards': [{}],
  };
}

更新卡片的一般原因是响应按钮点击操作。回想上一节附加卡片中的分配给我按钮。以下完整示例会更新该卡片,使其在用户点击分配给我后分配给“您”。该示例会通过检查发件人类型来动态设置 ActionResponse

完整示例:案例 - 客户服务聊天应用

以下是 Case-y 的完整代码,Case-y 是一款聊天应用,可预览客户服务客服人员在 Chat 聊天室中分享的支持请求链接。

Node.js

node/preview-link/preview-link.js
/**
 * Responds to messages that have links whose URLs match URL patterns
 * configured for link previewing.
 *
 * @param {Object} req Request sent from Google Chat.
 * @param {Object} res Response to send back.
 */
exports.onMessage = (req, res) => {
  if (req.method === 'GET' || !req.body.message) {
    res.send(
        'Hello! This function is meant to be used in a Google Chat Space.');
  }

  // Checks for the presence of event.message.matchedUrl and attaches a card
  // if present
  if (req.body.message.matchedUrl) {
    res.json(createMessage());
  }

  // Respond to button clicks on attached cards
  if (req.body.type === 'CARD_CLICKED') {
    // Checks whether the message event originated from a human or a Chat app
    // and sets actionResponse.type to "UPDATE_USER_MESSAGE_CARDS if human or
    // "UPDATE_MESSAGE" if Chat app.
    const actionResponseType = req.body.action.actionMethodName === 'HUMAN' ?
      'UPDATE_USER_MESSAGE_CARDS' :
      'UPDATE_MESSAGE';

    if (req.body.action.actionMethodName === 'assign') {
      res.json(createMessage(actionResponseType, 'You'));
    }
  }

  // If the Chat app doesn’t detect a link preview URL pattern, it says so.
  res.json({'text': 'No matchedUrl detected.'});
};

/**
 * Message to create a card with the correct response type and assignee.
 *
 * @param {string} actionResponseType
 * @param {string} assignee
 * @return {Object} a card with URL preview
 */
function createMessage(
    actionResponseType = 'UPDATE_USER_MESSAGE_CARDS',
    assignee = 'Charlie'
) {
  return {
    'actionResponse': {'type': actionResponseType},
    'cards': [
      {
        'header': {
          'title': 'Example Customer Service Case',
          'subtitle': 'Case basics',
        },
        'sections': [
          {
            'widgets': [
              {'keyValue': {'topLabel': 'Case ID', 'content': 'case123'}},
              {'keyValue': {'topLabel': 'Assignee', 'content': assignee}},
              {'keyValue': {'topLabel': 'Status', 'content': 'Open'}},
              {
                'keyValue': {
                  'topLabel': 'Subject', 'content': 'It won"t turn on...',
                },
              },
            ],
          },
          {
            'widgets': [
              {
                'buttons': [
                  {
                    'textButton': {
                      'text': 'OPEN CASE',
                      'onClick': {
                        'openLink': {
                          'url': 'https://support.example.com/orders/case123',
                        },
                      },
                    },
                  },
                  {
                    'textButton': {
                      'text': 'RESOLVE CASE',
                      'onClick': {
                        'openLink': {
                          'url': 'https://support.example.com/orders/case123?resolved=y',
                        },
                      },
                    },
                  },
                  {
                    'textButton': {
                      'text': 'ASSIGN TO ME',
                      'onClick': {
                        'action': {
                          'actionMethodName': 'assign',
                        },
                      },
                    },
                  },
                ],
              },
            ],
          },
        ],
      },
    ],
  };
}

Apps 脚本

apps-script/preview-link/preview-link.gs
/**
 * Responds to messages that have links whose URLs match URL patterns
 * configured for link previews.
 *
 * @param {Object} event The event object from Chat API.
 * @return {Object} Response from the Chat app attached to the message with
 * the previewed link.
 */
function onMessage(event) {
  // Checks for the presence of event.message.matchedUrl and attaches a card
  // if present
  if (event.message.matchedUrl) {
    return {
      'actionResponse': {
        'type': 'UPDATE_USER_MESSAGE_CARDS',
      },
      'cards': [{
        'header': {
          'title': 'Example Customer Service Case',
          'subtitle': 'Case basics',
        },
        'sections': [{
          'widgets': [
            {'keyValue': {'topLabel': 'Case ID', 'content': 'case123'}},
            {'keyValue': {'topLabel': 'Assignee', 'content': 'Charlie'}},
            {'keyValue': {'topLabel': 'Status', 'content': 'Open'}},
            {'keyValue': {
              'topLabel': 'Subject', 'content': 'It won\'t turn on...',
            }},
          ],
        },
        {
          'widgets': [{
            'buttons': [{
              'textButton': {
                'text': 'OPEN CASE',
                'onClick': {
                  'openLink': {
                    'url': 'https://support.example.com/orders/case123',
                  },
                },
              },
            },
            {
              'textButton': {
                'text': 'RESOLVE CASE',
                'onClick': {
                  'openLink': {
                    'url': 'https://support.example.com/orders/case123?resolved=y',
                  },
                },
              },
            },
            {
              'textButton': {
                'text': 'ASSIGN TO ME',
                'onClick': {
                  'action': {
                    'actionMethodName': 'assign',
                  },
                },
              },
            },
            ],
          }],
        }],
      }],
    };
  }

  // If the Chat app doesn’t detect a link preview URL pattern, it says so.
  return {'text': 'No matchedUrl detected.'};
}

/**
 * Updates a card that was attached to a message with a previewed link.
 *
 * @param {Object} event The event object from Chat API.
 * @return {Object} Response from the Chat app. Either a new card attached to
 * the message with the previewed link, or an update to an existing card.
 */
function onCardClick(event) {
  // Checks whether the message event originated from a human or a Chat app
  // and sets actionResponse to "UPDATE_USER_MESSAGE_CARDS if human or
  // "UPDATE_MESSAGE" if Chat app.
  const actionResponseType = event.message.sender.type === 'HUMAN' ?
    'UPDATE_USER_MESSAGE_CARDS' :
    'UPDATE_MESSAGE';

  // To respond to the correct button, checks the button's actionMethodName.
  if (event.action.actionMethodName === 'assign') {
    return assignCase(actionResponseType);
  }
}

/**
 * Updates a card to say that "You" are the assignee after clicking the Assign
 * to Me button.
 *
 * @param {String} actionResponseType Which actionResponse the Chat app should
 * use to update the attached card based on who created the message.
 * @return {Object} Response from the Chat app. Updates the card attached to
 * the message with the previewed link.
 */
function assignCase(actionResponseType) {
  return {
    'actionResponse': {

      // Dynamically returns the correct actionResponse type.
      'type': actionResponseType,
    },
    'cards': [{
      'header': {
        'title': 'Example Customer Service Case',
        'subtitle': 'Case basics',
      },
      'sections': [{
        'widgets': [
          {'keyValue': {'topLabel': 'Case ID', 'content': 'case123'}},
          {'keyValue': {'topLabel': 'Assignee', 'content': 'You'}},
          {'keyValue': {'topLabel': 'Status', 'content': 'Open'}},
          {'keyValue': {
            'topLabel': 'Subject', 'content': 'It won\'t turn on...',
          }},
        ],
      },
      {
        'widgets': [{
          'buttons': [{
            'textButton': {
              'text': 'OPEN CASE',
              'onClick': {
                'openLink': {
                  'url': 'https://support.example.com/orders/case123',
                },
              },
            },
          },
          {
            'textButton': {
              'text': 'RESOLVE CASE',
              'onClick': {
                'openLink': {
                  'url': 'https://support.example.com/orders/case123?resolved=y',
                },
              },
            },
          },
          {
            'textButton': {
              'text': 'ASSIGN TO ME',
              'onClick': {
                'action': {
                  'actionMethodName': 'assign',
                },
              },
            },
          },
          ],
        }],
      }],
    }],
  };
}

限制和注意事项

为 Chat 应用配置链接预览时,请注意以下限制和注意事项:

  • 每个聊天应用最多支持 5 种网址格式的链接预览。
  • 聊天应用会预览每条消息的一个链接。如果单条消息中存在多个可预览链接,则系统仅会显示第一个可预览链接的预览。
  • 聊天应用仅预览以 https:// 开头的链接,因此是 https://support.example.com/cases/ 预览,但 support.example.com/cases/ 不会预览。
  • 除非消息中包含发送到 Chat 应用的其他信息(如斜杠命令),否则只有链接网址会通过链接预览发送到 Chat 应用。
  • 附加到预览链接的卡片仅支持类型为 UPDATE_USER_MESSAGE_CARDSActionResponse,并且仅响应来自聊天事件的同步请求。链接预览不支持 UPDATE_MESSAGE,也不支持通过 Chat REST API 更新预览链接所附卡片的异步请求。如需了解详情,请参阅更新卡

在实现链接预览时,您可能需要通过读取 Chat 应用的日志来对其进行调试。如需读取日志,请访问 Google Cloud Console 上的日志浏览器