在Teams平台上更新BotFramework v4中的活动 [英] Updating an activity in BotFramework v4 on Teams platform

查看:115
本文介绍了在Teams平台上更新BotFramework v4中的活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个机器人,该机器人是使用Bot Framework v4和NodeJS开发的,并已部署在Teams的多个渠道上.有没有办法更新机器人发送的消息?我尝试在BotFrameworkAdapter中实现updateActivity()函数.但是,它不会更新活动.

I have a bot developed using the Bot Framework v4 using NodeJS and deployed on multiple channels in Teams. Is there a way we can update a message sent by the bot? I tried implementing the updateActivity() function in the BotFrameworkAdapter. However, it does not update the activity.

我已将此卡从机器人中发送到了Teams频道.有人单击按钮时,有什么方法可以更新卡或消息(禁用按钮)?

I have this card sent from the bot to a Teams channel. When someone clicks on the button, is there a way I can update the card or the message (disabling the button)?

推荐答案

关键是要确保在使用updateActivity()时,使用由团队渠道创建的正确活动ID.您还需要确保更新后的活动已将所有团队"数据集都设置为该数据.

The key to this is making sure that when you use updateActivity(), you use the right activity ID that is created by the Teams Channel. You also need to make sure that the updated activity gets all of the Teams data set to it.

onTurn中,捕获外发活动,以便您可以轻松保存所有必要的Team Channel数据:

In onTurn, capture outgoing activities so that you can easily save all of the necessary Teams Channel data:

public onTurn = async (turnContext: TurnContext) => {

    turnContext.onSendActivities(async (ctx, activities, nextSend) => {
        activities.forEach(async (activity) => {
            if (activity.channelData.saveMe) {
                this.savedActivity = activity;
            }
        });
        return await nextSend();
    });

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆