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
Gupshup allows you to write the bot code outside Gupshup's Bot Builder tool in any programming language of your choice.You can then associate a callback to the bot on Gupshup's platform.This callback will be the location of your bot code on the server where you have hosted the code. Whenever the bot is called by the user, Gupshup will send the relevant details to your bot through the callback URL using which you can respond back to the user.
Let's see how this can be achieved through an example using Java as the programming language.
Follow these steps below to build, deploy and test a weatherbot that responds to user's query about the weather in any city :
1. Create a bot on Gupshup platform - Go to My Bots section and then click on the '+' sign on the bottom right and give a name to the bot.
2. Write the bot's code in your IDE -
When a user interacts with the bot a GET call is made to the callback URL with additional parameters.The below table illustrates all the parameters which are sent to the bot.
Object Name | Sample Value | Description | Remarks |
---|---|---|---|
contextobj | {"botname":"demobot", "channeltype":"twitter", "contextid":"john", "contexttype":"p2p"} |
JSON object defining various parameter and way of conversation. |
channeltype - the messaging channel name from where the user interacts with the bot. For list of channels
refer appendix.
contextid / channelid - The user ID of a user on the particular messaging channel. contexttype - The type of conversation. For the list of probable values refer appendix. display - The display name of a user corresponding to the user ID on the messaging channel botname - The bot name. text - The message from the user. type - The type of message sent by the user. For the list of probable values refer appendix. |
senderobj | {"channelid":"john", "channeltype":"twitter", "display":"John Doe"} |
JSON object identifying the user details. This is useful in case of a group on a messaging channel. | |
messageobj | {"text":"Hi", "type":"msg"} |
JSON object for messages from the user. | |
channel | The channel from where the user is interacting with the bot. | ||
botname | demobot | The name of the bot. |
Now handle these in your code to define your bot logic. For Java let's create a Java Servlet.
Pseudo code -
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
String contextobj = request.getParameter("contextobj");
String senderobj = request.getParameter("senderobj");
String messageobj = request.getParameter("messageobj");
}
When you map your bot to the Proxy Bot for testing, a “botmappedevent” event is triggered. You can read more about Proxy Bots here. So you should handle this event to send a text to the user asking him/her to enter the city or you can also send this text if someone says 'Hi' to your bot.
Pseudo code -
JSONObject messageobjObj = JSONObject(messageobj);
String conversationType = messageobjObj.getString("type");
String message = messageobjObj.getString("text");
if((conversationType.equalsIgnoreCase("event")&& message.equalsIgnoreCase("botmappedevent"))|| (message.equalsIgnoreCase("hi")) )
{
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.print("Enter the city name");
out.flush();
out.close();
}
Once user provides the city name, call an external API to get the weather details
Pseudo code -
JSONObject messageobjObj = JSONObject(messageobj)
String conversationType = messageobjObj.getString("type");
String cityName = messageobjObj.getString("text");
if(conversationType.equalsIgnoreCase("msg"))
{
String URL = "https://api.worldweatheronline.com/free/v2/weather.ashx?q="+cityName+"&format=json&num_of_days=1&key={Your apikey}";
okhttp3.OkHttpClient client = new okhttp3.OkHttpClient();
okhttp3.Request request = new okhttp3.Request.Builder()
.url(URL)
.get()
.build();
okhttp3.Response response = client.newCall(request).execute();
}
In the example we have used the API of World Weather Online but you can choose any other API available. The apikey for this API is provide by World Weather Online after registration.
Once you have the response from the external API you can send the message to the user. There are two ways to do so -
a. Immediate response - In this you return a HTTP response back to the callback without any delay.
Pseudo code -
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.print("Weather in"+cityName+" is -"+responseofWeatherAPI);
out.flush();
out.close();
b. Delayed response - In this you can use the Gupshup send message API. For details please read this guide.
Pseudo code -
String botname = "weatherbot";
String botmessage = "Weather in"+cityName+" is -"+responseofWeatherAPI";
String URL = "http://api.gupshup.io/sm/api/bot/weatherbot/msg";
String body = "apikey={Your Gupshup API key}&botname="+botname+"&context="+contextobj+"&message="+botmessage;
okhttp3.OkHttpClient client = new okhttp3.OkHttpClient();
okhttp3.MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded");
RequestBody body = RequestBody.create(mediaType,body);
okhttp3.Request request = new okhttp3.Request.Builder()
.url(URL)
.post(body)
.build();
okhttp3.Response response = client.newCall(request).execute();
Once your code is ready, run it on the local server.
3. Deploy locally and associate the callback - To deploy the bot locally and associate the callback please read this guide
4. Testing your bot - You can test your bot either using the Proxy Bots or you can publish your bot to the specific messaging channel and test.
Testing flow for the bot which we have built above -
1. Mapping the bot to Proxy Bot and getting the help text for the mapping event.
2. Entering the city name and getting the result.
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