Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Hands-On Chatbots and Conversational UI Development

You're reading from   Hands-On Chatbots and Conversational UI Development Build chatbots and voice user interfaces with Chatfuel, Dialogflow, Microsoft Bot Framework, Twilio, and Alexa Skills

Arrow left icon
Product type Paperback
Published in Dec 2017
Publisher Packt
ISBN-13 9781788294669
Length 392 pages
Edition 1st Edition
Languages
Concepts
Arrow right icon
Author (1):
Arrow left icon
Srini Janarthanam Srini Janarthanam
Author Profile Icon Srini Janarthanam
Srini Janarthanam
Arrow right icon
View More author details
Toc

Table of Contents (11) Chapters Close

Preface 1. Introduction FREE CHAPTER 2. Tour Guide for Your City 3. Let's Talk Weather 4. Building a Persona Bot 5. Let's Catch a Train 6. Restaurant Search 7. The News Bot 8. My TV Guide 9. My Man Friday 10. More Resources

Building a Twitter news bot

Now that we have explored NewsAPI, a data source for the latest news updates, and a little bit of what the Twitter API can do, let us combine them both to build a bot tweeting interesting news stories, first on its own timeline and then specifically to each of its followers:

  1. Let's build a news tweeter module that tweets the top news article given the source. The following code uses the tweet() function we built earlier:
topNewsTweeter('cnn', null);

function topNewsTweeter(newsSource, screen_name, status_id){
request({
url: 'https://newsapi.org/v1/articles?source='
+ newsSource +
'&apiKey=YOUR_API_KEY',
method: 'GET'
},
function (error, response, body) {
//response is from the bot
if (!error && response...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image