Botframework-sdk: Can someone point me to some code inplementing list view for fb?

Created on 3 Jan 2017  路  5Comments  路  Source: microsoft/botframework-sdk

Most helpful comment

Try this:

var card =  {
  facebook: {
    attachment: {
      type: "template",
      payload: {
        template_type: "list",
        top_element_style: "compact",
        elements: [
          {
            title: 'title',
            image_url: null,
            subtitle: 'subtitle subtitle subtitle',
            buttons: [
              {
                title: 'title',
                type: 'web_url',
                url: 'http://www.google.com.au',
                webview_height_ratio: 'compact'
              }
            ]
          },
          {
            title: 'title',
            image_url: null,
            subtitle: 'subtitle subtitle subtitle',
            buttons: [
              {
                title: 'title',
                type: 'web_url',
                url: 'http://www.google.com.au',
                webview_height_ratio: 'compact'
              }
            ]
          }
        ]
      }
    }
  }
}

All 5 comments

You'll need to send a raw FB message via ChannelData/SourceEvent to display a List Template.

@craigjensen:
I have attempted to use the sourceEvent workaround but with no avail.

Every time I try to send this, I get a log out of the following:
_Error: Request to 'https://facebook.botframework.com/v3/conversations/1314733455250332-1257481210956934/activities/mid.1484799216105%3Acfddfe3b84' failed: [400] Bad Request_

This is my code for trying to do so:

var card = {
    facebook: {
        attachment: {
            type: "template",
            payload: {
                template_type: "list",
                elements: [
                    {
                        title: 'title',
                        image_url: null,
                        subtitle: 'subtitle subtitle subtitle',
                        buttons: [
                            {
                                title: 'title',
                                type: 'web_url',
                                url: 'http://www.google.com.au',
                                messenger_extensions: false,
                                webview_height_ratio: 'compact',
                                fallback_url: 'http://google.com.au'
                            }
                        ]
                    },
                    {
                        title: 'title',
                        image_url: null,
                        subtitle: 'subtitle subtitle subtitle',
                        buttons: [
                            {
                                title: 'title',
                                type: 'web_url',
                                url: 'http://www.google.com.au',
                                messenger_extensions: false,
                                webview_height_ratio: 'compact',
                                fallback_url: 'http://google.com.au'
                            }
                        ]
                    }
                ]
            }
        }
    }
}

var msg = new builder.Message(session).sourceEvent(card);

session.send(msg);

Any help would be highly appreciated.

Thanks,
Scott

Try this:

var card =  {
  facebook: {
    attachment: {
      type: "template",
      payload: {
        template_type: "list",
        top_element_style: "compact",
        elements: [
          {
            title: 'title',
            image_url: null,
            subtitle: 'subtitle subtitle subtitle',
            buttons: [
              {
                title: 'title',
                type: 'web_url',
                url: 'http://www.google.com.au',
                webview_height_ratio: 'compact'
              }
            ]
          },
          {
            title: 'title',
            image_url: null,
            subtitle: 'subtitle subtitle subtitle',
            buttons: [
              {
                title: 'title',
                type: 'web_url',
                url: 'http://www.google.com.au',
                webview_height_ratio: 'compact'
              }
            ]
          }
        ]
      }
    }
  }
}

@craigjensen; Wow. I don't know how I could have missed that. I was using the example on the FB dev page - I guess that's out of date.

Thanks a ton for that.

Glad to hear its working now. I'll go ahead and close this issue. Feel free to reopen if needed

Was this page helpful?
0 / 5 - 0 ratings

Related issues

akakoychenko picture akakoychenko  路  3Comments

verdysh picture verdysh  路  3Comments

mattlanham picture mattlanham  路  3Comments

clearab picture clearab  路  3Comments

hailiang-wang picture hailiang-wang  路  3Comments