【发布时间】:2020-11-05 22:11:32
【问题描述】:
用户想要将消息返回到团队频道。在卡片中,我想提及将消息发送回频道的用户。按照说明on the Microsoft Docs 没有用。使用该 TextEncoder,用户的姓名将被编码并作为数字返回(例如 82,111,115,105,101,114,115,44,32,74,97,115,112,10,....)。
下面的设置方式返回用户名,但不作为提及,只是文本。如何将其转化为实际提及用户的代码?
我也尝试在 heroCard 中使用context.activity.from.name,但也没有提及用户。
const mention = {
mentioned: context.activity.from,
text: `<at>${context.activity.from.name}</at>`,
type: 'mention'
} as Mention;
const heroCard = CardFactory.heroCard(
`Returned question by ${ mention.mentioned.name }`,
`${ mention.mentioned.name } You can internally discuss the user request below. ` +
'Once ready, one person can take ownership of the conversation with the user by pressing the button. ' +
'The user\'s question: ' + teamsSupport.question,
null,
CardFactory.actions([
{
title: 'Takeover conversation',
type: ActionTypes.MessageBack,
displayText: `I will take this conversation.`,
text: this.configService.get<string>('TakeoverConfirmation') + teamsSupport.sessionId,
value: ''
},
{
title: 'Show chat history',
type: ActionTypes.OpenUrl,
value: 'https://****/conversations/' + teamsSupport.sessionId
}
])
);
const suggestedActions = MessageFactory.attachment(heroCard);
suggestedActions.entities = [mention];
【问题讨论】:
-
我可以看到 TextEncoder.encode 确实似乎返回了一个字节数组而不是一个字符串。它们可能意味着您可以像 C# 那样对字符串进行 XML 编码。无论如何,我有两个问题。 1. 只是名称的文字显示不正确还是链接除了显示不正确之外还不起作用? 2. 你是否能够在英雄卡之外,即在消息文本中正确提及?
-
在使用 TextEncoder 时,我只得到字节数组,因此显示不正确。不使用该编码器时,我确实得到了正确的名称。在这两种情况下,都没有链接。我还没有尝试在消息文本中这样做,我会在明天尝试并在我有的时候再次回答。
-
仅在Text Message 和Adaptive Card 中支持提及。
-
我认为它也可以在 herocards 中使用,短信提及现在可以使用,谢谢!
标签: node.js typescript microsoft-teams botframework