Search code examples
node.jsbotframeworkdirect-line-botframework

How to prevent Suggested Actions from being converted to text?


I am building a chatbot with Microsoft Botframework V4 using Node js. When I send a SuggestedActions to the user with short text it works perfectly as shown in this image Suggested Action Buttons. However, when the text of the buttons exceeds appx 20 characters they get converted to an ordered list with text.Buttons converted to text Is there a way to force the bot to send Buttons even if the text is long?

// this works perfectly
let buttons = ["Red", "Blue", "Yello"];
return await step.prompt(CHOICE_PROMPT, "Please Choose One", buttons);


// this does not work as expected, the buttons are converted to text and are //shown in a list

let buttons = ["I like Red and Blue",
    "I do not like any colo ",
    "Please stop   asking questions"
];
return await step.prompt(CHOICE_PROMPT, "Please Choose One", buttons);


Solution

  • This worked

     let buttons = ["I like Red and Blue",
            "I do not like any colo ",
            "Please stop   asking questions"
        ];
    
    let suggestedActions = MessageFactory.suggestedActions([buttons], 'Please choose one')
    
    return await step.prompt(CHOICE_PROMPT, suggestedActions);
    

    Found the best answer here: https://stackoverflow.com/a/57064662/10531724