How I Automate My Freelance Workflow with Python
As a freelancer, managing multiple projects and clients can be overwhelming. However, by leveraging the power of Python, I've been able to automate many tasks, freeing up more time to focus on high-priority work and increasing my earning potential. In this article, I'll share my workflow automation strategy, providing you with practical steps and code examples to help you do the same.
Step 1: Project Management with Trello and Python
To start automating my workflow, I use Trello to manage my projects and tasks. I've created a Python script that interacts with the Trello API to automate tasks such as:
- Creating new boards and lists for each project
- Adding new cards for tasks and due dates
- Moving cards across lists as tasks progress
- Assigning labels and priorities
Here's an example code snippet using the requests library to create a new Trello board:
import requests
# Trello API credentials
api_key = "your_api_key"
api_token = "your_api_token"
# Create a new board
board_name = "New Project Board"
url = f"https://api.trello.com/1/boards/?key={api_key}&token={api_token}&name={board_name}"
response = requests.post(url)
# Check if the board was created successfully
if response.status_code == 200:
print(f"Board '{board_name}' created successfully")
else:
print(f"Error creating board: {response.text}")
Step 2: Invoicing and Payment Tracking with Python
Next, I use Python to automate my invoicing and payment tracking process. I've created a script that:
- Generates invoices based on project milestones and hours worked
- Sends invoices to clients via email
- Tracks payments and updates the project status accordingly
Here's an example code snippet using the pdfkit library to generate an invoice:
import pdfkit
from datetime import datetime
# Invoice data
client_name = "John Doe"
project_name = "New Website"
hours_worked = 10
hourly_rate = 50
# Create an invoice template
template = f"""
<html>
<body>
<h1>Invoice for {project_name}</h1>
<p>Client: {client_name}</p>
<p>Hours worked: {hours_worked}</p>
<p>Hourly rate: ${hourly_rate}</p>
<p>Total: ${hours_worked * hourly_rate}</p>
<p>Date: {datetime.now().strftime("%Y-%m-%d")}</p>
</body>
</html>
"""
# Generate the invoice PDF
pdfkit.from_string(template, "invoice.pdf")
# Send the invoice via email
import smtplib
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
msg = MIMEMultipart()
msg["Subject"] = f"Invoice for {project_name}"
msg["From"] = "your_email@example.com"
msg["To"] = client_name
attachment = open("invoice.pdf", "rb")
part = MIMEApplication(attachment.read(), Name="invoice.pdf")
part["Content-Disposition"] = "attachment; filename=%s" % "invoice.pdf"
msg.attach(part)
server = smtplib.SMTP("smtp.example.com", 587)
server.starttls()
server.login("your_email@example.com", "your_password")
server.sendmail("your_email@example.com", client_name, msg.as_string())
server.quit()
Step 3: Time Tracking and Reporting with Python
To optimize my workflow, I also use Python to track my time spent on tasks and generate reports. I've created a script that:
- Tracks time spent on tasks using the
timemodule - Generates reports based on task categories and time spent *
Top comments (0)