Unfortunately, there is one difficulty with connecting with so many people across the world – time zones. You may want to be available to interact with your readership or to do business with potential clients, but at some point, you have to sleep.
Enter the chat bot. A chat bot can serve as your front desk digital secretary when you aren’t available to accept IM requests. The intelligence of this digital “secretary” really only comes down to how well you’re able to program the dialogue into your chat bot.
MUO has previously covered ChitterIM, which is essentially a chat bot that accepts IM commands from you in order to interact with Twitter. This is just one example of how a chat bot can automatically perform tasks for your site or your business, but in this article I’m going to show you the basic steps to make your own chat bot for your own site or business.
How to Make a Chat Bot
By far, the best available tool for doing this is IMified. We’ve briefly covered IMified in the directory, and Mark covered how to use the prebuilt IMified bot to use a whole list of premade applications that the folks at IMified already offer.
However, you can also create your own customized chat bot by signing up for a new account, and then clicking on the “Create a New Bot” button on the right menu.
Setting up your own customized chat bot is as simple as creating an ID for your bot, and defining the URL where your bot’s chat code will reside. In my case, I’m storing the PHP code for the bot programming on my own website, so I’ve provided the path to that PHP file.
When you’re done, you’ll receive a long “Bot Key” that you can use when you get more deeply into integrating your bot into various services, such as programming your own Twitter features. However, for now we’re going to focus on creating that basic PHP file where you can program your bot to interact with your users.
To show how this basically works, I’m going to explain how the basic PHP file offered by IMified works. Here’s what the basic interaction code looks like.
If you step through this sample code you’ll see just how simple it is. The IMified bot lets you take the conversation through several “steps”, and you can force navigation. You can allow the user to type something and continue to the next step by doing nothing and just ending that section with “break;”. If you end your echo with a “”, it’ll reset the bot (and the conversation) back to the start. Your bot will forget everything that was recently said.
IMified also lets you use a “goto” command to go to a specific step in the conversation, and will force the conversation one step back (I’ll show you how this works below).
But first, here’s what the bot conversation will look like. The bot is called “tswdesk”.
Of course, you’re going to want your chat bot to be a little more intelligent (and interesting) than this simple example. However, since you are controlling the conversation using PHP code, just think of the possibilities. Based on the conversation, you could perform different services for your readers or your clients. Send out an email, log “feedback” test to a file, or provide the user with requested information. The possibilities are really unlimited.
Here’s a sample PHP bot code where you can provide the visitor with the option to select from a menu of “services” that your bot offers.
Now that there’s a bit more logic and information in the background code, you can see how much more intelligent the bot will appear to users, as shown in the conversation below.
Now, carrying out some of these tasks may be as simple as writing to a logfile or sending out an email to the editor using PHP, but if you want to have your bot serve you by accepting Twitter commands or issuing alerts to all chat “friends”, it will require using some of the IMified APIs. That’s outside the scope of this article, but we’ll get to those cool features in an upcoming article.
Have you ever used IMified to customize your own bot, or have you used any other similar service? Share your chat bot experiences and insights in the comments section below.
0 comments:
Post a Comment