IntelliTicks
  • Introduction
  • Getting Started
    • Overview
    • Build your first playbook
      • Start with Pre-build Templates
      • Start from scratch
  • Installation
    • IntelliTicks Plugin Script
    • Plugin Installation
  • Facebook Messenger Bot
    • Getting Started
      • Connect Facebook Page
      • Link Playbook to Messenger
    • Testing FB Messenger Bot
  • WhatsApp Bot
    • Benefits of WhatsApp Chatbots
    • Getting Started
    • FAQs
  • AI Builder
    • Playbooks
    • Nodes
      • Add and Send Data
        • Text
        • Image
        • Links
        • Youtube
        • Gallery
        • Dynamic Node
      • Collect User Data
        • Quick Reply
        • Form
        • Datepicker
        • Web View
        • Payment
        • Rating
        • Slider
        • Ask Question
        • Mutli Selection Reply
        • Quick Reply (with branches)
      • Redirect Users
        • URL redirect
        • Conditional branching
        • Go to Playbook
        • Jump to node
      • Export & Import
        • JSON API
      • Connect Users To A Human
        • Notify Agent
        • End Automation
      • Additional
        • Wait
        • Client Javascript
        • Actions
    • Actions
    • FAQ Training
    • Keyword Training
    • Advanced
      • Advanced Actions
  • Flash Responses
    • Flash Response
    • Create Flash Response
    • Using Flash Response
  • Customizing Platform
    • Widget
      • Theme Customization
      • Chat Widget Texts in Local Language
      • Adding Start Over button
      • URL Rules
      • Advanced Customization
        • How to Easily Add Custom CSS to Chat Widget
    • Chat icon/Bot Profile Photo
    • Different chatbot on each URLs
  • Integrations
    • WordPress Integration
    • Shopify Integration
    • Shopify Installation via Private Apps
    • Google Analytics
    • Magento Integration (1.x)
    • Magento Integration (2.x)
    • LeadSquared Integration
    • Marketo Integration
    • Salesforce Integration
    • Zapier Integration
      • Data Available in Zapier
    • Zoho CRM Integration
    • Wix Integration
    • Custom/in-house CRM integration
  • How to
    • Change the Default Playbook
    • Schedule meetings on calendar
      • How to integrate calendly for meetings
      • How to integrate Acquity for meetings
      • How to Integrate YouCanBook for meetings
    • Block a User
    • Delete a User
    • Hide trigger message from website
    • How to show chatbot in right middle of website
    • Start chatbot on a button click
    • Create chatbot landing page
    • Customize Landing Page Link
    • Enable Notifications on browser
    • Popup bot on Facebook page automatically
    • How to send data to chatbot via Javascript
  • Growth Hacks
    • Facebook Retargeting
    • Messenger Ads to chatbot
  • Troubleshooting
    • Messenger Bot is not working as expected
    • How do I remove the Messenger app in Shopify?
    • Push Notification Issues
  • Partnerships
    • White-labeled Chat Platform
    • Affiliate Partnership
  • Miscellaneous
    • Languages Supported
Powered by GitBook
On this page
  • Web Webview
  • Facebook Webview

Was this helpful?

  1. AI Builder
  2. Nodes
  3. Collect User Data

Web View

Web Webview

Webview allows you to create complex UI using custom html code. Since webview communicates with chatbot to exchange data, just any URL would not work until relevant code has been added to establish communication.

To create a webview the most important parameter is template URL. It can be URL of any webpage. There must be few scripts defined in the webpage for the following

  1. Send a ready event to parent when webview is ready, so that bot can remove loader and show the webview.

  2. Listen to postMessage for msgId(and optional data) and save it.

  3. When interaction with webview is over, postMessage to parent along with msgId and option data.

Below is the sample script to demonstrate the same.

Please paste the script given below to your html so that loader is removed and webview is shown.

var msgId = null, body = null;
function onPostMessage(event) {
    if (!event || !event.data || !event.data.msgId) return; //required. check for msgId 
    msgId = event.data.msgId;
    if (event.data.body) {
        try {
            body = JSON.parse(event.data.body);//optional body to be passed from AI builder.
            //this body can be used anywhere in the code later
        } catch(error){
            console.error('Error on parsing body data', error);
        }
    }
}
window.addEventListener('message', onPostMessage);
parent.postMessage({ type: "webview.frame.ready" }, '*');//trigger this whenever webview is ready to be displayed

//call this function with text(to be shown in chat) along with optional data 
function closeFrame(text, data) {
    //data passed here will be available as a res param in the Res function of webview.
		parent.postMessage({ type: "webview", jsonData: JSON.stringify(data || {}), msgId: msgId, text: text }, '*');
}

You need to call closeFrame function to close the webview.

Check the source of above URL to understand it more.

Facebook Webview

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.

Setting Webview Template URL (Required Domain Whitelisting)

To display a webpage in the Messenger webview you must whitelist the domain, including sub-domain, in the whitelisted_domains property of your page Messenger Profile. This ensures that only trusted domains have access to user and node information available via SDK functions.

If you facing any issue on whitelisting domains please contact at support@intelliticks.com

Setting Webview Height

You can specify the height of the webview when it opens in messenger by setting the Webview Display Mode property when configuring webview node. The following sizes are supported:

  • COMPACT

  • TALL

  • FULL

Adding the IntelliTicks Messenger Extensions SDK

1. Include the Messenger Extensions JS SDK

Add the Messenger Extensions Javascript SDK to the page being loaded in the webview with the code below. You should insert it directly after the opening body tag on each page you want to load it:

<script src="//webview.intelliticks.com/messenger/common/iticks_fb.js"></script>

2. Wait for the SDK load event

iticksInit will be called when the IntelliTicks Messenger Extensions JS SDK is done loading. You can use this as a trigger to call other functions available in the SDK.

window.addEventListener('iticksInit', async function () {
  // the IntelliTicks Messenger Extensions JS SDK is done loading            
})

IticksMessengerExtensions and its methods are available in the Messenger webview when you include the IntelliTicks Messenger Extensions JS SDK.

Function

Description

getWebviewData()

Retrieve node Req Body for the person that opened the webview.

sendWebviewData()

Send data back for the person that engage with webview.

requestCloseBrowser()

Close the webview and return to the Messenger conversation.

Get Webview Req Body Data

The getWebviewData() method retrieves Req Body information of the node. It is useful for creating interactive group experiences, as well as restricting any content that was intended to be shared only to a certain thread.

const response = await IticksMessengerExtensions.getWebviewData();
if(response.isValid) {
    const data = response.data; // Req Body data
} else {
    // Error on getting webview data
}

Send Webview Data

The getWebviewData(text, jsonData) method send back data to conversation and help to proceed flow further.

const response = await IticksMessengerExtensions.sendWebviewData(text, jsonData);
if(response.isValid) {
    // Data sent successfully
} else {
    // Error on sending webview data
}

Closing the Webview

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 IntelliTicks Messenger Extensions SDK just call

IticksMessengerExtensions.requestCloseBrowser();             

Setting Webview Title

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>

PreviousDatepickerNextPayment

Last updated 4 years ago

Was this helpful?

You can also check out sample webview URL and use it in the webview to see how it work.

For more information on whitelisting domains, see the

http://webview.intelliticks.com/common/datepicker.html
whitelisted_domains reference
facebook webview