This website and apps are for sale. Only serious offers will be considered. Contact [email protected]

Bot Libre Forum

Introducing Timers - Automate the Web and Social Media

通过 admin 发布 May 13 2017, 15:06

Bot Libre now supports timers. Timers let your bot perform automated tasks on a scheduled basis. You can use timers to have your bot followup with users on Facebook and social media on a daily or scheduled basis, create mailing lists, generate daily reports, and automate web scraping or other tasks.

To access your bot's timers go to its Timers page in its Admin Console. The timers page lets you enter a list of command messages that will be sent to your bot on a scheduled basis. You can enter the duration in hours to how frequently you want your background tasks to be run. To run more frequently than 1 per hour, you can enter -1 in the Timer Interval field.

A timer is a command message sent to your bot. Each timer message you enter will be sent to your bot each timer interval. A timer is normally implemented as a Self script.

In your timer script you need a state that has a pattern that matches your command, and a function that performs your desired function. You can browse the Bot Libre script library for timer examples and templates.

Self is Bot Libre's JavaScript dialect that is integrated with your bot's database, and has several built in classes for accessing social media, and web services. The Facebook, Twitter, Telegram, Twilio, and Email classes can be used to send messages on social media, and the Http class can be used to access web services and scrape HTML web pages.

Timers commands are always sent from the bot's #self user. This allows your script to check the input's

Example Timer Script

This example timer script checks for new blog posts and sends them to a mailing list.

/** * This script lets users register for a mailing list and uses a timer function to send email notifications of new blog posts. * To use this script you must connect your bot to email, and set your timer message to "send-email". */ state EmailList { pattern "[subscribe join]" template subscribe(); pattern "[remove stop unsubscribe]" template unsubscribe(); pattern "send-email" template sendEmail(); function subscribe() { if (conversation.type != #email) { return "You must subscribe through email."; } #mailingList.subscriber =+ conversation.speaker.name; return "You have been subscribed to our mailing list, please email 'remove' to unsubscribe."; } function unsubscribe() { if (conversation.type != #email) { return "You must unsubscribe through email."; } #mailingList.subscriber =- conversation.speaker.name; return "You have been unsubscribe from our mailing list, please email 'subscribe' to resubscribe."; } function sendEmail() { if (speaker != #self) { return "Must execute through a timer."; } var rss = Http.rss("http://botlibre.blogspot.com/feeds/posts/default"); if (#mailingList.last == rss.link) { return "No new posts"; } #mailingList.last = rss.link; var count = 0; for (subscriber in #mailingList.subscriber) { Email.email(subscriber, "New post: " + rss.title, "New post: <a href='" + rss.link + "'>" + rss.title + "</a> <br/><br/>" + rss.content); count++; } return "New post '" + rss.topic + "' sent to " + count + " subscribers"; } }

The possibilities of what you can implement with timers is endless, but it does require scripting. If you would like a bot that automates any task and need help with the implementation, please contact [email protected] and let us develop your automation solution for you.


Id: 17076300
标签: how to, scripting, self, timers
发布: May 13 2017, 15:06
更新: May 19 2017, 7:27
答复: 0
的风景: 8738, 今天: 3, 周: 13, 一个月: 11
0 0 0.0/5