user9463688
user9463688

Reputation:

Adaptive card action not triggered

I have dialog called "form search" which has an adaptive card. when i click submit button the control doesn't go to the next flow but ends with error . But if use hero card the button click is triggering the next flow.what might be the issue.

session.message does not contain and value and also it does not trigger to next flow.

bot.dialog("/FormSearch",[

    function(session,args, next) {

        var card = {
            contentType: "application/vnd.microsoft.card.adaptive",
            content:{
                "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
                "type": "AdaptiveCard",
                "version": "1.0",
                "body": [
                    {
                        "type": "ColumnSet",
                        "columns": [
                            {
                                "type": "Column",
                                "width": 2,
                                "items": [
                                    {
                                        "type": "TextBlock",
                                        "text": "Tell us about yourself",
                                        "weight": "bolder",
                                        "size": "medium"
                                    },
                                    {
                                        "type": "TextBlock",
                                        "text": "Your name",
                                        "wrap": true
                                    },
                                    {
                                        "type": "Input.Text",
                                        "id": "myName",
                                        "placeholder": "Last, First"
                                    },
                                    {
                                        "type": "TextBlock",
                                        "text": "Your email",
                                        "wrap": true
                                    },
                                    {
                                        "type": "Input.Text",
                                        "id": "myEmail",
                                        "placeholder": "[email protected]",
                                        "style": "email"
                                    },
                                    {
                                        "type": "TextBlock",
                                        "text": "Phone Number"
                                    },
                                    {
                                        "type": "Input.Text",
                                        "id": "myTel",
                                        "placeholder": "xxx.xxx.xxxx",
                                        "style": "tel"
                                    }
                                ]
                            },
                            {
                                "type": "Column",
                                "width": 1,
                                "items": [
                                    {
                                        "type": "Image",
                                        "url": "https://upload.wikimedia.org/wikipedia/commons/b/b2/Diver_Silhouette%2C_Great_Barrier_Reef.jpg",
                                        "size": "auto"
                                    }
                                ]
                            }
                        ]
                    }
                ],
                "actions": [
                    {
                        "type": "Action.Submit",
                        "title": "Submit"
                    }
                ]
            }
        }

    // var card = new builder.HeroCard(session)
    // .title('card title')
    // .subtitle('subtitle')
    // .images([builder.CardImage.create(session, 'http://oobrien.com/wordpress/wp-content/uploads/2016/07/googlemaps_july2016.jpg')])
    // .buttons([
    //     builder.CardAction.openUrl(session, 'https://www.google.com', "Navigate"),
    //     builder.CardAction.postBack(session, 'select', "select")
    // ]);



         var msg = new builder.Message(session).addAttachment(card);
        builder.Prompts.text(session, 'Fill in the below form'); 
        session.send(msg);


    },

    function(session,results) {
        console.log('next flow ____________');
        if (session.message && session.message.value) {
            console.log('A Card Submit Action obj was received');
           session.send('form submitted');
        }

    }


]);

Error message triggered

Error message screenshot

Upvotes: 3

Views: 2084

Answers (1)

D4RKCIDE
D4RKCIDE

Reputation: 3426

Please see the documentation here regarding adaptive cards in the botbuilder-webchat repo.

Specifically this:

The data property of the action may be a string or it may be an object. A string is passed back to your bot as a Bot Builder SDK imBack activity, and an object is passed as a postBack activity. Activities with imBack appear in the chat stream as a user-entered reply. The postBack activities are not displayed.

As for your code please try moving this block of code into your dialog function:

    if (session.message && session.message.value) {
        console.log('A Card Submit Action obj was received');
       session.send('form submitted');
    }

There is also a good node example here for handling submit actions.

Upvotes: 1

Related Questions