URL Button

The URL Button can be used to open a web page in the in-app browser. This button can be used with the Button and Generic Templates.

  1. Implementation
  2. Linking to Your Bot from a URL Button
  3. Features Available Inside the Webview

Webviews can be shown in compact, tall and full sizes.

Implementation

To get started, calling the Send API, add a button with the type web_url, and include the URL you want to open in the url field.

    ...
    
    "buttons":[
      {
        "type":"web_url",
        "url":"https://petersfancyapparel.com/classic_white_tshirt",
        "title":"View Item",
        "webview_height_ratio": "compact"
      }
    ]
    
    ...
  

You can also specify a variety of attributes to better control how the webview opens:

    ...

    "buttons":[
      {
        "type":"web_url",
        "url":"https://petersfancyapparel.com/criteria_selector",
        "title":"Select Criteria",
        "webview_height_ratio": "full",
        "messenger_extensions": true,  
        "fallback_url": "https://petersfancyapparel.com/fallback"
      }
    ]
        
    ...        

buttons Fields

Property Name Description Type Required

type

Type of button. Must be web_url.

Enum

Y

title

Button title. 20 character limit.

String

Y

url

This URL is opened in a mobile browser when the button is tapped

String

Y

webview_height_ratio

Height of the Webview. Valid values: compact, tall, full.

Enum

N, default is full

messenger_extensions

Must be true if using Messenger Extensions.

Boolean

N

fallback_url

URL to use on clients that don't support Messenger Extensions. If this is not defined, the url will be used as the fallback. It may only be specified if messenger_extensions is true.

String

N

webview_share_button

Set to hide to disable sharing in the webview (for sensitive info).

String

N

Linking to Your Bot from a URL Button

If you're specifying a URL button as part of a custom message to be shared in the share button or inside the webview, you may wish for the recipient of the share to enter your bot using the button (rather than a URL in the webview).

To enable do, all you must do is link to the bot using m.me. If you want the recipient of the share to activate a specific flow when they click the link, consider adding a ref parameter.

For instance:

    ...

    "buttons":[
      {
        "type":"web_url",
        "url":"http://m.me/petershats?ref=take_quiz",
        "title":"Take the Hat Quiz",
      }
    ]
        
    ...        

When the user taps the button, the bot will directly open, bypassing the webview.

Features Available Inside the Webview

After opening the webview, there are a lot of APIs available in Messenger Extensions to better integrate your experience with Messenger.

These include closing the window, sharing, payments, and much more!

Learn More About Messenger Extensions →