Build Chatbot Interactions: Responsive, Intuitive Interfaces with Ruby

Build Chatbot Interactions: Responsive, Intuitive Interfaces with Ruby

by Daniel Pritchett


View All Available Formats & Editions
Choose Expedited Shipping at checkout for guaranteed delivery by Monday, April 13


The next step in the evolution of user interfaces is here. Chatbots let your users interact with your service in their own natural language. Use free and open source tools along with Ruby to build creative, useful, and unexpected interactions for users. Take advantage of the Lita framework's step-by-step implementation strategy to simplify bot development and testing. From novices to experts, chatbots are an area in which everyone can participate. Exercise your creativity by creating chatbot skills for communicating, information, and fun.

Developers of all skill levels can craft user experiences that are natural, easy to use, and most of all, fun. Build chatbots using free, open source tools and launch them to popular chat platforms like Slack and Amazon's Alexa. Use the Ruby programming language and the Lita bot framework to unlock fun and powerful chat abilities such as sending text messages and emails, creating new meme images, driving a robot around the room, and talking out loud on a home speaker.

Use frameworks available in Ruby and Node.js to get started quickly. Create simple chatbot skills that respond quickly to basic requests. Chain skills together for more complex interactions. Take advantage of test-driven development techniques to build your bots with confidence. Coordinate tasks with colleagues via bot. Connect with external APIs to provide users with data they need. Extract data information from web pages when an API isn't available. Expand your bot's reach with SMS and e-mail messaging. Deploy a chatbot to a host so users can interact with it on their schedule.

Build a more responsive, easy-to-use interface for your users today.

What You Need:

You don't need much to get started with chatbots. A Mac or Linux computer with a recent version of Ruby is recommended. Windows users can keep up with a free virtual machine running Linux. You'll deploy your chatbots for free (or at least cheaply) on cloud hosting platforms like Heroku and Digital Ocean.

Product Details

ISBN-13: 9781680506327
Publisher: Pragmatic Programmers, LLC, The
Publication date: 06/23/2019
Pages: 208
Sales rank: 1,148,377
Product dimensions: 7.40(w) x 9.20(h) x 0.60(d)

About the Author

Daniel Pritchett is a consulting programmer, speaker, and user group supporter in Memphis, Tennessee. He builds infrastructure tooling for internet companies. If it's interesting and useful, Daniel wants to help you build it.

Table of Contents

Preface ix

1 Your First Lita Bot 1

Install Ruby 2

Install Shared Libraries and Redis 2

Use Redis as Lita's "Brain" 3

Install the Lita Gem 4

Generate a New Lita Bot 5

Test the Bot Locally 6

Wrap-up 7

2 Your First Lita Skill 9

Generate an Empty Skill 9

Complete Your Skill and Write Some Unit Tests 13

Publish Your Skill for Others as a Ruby Gem 15

Wrap-up 19

3 Deploy Your Lita Bot to Heroku 21

Prepare a Heroku Home for Your Bot 22

Add-ons and Heroku's Elements Marketplace 28

Wrap-up 33

4 Deploy Lita on Your Linux Server 35

Create a Cloud Virtual Machine 36

Review and Run the Bootstrap Script 37

Review Your Dockerized Bot through SSH 42

Wrap-up 42

5 Parse a Photoblog: What's Brad Eating? 45

Build a Web Page Scraper Skill 46

Set Up a Matcher 47

Download the Raw HTML with Tumblr 49

Parse the Raw HTML with Nokogiri 51

Isolate the First Post with a CSS Selector 52

Find the Image with Another CSS Selector 53

Format the Results to Share with the End User 54

Wrap-up 55

6 Meetup Finder 57

Set Up a Account and API Key 58

Connect to the Meetup API Using the Meetup Client Gem 58

Teach Lita How to Query the Meetup API 59

Test Your MeetupFinder Class 64

Model the API Response with a Plain Old Ruby Object 67

Wrap-up 70

7 Imgflip Meme Maker 71

Make an Image Macro 72

Teach Lita How to Generate Memes 75

Expand the Skill to Support More than One Meme 79

Enable Users to Add Memes to Your Gem 81

Wrap-up 86

8 Bot Task Scheduler 89

Capture a Lita Command to Reuse Later 89

Resubmit a Deferred Lita Command 93

Store Scheduled Tasks in Redis 94

Wrap-up 98

9 Hide Walls of Text Behind an Offsite URL 99

Create a Lita Extension to Send Text to the Pastebin API 100

Make a Simple Lita Handler Skill to Use as a Test Driver 103

Wrap-up 106

10 Use a Markov Chain or Cleverbot 109

Markov Chain: Train Lita to Speak in Someone Else's Voice 109

Cleverbot: Use an External AI for Difficult Questions 115

Wrap-up 119

11 Send Messages with SMS and Email 121

Use Twilio to Send Text Messages 121

Use SMTP to Send an Email 127

Wrap-up 132

12 ChatOps Techniques for Managing Software Systems 135

Create a Mini-skill to Check Installed Version 136

Test the Command Executor 139

Ask Lita to Ship a New Software Release 139

Wrap-up 142

13 Amazon Alexa Integrations 143

Hardware, Simulators, and Alexa Portal Access 143

Register for an Alexa Developer Account 144

Create Your First Skill on the Portal 145

Serve Up a "Flash Briefing" Newsfeed for Echo Devices 146

Record Messages with a Companion Alexa Skill 153

Build Out a Lita Skill to Take in Messages from Alexa 158

Wrap-up 162

14 Hue Programmable Lighting 165

Connect a Hue Bridge to Your Computer 166

Build a Simple Wrapper for Managing a Bulb 170

Control Your Bulbs from Lita 175

Wrap-up 179

Index 181

Customer Reviews