The Messenger Platform allows you to open a standard webview, where you can load webpages inside Messenger. This lets you offer experiences and features that might be difficult to offer with message bubbles, such as picking products to buy, seats to book, or dates to reserve.
You can open the webview with any of the following:
In each of these instances, you can specify how the webview should look and behave.
If your experience uses the Messenger Extensions described in this section, remember to set the messenger_extensions
parameter to true
in the menu item or button you are invoking it from!
Messenger 웹 보기에서 Messenger Extensions SDK를 활성화하고 웹페이지를 표시하려면 반드시whitelisted_domains
봇의 Messenger 프로필 속성에서 도메인(하위 도메인 포함)을 화이트리스트에 추가해야 합니다. 그러면 신뢰하는 도메인만 SDK 함수를 통해 제공되는 사용자 정보에 액세스할 수 있습니다.
도메인을 화이트리스트에 추가하는 방법에 대한 자세한 내용은 whitelisted_domains
참고 자료를 참조하세요.
As with any webpage, the <title>
tag sets the text displayed in the title bar for the webview.
<html> <head> <title>My Awesome Webview</title> </head> ... </html>
It is a good idea to close the webview after a transaction is complete, especially if actions the user took will result in a message in the thread. This can be done with the Messenger Extensions SDK or by using a redirect URL.
To close the webview using the Messenger Extensions SDK, call MessengerExtensions.requestCloseBrowser()
. You can also optionally implement success and error callbacks functions.
MessengerExtensions.requestCloseBrowser(function success() { // webview closed }, function error(err) { // an error occurred });
You can also close the webview by redirecting the user to a URL with the following format:
https://www.messenger.com/closeWindow/?image_url=<IMAGE_URL>&display_text=<DISPLAY_TEXT>
The values set for the display_text
and image_url
parameters will be displayed briefly until the window closes. Note that this method will only close if you redirect from your URL/Page. Directly opening the URL will not close the browser.
This only works on Android. On iOS, the text and image will be displayed, but the browser will not close automatically.
To give you the ability to tightly integrate experiences in the webview with the Messenger experience, we also have made the Messenger Extensions JS SDK available, which makes added functionality accessible in the webview, such as information about the thread context.
For more information, see Adding the Messenger Extensions SDK.
Use it for longer interactions (more than three steps) where people might want to edit their input or otherwise proceed in a non-linear fashion.
Use it for content that's especially visual.
Use it for user preferences, or to allow on-demand changes to previous selections.
Use it in combination with more conversational interactions.
Configure the height of your webview to match its content — and preserve the context of the thread beneath.
Take advantage of Messenger's webview extensions to bring the thread's context into the webview.
Don't feel limited to collecting all form information at once. You can capture it piece by piece conversationally, then use a form in the webview for later edits.
Mix conversational and webview interactions, and keep any given interaction brief. Combine thread and webview interactions for a "Messenger-native" experience.