简体   繁体   中英

Detecting button press in CardAction BotBuilder

So within a carousel I have builder.CardAction.imBack(session, 'relatedStuff', 'Related stuff'),

and i've been doing a match to match once this is selected and handle a new dialog like so:

bot.dialog('relatedStuff', (session, args, next) => {
  // console.log(session, '<<<<<< SESSION');
  session.endDialog('This is a simple bot that collects a name and age.');
}).triggerAction({
  matches: /^relatedStuff$/,
  onSelectAction: (session, args, next) => {
    session.beginDialog(args.action, args);
  },
});

How can I identify what's being selected rather than doing a match?

So for example,

builder.CardAction.imBack(session, data.name, 'Related events'), and do a dialog that says if (data.name === 'something) { do something.. }

I can't find anything in the docs that tells me how to identify what's been selected if I don't know the value beforehand.

session.message.text will contain the value of the button pressed. You should check for the value there.

Here is an example of how this works.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM