The IranCrypto Market Social Media Bot is a powerful project that leverages Node.js and AWS Lambda to automate the generation of daily/weekly crypto market updates on social media platforms, including Twitter, Telegram and Instagram. It utilizes the IranCrypto API to fetch data on the most popular cryptocurrencies and then generates insightful content, complete with engaging English-language tweets and Instagram posts.
- Crypto Market Data: Fetches daily and weekly rankings of top cryptocurrencies from the IranCryptoMarket API.
- Engaging Content Generation: Uses ChatGPT to create compelling English-language tweets that discuss the performance, volume, and price changes of the top cryptocurrencies.
- Instagram Image Creation: Generates images for Instagram posts using Node HTML to image, based on templates created for the project.
- Twitter Integration: Posts generated content on Twitter using the Twitter API V2, with credentials obtained using a CLI tool.
- Instagram Posting: Shares the generated images as both posts and stories on Instagram, utilizing the Instagram private API.
- Telegram Posting: Shares the generated images on Telegram channel, utilizing the Node.JS Telegram Bot API.
- Serverless Execution: Runs daily via AWS Lambda on a cron schedule, ensuring maintenance-free execution and scalability.
Twitter access token it's not a straight forward way, But for the rest of the modules, you just need to use the credientials on .env file.
- Developer Portal Setup: Begin by setting up your developer portal on Twitter.
- Application Creation: Create a new application within your developer portal.
- User Authentication Setup: Set up user authentication for your project, including specifying a callback URL. (Callback URL could be anything, we just need to copy it after redirection)
- Environment Variables: Configure your environment variables by adding them to the .env file. These variables include API keys, access tokens, and credentials for Twitter and Instagram.
OPENAI_MODEL=gpt-3.5-turbo
OPENAI_API_KEY=<Your API Key>
OPENAI_ORGANIZATION=<Your Organization API Key>
DYNAMODB_TABLE=<Your Dynamo DB table name>
IRANCRYPTO_API_KEY=<Your API Key on IranCrypto>
TWITTER_ACCESS_TOKEN=<Your twitter access token that you wont have it first>
TWITTER_REFRESH_TOKEN=<Your twitter refresh token that you wont have it first>
TWITTER_CLIENT_ID=<Your Twitter application client ID>
TWITTER_CLIENT_SECRET=<Your Twitter application client Secret>
TWITTER_CALLBACK_URL=https://randomurl/twitterbot/ //Should be the same with your Twitter app config
IG_USERNAME=<Your Instagram username>
IG_PASSWORD=<Your Instagram password>
IG_PROXY=<Your server proxy to use Instagram>
IG_PRELOGIN=false //If you want to use prelogin simulation, set it to true
IG_STORE_SESSION=true //If you want to store session on DynamoDB, set it to true
TELEGRAM_CHANNEL_ID=<Your Telegram channel ID in number>
TELEGRAM_BOT_TOKEN=<Your Telegram bot token>
- Twitter Authentication: Use the provided CLI tool to authenticate and configure Twitter credentials. This tool will guide you through the authentication process and generate access and refresh tokens.
$ npm run twitter-auth
> Save Code verifierer below ->
<....>
Go to this link to auth your account ->
<https://twitter.com/i/oauth2/authorize?>
After all answer the prompts!
- Token Storage: The project uses DynamoDB to store and manage your Twitter tokens, ensuring that they are refreshed as needed.
Read more technical details on the Twitter authentication flow used.
- Instagram Checkpoint Bypass: In case of Instagram blockage, you can use the CLI tool to bypass the checkpoint.
$ npm run instagram-auth
- Telegram Channel ID: You can use JSONDump Bot by forwarding a post from your channel to the bot to identify the channel id.
## Installation
1. Clone Repo
2. Run `npm install`
3. Create .env file and fill out the values as explained
4. Deploy lambda function through [serverless](https://www.serverless.com/framework/docs/providers/aws/guide/deploying): `npm run deploy`
Whole serverless configuration will create DynamoDB table, attach the needed permissions and set the cronjob.
## Functionality
- Twitter: Share two daily tweets about total market transactions and top 3 cryptocurrencies.
- Instagram: Share a weekly post about 10 most traded cryptocurrencies.
- Telegram: Share a daily post about 10 most traded cryptocurrencies.
### Cronjob
Cronjob is set to run specificly for each controller:
- Twitter: Every day at 8:00 & 9:00 PM.
- Instagram: Every Friday at 8:00 PM.
- Telegram: Every day at 9:01 PM.
You can change cronjob settings from serverless.yml file.
## Contributing
Pull requests are welcome! Feel free to open issues for any improvements or bugs.
## License
This project is open source and available under the [MIT License](https://opensource.org/licenses/MIT).