首页 > 解决方案 > 在 heroCard botframework (nodejs) 中提及用户

问题描述

用户想要将消息返回到团队频道。在卡片中,我想提及将消息发送回频道的用户。按照Microsoft Docs 上的说明操作无效。使用该 TextEncoder,用户的姓名将被编码并作为数字返回(例如 82,111,115,105,101,114,115,44,32,74,97,115,112,10,....)。

下面的设置方式返回用户名,但不作为提及,只是文本。如何将其转换为实际提及用户的代码?

我也尝试context.activity.from.name在 heroCard 中使用,但也没有提及用户。

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];

标签: node.jstypescriptmicrosoft-teamsbotframework

解决方案


正如Wajeed-MSFT正确指出的那样,heroCards 不支持提及。

然而,它们支持文本消息自适应卡,这对我有用。


推荐阅读