Search code examples
facebookibm-watsonwatson-assistant

How to do Generic Template of messenger Facebook with IBM Watson Assistant Dialog


I have a working Assistant from IBM Watson I want to show multiple choices as Image, Description, and Link combinations this feature is available for messenger under Generic Template but I cant find an option at dialog responses that can get me do this image

{
"output": {
    "generic": [
        {
            "values": [
                {
                    "text": "I got that"
                }
            ],
            "response_type": "text",
            "selection_policy": "sequential"
        }
    ],
    "facebook": {
        "message": {
            "attachment": {
                "type": "template",
                "payload": {
                    "template_type": "generic",
                    "elements": [
                        {
                            "title": "Welcome!",
                            "image_url": "https://petersfancybrownhats.com/company_image.png",
                            "subtitle": "We have the right hat for everyone.",
                            "default_action": {
                                "type": "web_url",
                                "url": "https://petersfancybrownhats.com/view?item=103",
                                "webview_height_ratio": "tall"
                            },
                            "buttons": [
                                {
                                    "type": "web_url",
                                    "url": "https://petersfancybrownhats.com",
                                    "title": "View Website"
                                },
                                {
                                    "type": "postback",
                                    "title": "Start Chatting",
                                    "payload": "DEVELOPER_DEFINED_PAYLOAD"
                                }
                            ]
                        }
                    ]
                }
            }
        }
    }
}

}

I have used this JSON at the dialog node with no success


Solution

  • If any one is facing the same problem you should do it as output.integrations.facebook not output.facebook

    so the object will be mothing like that

    {
    "output": {
        "generic": [
            {
                "values": [
                    {
                        "text": "I got that"
                    }
                ],
                "response_type": "text",
                "selection_policy": "sequential"
            }
        ],
        "facebook": {
            "message": {
                "attachment": {
                    "type": "template",
                    "payload": {
                        "template_type": "generic",
                        "elements": [
                            {
                                "title": "Welcome!",
                                "image_url": "https://petersfancybrownhats.com/company_image.png",
                                "subtitle": "We have the right hat for everyone.",
                                "default_action": {
                                    "type": "web_url",
                                    "url": "https://petersfancybrownhats.com/view?item=103",
                                    "webview_height_ratio": "tall"
                                },
                                "buttons": [
                                    {
                                        "type": "web_url",
                                        "url": "https://petersfancybrownhats.com",
                                        "title": "View Website"
                                    },
                                    {
                                        "type": "postback",
                                        "title": "Start Chatting",
                                        "payload": "DEVELOPER_DEFINED_PAYLOAD"
                                    }
                                ]
                            }
                        ]
                    }
                }
            }
        }
    }
    }