Bot Framework stepContext.context.activity.value 在团队中测试时作为空对象出现

Bot Framework stepContext.context.activity.value is coming as an empty object when tested in teams

下面是一个瀑布方法,它会在第一步显示一张英雄卡。在第二步中,它将接收值并根据选择开始对话。但是,在团队中进行测试时,我遇到了一个问题。请找到以下详细信息

代码:

async serviceRequestTypes(stepContext) {
            const srTypes = stepContext.options;
            console.log('INSIDE SR TYPES');
            const serviceRequestCard = CardFactory.heroCard('Service Requests', 'Please choose the belwo options to create the appropriate service Requests',
                        CardFactory.images(['https://www.usnews.com/dims4/USNEWS/65f1856/2147483647/thumbnail/970x647/quality/85/?url=http%3A%2F%2Fcom-usnews-beam-media.s3.amazonaws.com%2Fbe%2Fdd%2F8f25b4174b6398285139452fb7d5%2F190313-collegeapplication-stock.jpg']),
  CardFactory.actions([
                            {
                                type: 'messageBack',
                                title: 'Create Generic Service Request',
                                value: 'Create Generic Service Request'
                            },
                            {
                                type: 'messageBack',
                                title: 'Create Application Service Request',
                                value: 'Create Application Service Request'
                            },
                            {
                                type: 'messageBack',
                                title: 'Create Virtual Desktop Service Request',
                                value: 'Create Virtual Desktop Service Request'
                            }
                        ])
                    );

                    await stepContext.context.sendActivity({ attachments: [serviceRequestCard], attachmentLayout: AttachmentLayoutTypes.carousel });
                    return { status: DialogTurnStatus.waiting };
                }
            }

            async classifySRDialog(stepContext) {
                console.log('INSIDE CLASSIFY SR DIALOG');
                **console.log(stepContext.context.activity.value);
                stepContext.values.classifiedSR = stepContext.context.activity.value;**
                console.log(stepContext.values.classifiedSR);
                if (stepContext.values.classifiedSR === 'Create Generic Service Request') {
                    return await stepContext.beginDialog('createGenericSRDialog');
                } else if (stepContext.values.classifiedSR === 'Create Application Service Request') {
                    console.log('Inside Application SR');
                    return await stepContext.beginDialog('createApplicationDialog');
                } else if (stepContext.values.classifiedSR === 'Create Virtual Desktop Service Request') {
                    return await stepContext.beginDialog('createVDIDialog');
                } else {

                }
            }
        }

在第二个瀑布方法中我需要得到

stepContext.values.classifiedSR = stepContext.context.activity.value;

这在机器人模拟器和网络聊天中工作得非常好。但是,当使用 microsoft teams 进行测试时。

stepContext.context.activity.value 作为 {} 对象出现。有什么可以帮忙的吗。

首先,也是最重要的,您应该知道任何渠道(团队、Facebook、网络聊天等)都会以不同方式处理传递给它的数据(并且在这样做时也可能有不同的要求)。传回的结果会因此而有所不同,这就是为什么您会看到 Emulator 和 Teams 之间的不同响应。

对于Emulator,英雄卡中value属性传入的值,指定为messageBackActionTypes: MessageBack类型,可以是任意类型(引用here).

对于 Teams,传入的值必须是唯一标识符或 JSON 对象(引用 here)。

如果您调整代码以发送 JSON 对象,您应该会得到想要的结果(在 Teams 中)。

希望得到帮助!