Automate the process of generating and publishing blog posts to Medium using LangChain, OpenAI, and the Medium API — all based on topics scheduled in a simple CSV file.
- Automated Posting — Publishes the blog scheduled for the current date.
- LangChain Integration — Uses
ChatOpenAIto generate human-like, high-quality content. - Image Upload Support — Optionally uploads an image to Medium and embeds it in the post.
- Customizable Prompt — Fine-tune how AI writes your company blogs.
- Logging — Tracks each execution in a log file (
log.txt).
|
├── main.py # Main automation script
├── blog.csv # CSV file containing topics and product links
├── 1log.txt # Log file with execution history
├── README.md # Documentation
└── requirements.txt
- Python 3.9+
- A valid OpenAI API Key
- A Medium Integration Token
→ Generate from your Medium account settings:
https://medium.com/me/settings
Clone the repository:
git clone https://github.com/monojitbgit/langchain-medium-publisher.gitNevigate to the directory
cd langchain-medium-publisher-mainInstall required dependencies:
pip install -r requirements.txtor run
pip install langchain-openai langchain-core requests opencv-pythonOpen medium_post.py and replace placeholders with your credentials:
os.environ["OPENAI_API_KEY"] = "your_openai_api_key_here"
MEDIUM_API_TOKEN = "your_medium_integration_token_here"
Execute the Python script:
python main.py
LangChain
OpenAI GPT Models
Medium API
Python Libraries: requests, csv, datetime, opencv-python
This project is licensed under the MIT License.
You’re free to use, modify, and distribute it with attribution.