Let's build a chatbot together, introduction to bots

in #technology7 years ago (edited)

image.png

So because many of my posts are going to be about Artifical Intelligence and I thought it would be a good idea to create a tutorial that shows you how to build one of the most talked about trends from 2017, the chatbot.

This tutorial will be aimed at beginners with no coding experience who wish to learn how to create a chatbot for their company, blog or personal website. The subject matter for this tutorial will be taken from some steemit faq.

If you don't know already a chatbot is a computer program designed to simulate a conversation with human users, this means that a human is able to talk to a computer like a human and the computer will respond in a similar manner. Now by the end of the tutorial, we will only have the beginning of a chatbot, but you should have the knowledge and tools to take this further. If this post is a success I will write further tutorials on how to improve it into a deployable service.

Firstly in order to create this chatbot, we will need to use a chatbot provider, after all, I did say that we wouldn't need to write any code. For this tutorial we will be using dialogflow (https://dialogflow.com/) for anyone who doesn't know what dialogflow is here a short introduction:

Dialogflow (formerly Api.ai, Speaktoit) is a developer of human-computer interaction technologies based on natural language conversations. The company is best known for creating the Assistant (by Speaktoit), a virtual buddy for Android, iOS, and Windows Phone smartphones that perform tasks and answers users' question in a natural language. Speaktoit has also created a natural language processing engine that incorporates conversation context like dialogue history, location, and user preferences. Source: Wikipedia (https://en.wikipedia.org/wiki/Dialogflow)

Essentially they will provide us with the tools we need, I will teach you how to use them. It's important to note I am no way affiliated with them, actually, I work for a company in this space who offers tools similar to this but due to dialogflow' slick and easy to use UI I thought I would use them for the tutorial.

Step 1: Let's sign up for https://dialogflow.com/

First of all your going to need an account, so let's go to https://dialogflow.com/ and click on sign up for free. Oh yeah, I forgot to mention this is totally free :)

image.png

Once clicked, you will be asked to sign in with your Google account if you don't have one of these you can sign up by clicking more options and then create an account on the sign in page. Follow the sign-up options and there you have it you're ready to begin building your bot.

Step 2: Creating your agent

So now you're signed in your screen should look something like this:

image.png

The first thing we want to do is to create an agent, this is where we'll teach the bot everything it needs to know. Click on create an agent to get started, you will be presented with a list of options. The only thing you need to enter for this demo is the agent name, you can leave the rest of the options set to default. We're going to call our bot:

myFirstSteemItBot

When you're done, click save and we're ready to start teaching our chatbot all about steemit.

Step 3: Understanding Intents

After you've created your agent you will be navigated to the following page:

image.png

As you can see the page is broken down into three main areas, the left which holds the navigation and what we'll use to navigate between the various different features dialogflow has to offer, the centre that contains your main working area and on the right you have the ability to test your bot (we'll come back to this later). The first page that you'll be taken to is the intents page, this is where we'll teach the chatbot how it should respond to a users input. As you can see on this page, dialog flow has given you a selection of pre-made intents. These include:

  1. Default Fallback Intent
  2. Default Welcome Intent

The default fallback intent is used as a catch-all to everything that the chatbot hasn't been trained to understand, we'll come back to this later but first, let's take a look at the default welcome intent. Click on the default welcome intent and you'll be taken this page:

image.png

This intent has been created by dialogflow to help you get started and is used to welcome new users to your chatbot before it's ready to use we will need to changes to it. So let's take a look:

Below you can see user says section, this represents where you should configure what your users might say to trigger this intent.

image.png

For example in this scenario we can add the following:

Hi
Hello
Howdy

It should look like this:

image.png

What we've basically done is tell the bot that when a user says Hi, Hello or Howdy it should respond based on the information we enter within this intent. So we've figured out when a user says Hi, Hello or Howdy the bot is going to reply, but how is it going to reply you ask. Let's get that sorted out.

On the intents page, you will be able to see a section called "Response" it will look like this:

image.png

As you can see it has already been configured with a selection of different response the bot might say in response to Hi, Hello & Howdy. Let's delete all of those by clicking the trash icon located on the right of the header and create our own, personalized response.

So once you have deleted all of the pre-built response we want to add our own you can do this by clicking on the add content button and click text response:

image.png

This will configure a new response for the bot, let's enter

Hello, I'm the new Steemit bot. How can I help you?

Now we've entered a response we need to save our intent you can do this by clicking save at the top of the page, once you've pressed save it will tell you that your intent has been saved and then that training has begun.

image.png

This should only take a couple of seconds to complete and you should see it change to training complete.

image.png

So now the chatbot has been trained we can test it out, you can do this within the test experience area located on the right-hand side of the page.

Where it says try it now you can enter the text you wish to test your bot out with. Let's enter the following and hit enter/return.

Hello

You will see the following results displayed:

image.png

This means that the system will return that response in relation to the input you entered. As you can see this is what we entered earlier, but let's ask it something else.

What is steemit?

image.png

As you can see the bot returned "Sorry, can you say that again?" yours may say one of the following:

image.png

This is because the bot wasn't able to match "What is steemit?" with anything trained within our intents and instead displayed the fallback intent that we saw earlier in the pre-built intents. You can edit these fallback responses by clicking on intents located on the left-hand side and then selecting the fallback intent similarly to how we did before. For now, I won't be making any changes to these, but you can if you'd prefer to personalize them.

So great, now we have the first part of our chatbot. We've got it working and have an introduction. Let's add some information about steemit next.

4: Let's teach the chatbot

Firstly we're going to need some information for our chatbot, to begin with, I'm going to take information from the steemit FAQ in order to teach the chat the bot all about steemit, you can find the link to that below.

https://steemit.com/faq.html - Thanks @steemit

When you enter the page mentioned above you can see that there is a list of frequently asked questions about steemit, perfect training material for our chatbot.

In order to create a new intent, you should first click on "create intent" which is located at the top of the intents page, when pressed you'll be taken to the intents page that we saw earlier. I will walk you through the first one and from there you should be good to go.

Let's look at the question "What is Steemit.com?" on the faq, on the intents page enter "What is Steemit.com?" into the user says section, like before this will indicate that this intent should be triggered when a user says "What is Steemit.com?", but wait a minute this also answers the question we entered earlier that the chatbot didn't recognize for "What is Steemit?", let's add that too. Essentially, within user says we should try to replicate all of the different ways a user may ask a question so that our chatbot is able to understand a user a user in a variety of different ways. I have entered a few different variations.

image.png

After we've completed user says, we should move on to respond, here we want to take the answer from the faq and copy and paste it in.

Steemit is a social network and content rewards platform that makes the crowd the beneficiaries of the attention economy. It does this be rewarding users with STEEM. Steemit has redefined social media by building a living, breathing, and growing social economy; a community where users are getting rewarded for sharing their voice.

It should look like this:

image.png

Now for this but we don't need to worry about any of the other sections on this page, so we're ready to hit save and it will go into training. Once it has been trained you'll be able to test out the experience similar to how we did before.

image.png

I have repeated this process for the following questions within the faq, but I'll leave those up to you to fill in :)

  1. How does Steemit work?
  2. How does Steemit differ from other social media websites?
  3. Does it cost anything to post, comment, or vote?
  4. Can I earn digital tokens on Steemit? How?
  5. Where do the tokens come from?
  6. Where does the value come from?
  7. Why are people getting vastly different rewards?

When you're done your intents page should look similar to this:

image.png

4: Let's see it have a conversation

So great, we've trained our chatbot with information about steemit, but how do we test this in an actual conversation. To do this we want to click on "Integrations" located on the left-hand menu.

image.png

When you've reached this page you want to select "Web Demo" when will be presented with a page that will look like this:

image.png

Click enable by clicking on the toggle located at the top right of the pop-up. When you've done that you'll be presented with this.

image.png

Copy and paste the URL into your browser and it will launch your demo, mine is: https://bot.dialogflow.com/375e47e3-9597-49d1-b860-fb02ac5e2727

Once launched you can ask all of the intents you've trained it against earlier, take a look at mine below.
image.png

There you have it, you have the beginning of a working chatbot that is able to answer questions and answers about steemit.

5: What we built

Now it's important to remember that anyone who uses the test link this is the very beginning of a chatbot and isn't trained to a production-ready standard, that requires hours of user testing along with subject matter experts and previous user conversations, you'll likely find that it breaks more than it works due to low amounts of training data that I've included. This instead was supposed to show that it's easy to build a chatbot yourself, all you needed was me to give you the knowledge to do it :)

6: What I didn't mention...

Now I realize that I didn't mention a barrage of different things that are included within the dialogflow platform and there's a reason for that, I simply didn't want to confuse you with all of the different things that are there all at once and of course I need some content for future posts too ;)

Want proof I created it?

Ask the chatbot "Who created you?" :)

Need help?

If you need help, don't worry just ask in the comments and I'd be happy to help you out :)

What's next?

If you liked this tutorial this is only the start of what I can teach you, I just thought this would be a good introduction. If you would like more see more tutorials please let me know me in the comments :)

Sort:  

Nice start! but not really a "Steemit" bot. Seems more like a hardcode bot. Why? because it is closed to certain actions and it is not currently parsing data from the Steem blockchain. For example, if I ask current price of the token or something about an user in the blockchain, the bot should not be able to tell this information. However, it can be done by implementing a server side to parse this kind of information and maybe a neural network to make the bot learning about its users. So, it can sounds more natural and can learn over the time.

You have a good point, the title could be slightly misleading due to you being able to build bots on top of the blockchain, I will make an adjustment to the title.

You're right though, this bot could be easily adjusted to understand those question those questions related to users or the prices of steem through integrating with the steem API/a currency API (I haven't looked at docs but assume it's all available due to the apps being built on it). I only really wanted to give an introduction to bots in this post because as soon as you start mentioning code some users will lose interest and thought it would still be useful. My hope is that I can do more and more and show people how to build more advanced bots :)

As I said, nice start man! I got your point and your intentions are really good! keep it up! Also, why should users be scared about code? 🙃 I will be following up your steemit chat bot :) So, for the next one include a unique tag so I can easily follow it :)

great information your writing style is very unic wish you best of luck keep this type posting becuse we waiting for your post @Resteemed

You got a 0.28% upvote from @upme requested by: @tobias-g.
Send at least 1.5 SBD to @upme with a post link in the memo field to receive upvote next round.
To support our activity, please vote for my master @suggeelson, as a STEEM Witness

Your post has been Resteemed @tobias-g I offer free resteem for all

This post has received a 9.65 % upvote from thanks to: @tobias-g.
For more information, click here!!!!
Send minimum 0.100 SBD to bid for votes.

Before sending a transfer to @minnowhelper, verify that your publication meets these conditions (http://www.minnowhelper.com/conditions.php). After the transfer is made, no claims will be received.


The Minnowhelper team is still looking for investors (Minimum 10 SP), if you are interested in this, read the conditions of how to invest click here!!!
ROI Calculator for Investors click here!!!

splended.

This post has received a 27.03 % upvote from @sleeplesswhale thanks to: @tobias-g.

Coin Marketplace

STEEM 0.26
TRX 0.20
JST 0.038
BTC 94927.30
ETH 3526.90
USDT 1.00
SBD 3.83