Building a simple API bot in less than 5mins

Create Agent

Building a simple API bot in less than 5mins

With the launch of Google Home and Amazon Echo, voice applications are gaining popularity in the market. To adhere to the market trend, it is equally important to know how these voice assisted products can be tapped by the developers.



A conversation Action is simple to understand. A user talks to your actions and your actions will respond to that request. The above image shows the request/response interaction with a conversation API.

To Build a Conversation Action, we will be using API.AI – a platform that Google took over in September last year. Google has provided amazing content here along with design guides on how to create a great conversational experience. Alternatively, you can also use Actions SDK for building Conversation Actions.

This platform not only allows you to create your own actions but also allows you to integrate with several services like Slack, Facebook Messenger, Google Home and many more. In this example, we will show you how to integrate it with Facebook Messenger. Lets rock and roll to build Conversation Actions using API.AI.

Building our Action

Head to API.AI portal and click on Create Agent.

Create Agent


Next, fill out the form below. You can name the Agent (no whitespaces please) and give a description about the same. This platform also allows you to add sample data which you can select from the drop down menu. Leave the other options as is.



Once you create the agent, you will be taken to the Intent Page automatically. Here you will see two options:

  • The Default Welcome Intent: is called when the agent is involved on the device or application.
  • The Fallback Intent: is invoked when you have pushed a request that the Agent is unclear about.


Click on the Default Welcome Intent. On this page, you will see list of messages in the Response Section. Since you will not require them as of now, you may completely delete the list (Click on the bin button on the right hand side) and create a new one.


Click on Add Message Content. You can now add a welcome text response, just like the way shown below. This will help identify your agent to the user. You can add responses in several forms such as Text Response, Image, Card, Quick Replies and Custom Payload. We will currently use Text Response. Don’t forget to click on Save ( Top right corner) after these changes are done.



Next, click on “+” icon next to Intents in the left pane. It will open up the screen as shown below:



Our goal is to define a new Intent that will process information that is requested by the user. Say for example, “Do you deliver in Goa?”. We will now design a conversation dialog to ask the location name that the user wants the information for.  In the User Says field, type out the conversations you would like your Agent to process. Take a look below at my example:



Once you are done, you will realize that the form has automatically parsed out the sentence and parameterized your request text. Using the in-built entities that API.AI provides, the form was able to map a city name to sys.geo-city. The VALUE column shows $geo-city indicating a way, how you can access the value of the city.



At this moment, it is important to specify the mandatory piece of information that you expect from the user. If for some reason, user does not provide the information, the agent will continue to prompt for the required information, until it can process.




You can now add a New Parameter, Pincode. Simply add them after the geo-city parameter. From the list of entities, after pressing “@”, select sys.number.



Finally, we need to provide a Response if the request information is passed correctly. Save the form when done.




So we are done with main steps. You can now test the agent in the panel in the right side.
No Comments

Post a Comment