Please make sure you sign up with the same account with which you would like to create and maintain the app from. Transferring apps/wallet balance from one account to another in future would not be possible
By logging in, you are agreeing to the Terms of Service and the Privacy Policy.
Want to outsource bot development? We have partners to get it done. Click here to get in touch
Suppose you have a conversational shopping bot that allows your users to buy t-shirts. A typical user would click on the bot, choose size, color, design and other details. The bot then asks your user about delivery date and location and so on. Just before confirming the order, your user changes his mind and wants to select a different color. The user has to then cancel the current flow and restart the entire process via conversation again. This is cumbersome and highlights the a problem with having wholly conversational bots: Text isn't the best option when there are multiple inputs. Having structured messages to get each input doesn't solve the problem of having to re-enter data.
To help bot makers improve the experience for their users, Gupshup has developed Serverless WebViews which are webviews that you can customize and embed within your chatbot to collect data from the user. These Webviews do not explicitly need to be hosted on any server (hence the name “Serverless”) and they serve two main purposes:
This guide will illustrate how you can create a custom Serverless WebView using the Gupshup Form Builder API and embed it within your chatbot. You can embed the webview within a chatbot on Facebook Messenger. These are the input fields that you can use in a Serverless WebView:
First you'll have to create a form using the Gupshup Form Builder API.
Go to gupshup.io, hover to 'Developers' Tab and click on 'API'. Once redirected to APIs page, click on the 'Form Builder' section. You will use the /facebook/smartmsg/form/create API to build a form. This is a POST request and to create a form you will have to specify the fields of the form in a JSON.
Here's a description of the JSON:
Property Name | Description | Type | Required |
---|---|---|---|
title | Form title | String | Y |
autoClose | Enable Facebook's autoClose feature. If 'true' the form closes as soon as the 'Submit' button is pressed. | Boolean | N |
message | On form submit given message value will be displayed. | String | N, default is 'Success! Your reply has been noted.' |
callback-url | URL to pass the user input when submit button is clicked. If you'd like the user input data to be passed back to the bot use: https://www.gupshup.io/developer/bot/{botName}/public. Read [this](https://www.gupshup.io/developer/docs/bot-platform/guide/http-call-to-a-bot) for more info | String | Y |
fields | 1. Type - The type of input element. Types supported are:
-input - Text Box - radio - Radio Button - select - Drop Down - checkbox - Check Box - date - Add a date picker. Date format MM/DD/YYYY - Time - Add a time field. Time format HH:mm (12 hours) - textarea - Text Area. - Fbid - Add this to enable the 'Add to Messenger' extension Minimum 1 element is required in fields 2. Name: The name of the field 3. Label: The display name on the form 4. Validations: You can add an array of regex validations and corresponding messages. Format is: - regex - Add a regular expression to validate the field - msg - Message displayed when input is erroneous |
String | Y |
users | User ID or any unique value for user form. The response contains unique forms for each user specified. |
String | Y |
Here's a sample JSON:
{
"title": "This is a test.",
"autoClose": false,
"message": "Thank You",
"callback-url": "https://www.gupshup.io/developer/bot/{botName}/public",
"fields": [{
"type": "fbid",
"name": "fbname",
"label": "fbName"
}, {
"type": "input",
"name": "name",
"label": "Name",
"validations": [{
"regex": "^[A-Z a-z]+$",
"msg": "Only alphabets are allowed in this field"
}, {
"regex": "^[A-Z a-z]{6,}$",
"msg": "Minimum 6 characters required"
}]
}, {
"type": "radio",
"name": "gender",
"label": "Gender",
"options": [
"Male",
"Female"
],
"validations": [{
"regex": "",
"msg": ""
}]
}, {
"type": "select",
"name": "account",
"label": "AccountType",
"options": [
"current",
"savings"
],
"validations": [{
"regex": "",
"msg": ""
}]
}, {
"type": "checkbox",
"name": "interest",
"label": "Interests",
"options": [
"Cooking",
"Reading"
],
"validations": [{
"regex": "",
"msg": ""
}]
}],
"users": [
"Testing"
]
}
You can copy the sample JSON replacing {botName} with the name of your bot, in the callback URL field and use the Form Builder API to create a new form. You can also create your custom form JSON. If all goes well you will get a sample response like this:
[
{
"embedlink": "https://smapi.gupshup.io/sm/api/facebook/smartmsg/embed/786d48b1-xxx-4ebf-9fe1-998393fadab4",
"expired": false,
"fb-button": {
"messenger_extensions": true,
"title": "This is a test.",
"type": "web_url",
"url": "https://smapi.gupshup.io/sm/api/facebook/smartmsg/embed/786d48b1-xxxx-4ebf-9fe1-998393fadab4",
"webview_height_ratio": "tall"
},
"id": "786d48b1-xxxx-4ebf-9fe1-998393fadab4",
"signed-for": {
"display": "Testing",
"subdisplay": "Testing"
},
"smid": "4436"
}
]
Here 'embedlink' contains the link to the form that is created.
Webview_height_ratio refers to the size of the webview. It comes in three sizes - compact, tall and full.
In our example above, we have specified the endpoint of the bot as the callback URL. For more details about handling the HTTP endpoints of a bot read this. Thus the user's response is handled in the HttpEndpointHandler() method. The user input is stored in the event.params.payload parameter. Use this parameter to extract out all the fields of the form that you have created and store it into a database.
In your HttpEndpointHandler() add this code snippet:
function HttpEndpointHandler(context, event) {
formId = event.params.linkId;
var userDetails = event.params.payload;
for(var i=0; i < userDetails.length; i++)
{
if(userDetails[i]["fieldname"]=='name')
{
name = userDetails[i]["fieldvalue"];
continue;
}else if(userDetails[i]["fieldname"]=='account')
{
account = userDetails[i]["fieldvalue"];
continue;
}else if(userDetails[i]["fieldname"]=='gender')
{
gender = userDetails[i]["fieldvalue"];
continue;
}else
{
interests = userDetails[i]["fieldvalue"];
}
}
context.simpledb.doGet(formId);
}
Where 'name', 'account' and 'gender' correspond to the 'name' field of the JSON that we sent as part of the POST request earlier. We use the doGet method to query the database against the 'formId' of the form that was introduced earlier.
Do note that you cannot use a context.sendResponse within the HttpEndpointHandler() method. This is because the sendResponse will be sent to the Serverless Webview created and not the Messenger session that is in use.
In your DbGetHandler() method, we will construct a message using the input from the form. We will then use the Gupshup Send Message API to send this message back to the user.
function DbGetHandler(context, event) {
var done = null;
var apikey = '<API KEY>';
botname = encodeURI(event.botname);
contextobj = event.dbval;
apikey = encodeURI(apikey);
message = encodeURIComponent("Your Details are:\n" +
"Name: "+ name + "\n" +
"Gender: "+ gender + "\n" +
"Account Type: "+ account + "\n" +
"Interests: "+interests);
var url = "https://api.gupshup.io/sm/api/bot/" + botname + "/msg";
var body = "context=" + contextobj + "&message=" + message;
var headers = "{\"Accept\": \"application/json\",\"apikey\": \"" + apikey + "\",\"Content-Type\": \"application/x-www-form-urlencoded\"}";
context.simplehttp.makePost(url, body, JSON.parse(headers), done);
}
In the above example, the callback URL was the bot itself i.e the user input was sent back to the bot code hosted on Gupshup. You can chose to have an external callback as well. For example, we can use a Request Bin as a callback URL. Just modify the JSON that you are sending as part of the POST call.
{
"title": "This is a test.",
"autoClose": false,
"message": "Thank You",
"callback-url": "requestb.in/1i5oasr1?,
"fields": [{
"type": "fbid",
"name": "fbname",
"label": "fbName"
}, {
"type": "input",
"name": "name",
"label": "Name",
"validations": [{
"regex": "^[A-Z a-z]+$",
"msg": "Only alphabets are allowed in this field"
}, {
"regex": "^[A-Z a-z]{6,}$",
"msg": "Minimum 6 characters required"
}]
}, {
"type": "radio",
"name": "gender",
"label": "Gender",
"options": [
"Male",
"Female"
],
"validations": [{
"regex": "",
"msg": ""
}]
}, {
"type": "select",
"name": "account",
"label": "AccountType",
"options": [
"current",
"savings"
],
"validations": [{
"regex": "",
"msg": ""
}]
}, {
"type": "checkbox",
"name": "interest",
"label": "Interests",
"options": [
"Cooking",
"Reading"
],
"validations": [{
"regex": "",
"msg": ""
}]
}],
"users": [
"Testing"
]
}
The sample URL for a callback looks like this:
{
"linkId": "f42414e2-ce1a-xxx-b40a-e88e4d4d9aee",
"payload": [{
"fieldname": "name",
"fieldvalue": "Alice"
},{
"fieldname": "gender",
"fieldvalue": "Male"
},{
"fieldname": "account",
"fieldvalue": "savings"
},{
"fieldname": "interest",
"fieldvalue": "Cooking"
}],
"time": 1479904354249,
"userid": "UserID"
}
Like the name suggests, Facebook Messenger Extensions allow you to add functionality to your user's Messenger experience. With Extensions you can get information on the user, accept payments, auto-close webViews, make your bot viral with sharing, and deeply integrate with Messenger's UI.
To use Messenger Extensions in your bot, you must first whitelist the domain the webView is served from. Gupshup has an API to help you do this:
POST /sm/api/facebook/smartmsg/messenger/extension/enable
pageAccessToken= {FB page access token}
You can view this API here. The pageAccessToken can be obtained only once a FB App and FB page has been created.
Facebook has a feature which closes the webView after a transaction is complete or the form is filled. To enable this, first whitelist the domain using the API mentioned above.
Then in the JSON used to construct your form, change the 'autoClose' parameter to 'true'.
This website uses the following types of cookies: strictly necessary, functional and performance cookies. To know more information regarding how these cookies may impact your experience, please click on Settings.
These cookies are necessary for the website to function and cannot be switched off in our systems. They are set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Name | Provider | Purpose | Expiry | Type |
---|---|---|---|---|
CookieConsent | CookieBot | Stores the user's cookie consent state for the current domain | 1 year | HTTP |
smacon | www.gupshup.io | Authenticating user to access our website | Session | HTTP |
rc::c rc::b |
This cookie is used to distinguish between humans and bots. | Session | HTTP | |
JSESSIONID | www.gupshup.io | Preserves users states across page requests. | Session | HTTP |
gipuserid | www.gupshup.io | Collect & store User ID for easy accessibility | 5 years | HTTP |
__stripe_mid | www.gupshup.io | Stripe is used to make credit card payments in our application. Stripe uses this cookie to remember who you are and process payments without storing any credit card information on our servers. Know more | 1 year | First party |
__stripe_sid | www.gupshup.io | Stripe is used to make credit card payments in our application. Stripe uses this cookie to remember who you are and process payments without storing any credit card information on our servers. Know more | 30 minutes | First party |
These cookies enable the website to provide enhanced functionality and personalisation such as the website content being provided in the preferred language for your location. They may be set by us or by third party providers whose services we have added to our pages.
Name | Provider | Purpose | Expiry | Type |
---|---|---|---|---|
gs_lang_pref | www.gupshup.io | Remember the user's selected language version of a website. This allows the website to show content most relevant to that language. | Session | HTTP |
These cookies allow us to measure visits, traffic sources and engagement so we can improve the performance of our site. They help us learn which pages are the most and least popular and see how visitors move around the site. All information these cookies collect is aggregated and therefore anonymous.
Name | Provider | Purpose | Expiry | Type |
---|---|---|---|---|
_ga | www.gupshup.io | Registers a unique ID that is used to generate statistical data on how the visitor uses the website. Know more | 2 years | HTTP |
_ga_# | www.gupshup.io | Used by Google Analytics to collect data on the number of times a user has visited the website as well as dates for the first and most recent visit. Know more | 2 years | HTTP |
_gat | www.gupshup.io | Used by Google Analytics to throttle request rate. Know more | 1 day | HTTP |
_gid | www.gupshup.io | Registers a unique ID that is used to generate statistical data on how the visitor uses the website. | 1 day | HTTP |
__utmz | www.gupshup.io | Stores the traffic source or campaign that explains how the user reached your site. The cookie is created when the javascript library executes and is updated every time data is sent to Google Analytics. Know more | 6 months | HTTP |
__utma | www.gupshup.io | Used to distinguish users and sessions. The cookie is created when the javascript library executes and no existing __utma cookies exists. The cookie is updated every time data is sent to Google Analytics. Know more | 2 years | HTTP |
initialTrafficSource | www.gupshup.io | Used by Google Tag Manager to track the initial traffic source of the visitor. | 2 years | HTTP |
We may use cookies, web beacons, tracking pixels, and other tracking technologies when you visit our website gupshup.io including any other media form, media channel, mobile website, or mobile application related or connected thereto (collectively, the “Site”) to help customize the Site and improve your experience.
We reserve the right to make changes to this Cookie Policy at any time and for any reason. We will alert you about any changes by updating the “Last Updated” date of this Cookie Policy. Any changes or modifications will be effective immediately upon posting the updated Cookie Policy on the Site, and you waive the right to receive specific notice of each such change or modification.
You are encouraged to periodically review this Cookie Policy to stay informed of updates. You will be deemed to have been made aware of, will be subject to, and will be deemed to have accepted the changes in any revised Cookie Policy by your continued use of the Site after the date such revised Cookie Policy is posted.
Cookie Policy (“Policy”) provides detailed information about cookies and JavaScript libraries, how we use them, and how you can manage them when you visit Gupshup website (“website”).
Cookies make it easy and efficient for you to navigate and interact with the Gupshup website. Cookies are small text files that we place on your device (e.g. computer or smartphone) when you visit our website. We will always ask your consent to set cookies e.g., to remember your preferences that are more relevant to you.
Cookies which are necessary for the website to function cannot be switched off.
You can at any time change or withdraw your consent from the Cookie Declaration on our website. (see "Cookie Consent" below in footer).
Learn more about who we are, how you can contact us and how we process personal data in our Privacy Statement.
Your consent applies to the www.gupshup.io domain only.
Cookies are used to make the user's web experience faster, convenient and personalised. For example you can select a language to view a website the first time you visit it. When you visit the website again it will save your preference.
Session cookies: these cookies remain in your browser during your browser session only, i.e. until you leave the website.
Persistent cookies:these cookies remain in your browser for a set period of time after the browser session expires (unless you delete them in advance).
First-party cookies:these cookies are created by us, that is the domain you are visiting (i.e. the website displayed in the URL window).
Third-party cookies:these cookies are created by domains other than the one you are visiting at the time.
When you first visit our website you will see our Cookie Declaration where you can see all the cookies. You can change or withdraw your consent at any time (see "Cookie Consent" below in footer).
If you have any questions regarding this Policy, you may reach our Data Protection Officer at dpo@gupshup.io
Added below language support for WhatsApp,
Bot developers for Line: With the release of Line Messaging API, all BOT API Trial Accounts are scheduled to be deleted. Please republish your bot according to new Line implementation, mentioned under Publish tab in My Bots section.
New tool for non-developers- Our Flow Bot Builder helps users create their bot messaging flow with a graphical editor.
API.ai tool is now available for developing your NLP/AI bot.
Gupshup Enterprise APIs (SMS,Voice and Email) are now available directly in the APIs section.
New channels added for publishing bots- Smooch.io and your website as a web widget.
Now you can access our services including the bot builder tool using your Facebook login credentials.
Now you can delete the dummy bots created for testing from the My Bots Dashboard.
You can now access Bot specific data from your Dashboard itself.
Introducing a hassle free bot development experience for users to instantly create bots using our pre-defined restaurant templates. Check out our blog to know more.
We are removing few redundant parameters, that were being sent when a callback happens to your bot (i.e. inbound message comes to your bot).
Following is the list of parameters.
However, we will continue to send following parameters. If you are using any of the deprecated parameters, we request you to use these alternatives.
You are requested to make a note of this and do the necessary changes immediately to your bot code to keep it working. Should you need any help, please feel free to send an email to devsupport@gupshup.io