下面是我的代码示例。在选择之后的步骤中,如果我查看stepContext对象(在下面进一步找到),则引用了Activity.id,但此ID实际上是当前步骤的Activity ID。我确定我缺少一些简单的东西,但是无法弄清楚。
async step1(step) {
const choice1 = await step.prompt(CHOICE_PROMPT, {
prompt: 'Please select one of the following:',
choices: ChoiceFactory.toChoices(['Option1', 'Option2', 'Option3'])
});
return choice1
}
async step2(step) {
console.log(step)
console.log("...........................................................................")
return await step.prompt(NAME_PROMPT, 'Please insert your name')
}
WaterfallStepContext { dialogs: DialogSet { dialogs: { NAME_PROMPT: [Object], CHOICE_PROMPT: [Object], CONFIRM_PROMPT: [Object], ATTACHMENT_PROMPT: [Object], WATERFALL_DIALOG: [Object] }, dialogState: undefined }, context: TurnContext { _respondedRef: { responded: false }, _turnState: Map { Symbol(BotIdentity) => [Object], Symbol(ConnectorClient) => [Object], Symbol(OAuthScope) => 'https://api.botframework.com', 'botCallbackHandler' => [AsyncFunction], Symbol(state) => [Object], Symbol(ActivityReceivedEmitted) => true }, _onSendActivities: [], _onUpdateActivity: [], _onDeleteActivity: [], bufferedReplyActivities: [], _adapter: BotFrameworkAdapter { middleware: [Object], BotIdentityKey: Symbol(BotIdentity), OAuthScopeKey: Symbol(OAuthScope), ConnectorClientKey: Symbol(ConnectorClient), TokenApiClientCredentialsKey: Symbol(TokenApiClientCredentials), settings: [Object], credentials: [Object], credentialsProvider: [Object], isEmulatingOAuthCards: false, authConfiguration: [Object], turnError: [AsyncFunction] }, _activity: { text: 'Option1', textFormat: 'plain', type: 'message', timestamp: 2020-05-05T13:32:42.187Z, localTimestamp: 2020-05-05T13:32:42.187Z, id: '1588685562137', channelId: 'msteams', serviceUrl: 'https://smba.trafficmanager.net/za/', from: [Object], conversation: [Object], recipient: [Object], entities: [Array], channelData: [Object], locale: 'en-US' } }, stack: [ { id: 'WATERFALL_DIALOG', state: [Object] } ], state: DialogStateManager { dialogContext: [Circular] }, _info: { index: 1, options: {}, reason: 'endCalled', result: { value: 'Option1', index: 0, score: 1, synonym: 'Option1' }, values: { instanceId: 'b5bef7ce-1c43-e1db-abc0-651ed2b5bb8f' }, onNext: [Function: onNext] }, parent: DialogContext { dialogs: DialogSet { dialogs: [Object], dialogState: [Object] }, context: TurnContext { _respondedRef: [Object], _turnState: [Object], _onSendActivities: [], _onUpdateActivity: [], _onDeleteActivity: [], bufferedReplyActivities: [], _adapter: [Object], _activity: [Object] }, stack: [ [Object] ],
为了获得操作来源的活动ID,您必须在发送活动的回合中将其保存为机器人状态。可以在使用哪种方法发送活动返回的资源响应中找到该ID。不幸的是,这意味着您不能让提示为您发送卡片,因为那样您将无法访问资源响应。
如果您一次要保存多个活动ID,则需要一种方法来了解与每个传入操作相关联的活动ID。这意味着您必须将元数据包含在卡片中的操作中,并将该元数据与活动ID一起保存为机器人状态。
[如果您想要一种更轻松甚至自动的方式来完成所有这些操作,请表达对我当前正在使用的卡片库的支持:https://github.com/BotBuilderCommunity/botbuilder-community-dotnet/issues/137