Skip to content
Elizabeth Perreau edited this page Jun 25, 2016 · 6 revisions

#Steps To Set Up Your TwitterBot

Set up your chatbot

  1. Set up Program O on your server
  2. Make sure that you have followed the instructions here: https://github.com/Program-O/Program-O/wiki/Installation-Guide

Set up your Twitter account

  1. Create a Twitter account for your chatbot at http://twitter.com
  2. Sign into your new chatbot Twitter account and follow the Twitter instructions to set up your account
  3. Set your profile, add a picture etc etc.

Set up your Twitter application settings

  1. Goto https://apps.twitter.com/
  2. Click "Create New App"
  3. Follow the screenshots below to create your Twitter keys;

A. Check your app settings

Step 1

B. Callback and login permissions are NOT required

Step 2 Note: You do not need a callback or login permissions

C. Create the access tokens

Step 3 note: Press 'create access tokens' to generate your tokens

D. Check the access level

Step 4 note: Make sure the access level is set to read/write

E. Set access level to read/write

Step 5 note: Change the level if needed to read/write

4.Make a note of ...

  • Consumer key
  • Consumer secret
  • Access token
  • Access token secret

Set up your Twitterbot config in Program O

  1. Open /gui/twitter/tweet.php

  2. Locate 'EDIT YOUR CHAT BOT PARAMS'

  3. $chatbot_endpoint - Enter the url to your chatbot conversation endpoint - this is normally http://<yoursite.com>/chatbot/conversation_start.php

  4. $bot_id - Enter your chatbot bot_id - this is the bot_id from the bots table

  5. Locate 'EDIT THE AGE LIMIT OF TWEETS TO REPLY TO (minutes)'

  6. $age_of_tweets_in_minutes - add the number of minutes to check for new tweets. e.g. if you enter 5 when your twitterbot runs it will respond to tweets which are no older than 5 minutes old.

  7. Locate 'EDIT TWITTER OAUTH PARAMS'

  8. Enter the keys you created on apps.twitter.com

Set up a cron job on your server

  1. You will need to set up a cron task to run tweet.php every 5 minutes - instructions here: http://askubuntu.com/questions/2368/how-do-i-set-up-a-cron-job
  2. Your cron job will look something like this php -q /home/yoursite/public_html/yourbot/gui/twitter/tweet.php

Operation

The script will run every 5 mins and look for new @mentions created in the last $age_of_tweets_in_minutes on twitter and reply to them.

Test

If you have set up your Twitterbot correctly you can test it by

Important

If you change the cron occurrence entry in the cron table you will have alter the cron_every_x_minutes value below, so that the minutes are the same.