What to look for first of all when developing your own bot?
Chat bots will not surprise anyone now. They began to appear massively in various services and instant messengers. The main social platforms are gradually introducing the possibility of developing their own bots, which stimulates third-party developers. They offer more and more bots, useful and different. Some bots allow you to check the balance of your bank account, others - help make a purchase or book a table in a restaurant.
')
Why bots have become so popular? This is a rather complicated question. Probably the main reason - a huge number of applications in various markets. The developer (individual or company) should spend a lot of time and effort on the promotion of the application. There are already millions of applications, and every day the number of programs increases. But there is a way out - these are just bots. Now they are much smaller than mobile applications, and if you create an interesting bot, it can become popular in a matter of days, if not hours. Users love bots - after all, they are very convenient, in most cases. What to look for when creating your own bot? What is the process of creating it? Let's talk about all this right now.
What you need to consider when creating your bot?
• Interaction quality - the way a user interacts with a bot determines its success. Variations of the dialogue should be rich and quite useful. A bot that does not understand a slightly rephrased query will look ridiculous. IBM Watson, for example, has proven that trainee chatbots can be used to defeat the usual participants in such game shows as "Own Game", based on knowledge. Since the natural language of Watson and its variations of dialogs can be found on the IBM Bluemix platform, you can use them for your bot. Your bot does not have to pass the Turing test. Banking applications, for example, have a certain set of things that they can do. So you shouldn’t create an overloaded bot that will try to answer open-ended questions like “How can I get rich?”
• Independence from messaging platforms - This area is changeable; It’s hard to say what will be the preferences of your target audience in terms of instant messengers in a year. If possible, create bots that are not tied to a specific messenger.
• Architecture - for your bot to be dynamic and allow the user to successfully complete the task, he must work clearly with other cloud services and previous work. Make sure that you use technology that allows you to easily store and access information and will not let you down with a growing stream of users. Bots are more than just a chat, make sure that you can formulate and implement the logic of your business as flexibly and measurable as possible.
• Think strategically - bots are not just another feature. They have the potential to rethink the existing concept of mobile technologies and start a new era - Era after the applications of the post-app era.
Where to begin?
In order to show how easy it is to create your own bot based on IBM Bluemix, we suggest right now to develop a weather bot for Facebook messenger. We will learn right in the process of creating a bot.
So, our application-bot will be modular, and consist of four blocks-modules. The main module is Broker, it provides the interconnection of our bot with the Messaging Platform. In our example, the connection goes only with Facebook Messenger, but the spectrum of bot interaction with various platforms can be expanded.

The Weather App is a module that is responsible for interpreting the text request and formulating the response. The weather in our case is just an example. Information may be financial, related to shopping, products, etc.
The Weather App module is provided by the Bluemix cloud platform. This platform is a product of our company, it is clear. But we chose it not only because it was developed by IBM, but also because Bluemix does allow a lot to do. Here are the main advantages of the system:
The quality of interaction. Thanks to IBM Watson, Bluemix allows the developer to use the speech analysis tool and the formation of dialogues. Now these services are available in IBM Bluemix, so that they are available to all users of the platform without exception.
Independence from the messenger platform. If you select one of some kind of platform (the same Facebook) and create a bot based on it, the bot will be tightly tied to this platform. And Bluemix allows you to create an independent service that will not depend on the vagaries of the owners of the messenger platform.
Connectivity with other cloud platforms and services. Bluemix offers the opportunity to connect the bot with other cloud services - there would be a desire.
And now - we start developing
What is needed?• Bluemix account for the developer;
• Facebook account for bot;
Configuring Facebook Page and Application• From the page of the selected account, select in the menu “Create a New Page”;
• Select “Cause or Community”, enter the name and click “Get Started”;
• From your Facebook for Developers page, select My Apps / Create a New App and click on 'basic setup';
• Enter the required data and click "Create App ID";
With Facebook, for now, let's get down to setting up an account on Bluemix.• From the Bluemix panel, select 'Cloud Foundry App' -> 'Create App';
• Select “Web” -> 'SDK for Node.JS';
• Click "Continue" and enter the name of the application;
• Select “Download Starter Code” and specify the place to download;
• Open the app.js file and replace the default code
with this code from GitHub;
• Open the package.json file and under dependencies make the following changes:
“Body-parser”: “^ 1.15,0”,
“Express”: “^ 4.13.4”,
“Request”: “2.72.0”
• To start the Broker App to Bluemix, use the following command: 'cf push using manifest file path / manifest.yml, replacing “path” with the path to our file.
Connect the Facebook application to your Broker App:• On the Facebook Developer page under “Webhooks”, select New Subscription / Page;
• Under "'Callback URL" fill in the Broker App URL. You can find it immediately under the name of the application.

• Then in 'Verify Token' we fill the token specified in the Broker App (in our example, this is 'mySecretAccessToken');
• In 'Subscription Fields', select messages, message_deliveries, messaging_options and messaging_postbacks;
• To get a Facebook access token, click 'Messenger' and 'Get Started'. Select the page created earlier, “okay”, copy the generated Page Access Token;
• Now use Terminal and execute the following command: curl -ik -X POST “Facebook_access_token_goes_here”;
• Open app.js again and apply Facebook token var current;
• Launch the Broker App on Bluemix, as noted above.
Create a Weather App in Bluemix• In Bluemix, select AlchemyAPI, Insights for Weather, and Natural Language Classifier, which must be tied to our application;
• We have already taught the Watson Natural Language Classifier how to understand weather questions. He can distinguish the question of the weather itself from the simple question of temperature. Here it tells how to train your own classifier;
• After you have processed your own classifier, an id should appear;
• Now download the initial code for your Node.js application;
• Open the app.js file and replace the sample code with
this example from GitHub;
• Insert your id, got a couple of points above;
• Open package.json and make the following changes to dependencies:
"JSON": "^ 1.0.0",
"Body-parser": "^ 1.15.0",
"Cfenv": "^ 1.0.3",
"Express": "^ 4.13.4",
"Node-geocoder": "^ 3.9.1",
"Request": "^ 2.71.0",
"Watson-developer-cloud": "^ 1.4.1"Launch the Weather App on Bluemix
Connecting Broker App to Weather App
• Open the app.js application Broker;
• We are looking for the following code:
request (“
whatistheweather.mybluemix.net/getWeather?text= ” + text, function (error, response, body)
• Replace the URL on the URl of your Weather app;
• Launch the Weather App on Bluemix.
Earned? Fine. If you want more information on this topic, then pay attention: on June 23, a free online seminar on Bluemix will be held, at which our expert Timur Markunin will show how to create bots translators and answer the most pressing questions. You can register here .