user9463688
user9463688

Reputation:

Suggestive Actions within Waterfall Dialog not getting triggered?

Screenshots

image

Dialog image

Version

4.6.0 Using directline to use in website

Describe the bug

I am trying to trigger a waterfall dialog during the intro of the bot session. I want to show a few suggestive card options along with an intro and use waterfall to follow those steps. But unfortunately, the suggestive actions are not getting triggered? Is it because maybe I need to pass the context to the dialog and trigger the suggestive actions from that context instead of the dialog context?

if I send a normal text message from the dialog it works fine but not the suggestive action return await step.context.sendActivity('Welcome' );

Expected behavior

When I load the bot in the web I expect to see the bot greets me some suggestive card options. It has to trigger the WELCOME dialog and display the suggestive actions

Where the suggestive Action is working

For example: if I trigger the suggestive action inside async onTurn directly without calling the dialog then it works fine. But if I do it this way I will not be able to followup the clicks on the suggestive actions to steps so i wanted to call the dialog and do the activity within the waterfall dialog

  async onTurn(context) {
if (context.activity.name === 'webchat/join') {
var suggestlist = [{
                    type: ActionTypes.PostBack,
                    title: ji18n('option 1'),
                    value: { id: '1000000', type: 'option1' }
                }];



                var suggestedAction = MessageFactory.suggestedActions(suggestlist);

                return await step.context.sendActivity(suggestedAction);

}  
})

Upvotes: 1

Views: 123

Answers (1)

Steven Kanberg
Steven Kanberg

Reputation: 6393

The title property of your suggestList requires a string value, however ji18n() returns an object. I believe this is what is blocking your suggestedAction from rendering.

Consider implementing the following, as referenced in the doc:

.addDialog( new WaterfallDialog(MAIN_WATERFALL_DIALOG, [
  async ( step ) => {
    const activity = step.context.activity;

    const input = {
      "option1": [{
        "$": {
          "en-US": `This is "option 1" in English`,
          "fr-FR": `Il s'agit de "l'option 1" en anglais`
        }
      }]
    }

    const output = ji18n(input, activity.locale)
    console.log('Output ', output['option1'][0])

    const suggestList = [{
      type: ActionTypes.PostBack,
      title: output['option1'][0],
      value: { id: '1000000', type: 'option1' }
    }]

    const suggestedAction = MessageFactory.suggestedActions( suggestList )
    return await step.context.sendActivity( suggestedAction );
  }
]))

English result returned as output & button title:

enter image description here

enter image description here

French result returned as output & button title:

enter image description here

enter image description here

Hope of help!

Upvotes: 0

Related Questions