Twitter bot based on Lambda
In this builders session, you will build a serverless twitter bot. There are 2 kind of bots you could build depending on your choice:
- A simple retweet bot which will look for terms you are interested in and will retweet it automatically.
- A bot which will update image sent to you based on specific keyword you define
Some of the features that you would be building today are:
- Store your twitter credentials in SSM for reuse
- Trigger event regurlarly to gather tweets
- Retweet automatically
- Store messages in a queue for processing
This workshop requires:
- An active AWS Account with administrative permissions.
- A Cloud9 environment is recommended, but, if you are using your own laptop, you should have AWS-CLI and git installed.
- Knowledge of Python will be an added advantage.
- Knowledge of AWS Lambda, Amazon SQS will be an added advantage.
- An active twitter account
Developer twitter account - get started
- To enable your account, you need a valid phone number (verified through a text message with verification code)
- Fill the Account details (personal use, country of operation)
- Fill the use case details (categories, description with 300 characters minimum)
- Sample:
1. I am using twitter API to look for tweets related to technological topics or images
2. I plan to analyze tweets to be able to thank automatically people and also to detect trends in the images, text provided.
3. I will be tweeting content when a given content is interesting.
4. Tweets will be displayed on my timeline.
- Finalize your activation
- Read the terms of service and accept
- New verification is sent to your email to confirm the developer account
- Click on create application
- Fill the information to give a name and small description (10 words)
Interact with AWS environments and twitter through Python:
- SAM CLI: https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-quick-start.html
- To upgrade to last version of AWS CLI:
pip install awscli --upgrade --user
- To upgrade to last version of SAM CLI:
pip install aws-sam-cli --user
- Define the bot you want to do (the simple is Bot 1)
- Manage your Twitter credentials in AWS for use in lambdas
- Setting up AWS Cloud 9 Development Environment
- Bot 1
- Bot 2