Search code examples
botsbotframework

how to capture textblock text in adaptive card in Node js


I am working on bot using microsoft bot framework in Node Js, I want text value to be captured from chat text and submitted with adaptive card submit action. but I am getting empty value when I submitted the adoptive card.

my bot.js file terminal output

when I , submit the adaptive card on emulator, my "const ques" got undefined value. can i store my chat text to external files, from there I will be accessed the text after submition of adaptive card? or any other solution to get value in "const ques" ?


Solution

  • Values submitted by adaptive cards have a slightly different approach. You need to capture the text in your message event handler:

            this.onMessage(async (context, next) => {
            const activity = context.activity;
            // Convert the user's Adaptive Card input into the input of a Text Prompt
            // Must be sent as a string
            if (!activity.text && activity.value) {
                activity.text = JSON.stringify(activity.value);
            };
            await this.dialog.run(context, this.dialogState);
            await next();
        });