From 210aba3e44e276889c31d73441ea3571ea8cb707 Mon Sep 17 00:00:00 2001 From: davodm Date: Tue, 10 Oct 2023 16:10:47 +0100 Subject: [PATCH] doc: README updated --- README.md | 54 +++++++++++++++++++++++++++++++++--------------------- 1 file changed, 33 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index f39db40..40b1cff 100644 --- a/README.md +++ b/README.md @@ -1,27 +1,23 @@ -# IranCrypto Market Twitter Bot +# IranCrypto Market Social Media Bot -This project consists of a Node.js based AWS Lambda function and CLI helper tool to automatically tweet daily crypto market updates for Iran using data from the IranCrypto API. - -The Lambda function fetches the most popular cryptocurrencies each day using the IranCrypto market data API. It then uses this data to generate an insightful tweet thread discussing the top performing cryptos and their volume/price changes. - -The tweet content itself is generated using ChatGPT to create relevant messages in English based on the latest market data. These messages are then populated with actual values and posted via the Twitter API using credentials obtained with the CLI helper. +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 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. ### Features -* Fetches daily ranking of top cryptos from IranCrypto API -* Uses ChatGPT to create engaging English language tweets -* Populates tweet templates with real values and posts to Twitter -* Runs daily via AWS Lambda on a cron schedule -* CLI tool to authenticate and obtain Twitter API credentials -* Serverless architecture using AWS Lambda for maintenance-free execution +* **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](https://www.npmjs.com/package/node-html-to-image), based on templates created for the project. +* **Twitter Integration:** Posts generated content on Twitter using the [Twitter API V2](https://www.npmjs.com/package/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](https://www.npmjs.com/package/instagram-private-api). +* **Serverless Execution:** Runs daily via AWS Lambda on a cron schedule, ensuring maintenance-free execution and scalability. ## Setup & Usage -Twitter access token it's not a straight forward way, So you need: +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. -1. Setup your developer portal -2. Setup a new application -3. Setup an user authentication setup for your project (Callback URL could be anything, we just need to copy it after redirection) +1. **Developer Portal Setup:** Begin by setting up your developer portal on Twitter. +2. **Application Creation:** Create a new application within your developer portal. +3. **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) +4. **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. -4. Then it's time to set your enviornment variables: ```sh OPENAI_MODEL=gpt-3.5-turbo OPENAI_API_KEY= @@ -36,9 +32,14 @@ TWITTER_CLIENT_ID= TWITTER_CLIENT_SECRET= TWITTER_CALLBACK_URL=https://randomurl/twitterbot/ //Should be the same with your Twitter app config + +IG_USERNAME= +IG_PASSWORD= +IG_PROXY= ``` -5. In order to authenticate and configure Twitter credentials, use the helper cli tool: +5. **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. + ```sh $ npm run twitter-auth > Save Code verifierer below -> @@ -52,12 +53,16 @@ Go to this link to auth your account -> After all answer the prompts! ``` -6. After that you will see the access & refresh tokens in the console which should be copied in your enviornment variables. - -The rest will be managed by Dynamo DB to store your tokens each time it's get refreshed. +6. **Token Storage:** The project uses DynamoDB to store and manage your Twitter tokens, ensuring that they are refreshed as needed. Read more [technical details](https://github.com/PLhery/node-twitter-api-v2/blob/712ca82293c1b587638055537969dbec5a7bce40/doc/auth.md#user-wide-authentication-flow) on the Twitter authentication flow used. +7. **Instagram Checkpoint Bypass:** In case of Instagram blockage, you can use the CLI tool to bypass the checkpoint. + +```sh +$ npm run instagram-auth +``` + ## Installation 1. Clone Repo 2. Run `npm install` @@ -66,6 +71,13 @@ Read more [technical details](https://github.com/PLhery/node-twitter-api-v2/blob Whole serverless configuration will create DynamoDB table, attach the needed permissions and set the cronjob. +### 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. + +You can change cronjob settings from serverless.yml file. + ## Contributing Pull requests are welcome! Feel free to open issues for any improvements or bugs.