diff --git a/ToBeMigrated/ai_marketing_tools/ai_backlinker/README.md b/ToBeMigrated/ai_marketing_tools/ai_backlinker/README.md
deleted file mode 100644
index 3d09c64c..00000000
--- a/ToBeMigrated/ai_marketing_tools/ai_backlinker/README.md
+++ /dev/null
@@ -1,117 +0,0 @@
----
-
-# AI Backlinking Tool
-
-## Overview
-
-The `ai_backlinking.py` module is part of the [AI-Writer](https://github.com/AJaySi/AI-Writer) project. It simplifies and automates the process of finding and securing backlink opportunities. Using AI, the tool performs web research, extracts contact information, and sends personalized outreach emails for guest posting opportunities, making it an essential tool for content writers, digital marketers, and solopreneurs.
-
----
-
-## Key Features
-
-| Feature | Description |
-|-------------------------------|-----------------------------------------------------------------------------|
-| **Automated Web Scraping** | Extract guest post opportunities, contact details, and website insights. |
-| **AI-Powered Emails** | Create personalized outreach emails tailored to target websites. |
-| **Email Automation** | Integrate with platforms like Gmail or SendGrid for streamlined communication. |
-| **Lead Management** | Track email status (sent, replied, successful) and follow up efficiently. |
-| **Batch Processing** | Handle multiple keywords and queries simultaneously. |
-| **AI-Driven Follow-Up** | Automate polite reminders if there's no response. |
-| **Reports and Analytics** | View performance metrics like email open rates and backlink success rates. |
-
----
-
-## Workflow Breakdown
-
-| Step | Action | Example |
-|-------------------------------|---------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------|
-| **Input Keywords** | Provide keywords for backlinking opportunities. | *E.g., "AI tools", "SEO strategies", "content marketing."* |
-| **Generate Search Queries** | Automatically create queries for search engines. | *E.g., "AI tools + 'write for us'" or "content marketing + 'submit a guest post.'"* |
-| **Web Scraping** | Collect URLs, email addresses, and content details from target websites. | Extract "editor@contentblog.com" from "https://contentblog.com/write-for-us". |
-| **Compose Outreach Emails** | Use AI to draft personalized emails based on scraped website data. | Email tailored to "Content Blog" discussing "AI tools for better content writing." |
-| **Automated Email Sending** | Review and send emails or fully automate the process. | Send emails through Gmail or other SMTP services. |
-| **Follow-Ups** | Automate follow-ups for non-responsive contacts. | A polite reminder email sent 7 days later. |
-| **Track and Log Results** | Monitor sent emails, responses, and backlink placements. | View logs showing responses and backlink acquisition rate. |
-
----
-
-## Prerequisites
-
-- **Python Version**: 3.6 or higher.
-- **Required Packages**: `googlesearch-python`, `loguru`, `smtplib`, `email`.
-
----
-
-## Installation
-
-1. Clone the repository:
- ```bash
- git clone https://github.com/AJaySi/AI-Writer.git
- cd AI-Writer
- ```
-
-2. Install dependencies:
- ```bash
- pip install -r requirements.txt
- ```
-
----
-
-## Example Usage
-
-Here’s a quick example of how to use the tool:
-
-```python
-from lib.ai_marketing_tools.ai_backlinking import main_backlinking_workflow
-
-# Email configurations
-smtp_config = {
- 'server': 'smtp.gmail.com',
- 'port': 587,
- 'user': 'your_email@gmail.com',
- 'password': 'your_password'
-}
-
-imap_config = {
- 'server': 'imap.gmail.com',
- 'user': 'your_email@gmail.com',
- 'password': 'your_password'
-}
-
-# Proposal details
-user_proposal = {
- 'user_name': 'Your Name',
- 'user_email': 'your_email@gmail.com',
- 'topic': 'Proposed guest post topic'
-}
-
-# Keywords to search
-keywords = ['AI tools', 'SEO strategies', 'content marketing']
-
-# Start the workflow
-main_backlinking_workflow(keywords, smtp_config, imap_config, user_proposal)
-```
-
----
-
-## Core Functions
-
-| Function | Purpose |
-|--------------------------------------------|-------------------------------------------------------------------------------------------|
-| `generate_search_queries(keyword)` | Create search queries to find guest post opportunities. |
-| `find_backlink_opportunities(keyword)` | Scrape websites for backlink opportunities. |
-| `compose_personalized_email()` | Draft outreach emails using AI insights and website data. |
-| `send_email()` | Send emails using SMTP configurations. |
-| `check_email_responses()` | Monitor inbox for replies using IMAP. |
-| `send_follow_up_email()` | Automate polite reminders to non-responsive contacts. |
-| `log_sent_email()` | Keep a record of all sent emails and responses. |
-| `main_backlinking_workflow()` | Execute the complete backlinking workflow for multiple keywords. |
-
----
-
-## License
-
-This project is licensed under the MIT License. For more details, refer to the [LICENSE](LICENSE) file.
-
----
diff --git a/ToBeMigrated/ai_marketing_tools/ai_backlinker/ai_backlinking.py b/ToBeMigrated/ai_marketing_tools/ai_backlinker/ai_backlinking.py
deleted file mode 100644
index 8e25bd34..00000000
--- a/ToBeMigrated/ai_marketing_tools/ai_backlinker/ai_backlinking.py
+++ /dev/null
@@ -1,423 +0,0 @@
-#Problem:
-#
-#Finding websites for guest posts is manual, tedious, and time-consuming. Communicating with webmasters, maintaining conversations, and keeping track of backlinking opportunities is difficult to scale. Content creators and marketers struggle with discovering new websites and consistently getting backlinks.
-#Solution:
-#
-#An AI-powered backlinking app that automates web research, scrapes websites, extracts contact information, and sends personalized outreach emails to webmasters. This would simplify the entire process, allowing marketers to scale their backlinking strategy with minimal manual intervention.
-#Core Workflow:
-#
-# User Input:
-# Keyword Search: The user inputs a keyword (e.g., "AI writers").
-# Search Queries: Your app will append various search strings to this keyword to find backlinking opportunities (e.g., "AI writers + 'Write for Us'").
-#
-# Web Research:
-#
-# Use search engines or web scraping to run multiple queries:
-# Keyword + "Guest Contributor"
-# Keyword + "Add Guest Post"
-# Keyword + "Write for Us", etc.
-#
-# Collect URLs of websites that have pages or posts related to guest post opportunities.
-#
-# Scrape Website Data:
-# Contact Information Extraction:
-# Scrape the website for contact details (email addresses, contact forms, etc.).
-# Use natural language processing (NLP) to understand the type of content on the website and who the contact person might be (webmaster, editor, or guest post manager).
-# Website Content Understanding:
-# Scrape a summary of each website's content (e.g., their blog topics, categories, and tone) to personalize the email based on the site's focus.
-#
-# Personalized Outreach:
-# AI Email Composition:
-# Compose personalized outreach emails based on:
-# The scraped data (website content, topic focus, etc.).
-# The user's input (what kind of guest post or content they want to contribute).
-# Example: "Hi [Webmaster Name], I noticed that your site [Site Name] features high-quality content about [Topic]. I would love to contribute a guest post on [Proposed Topic] in exchange for a backlink."
-#
-# Automated Email Sending:
-# Review Emails (Optional HITL):
-# Let users review and approve the personalized emails before they are sent, or allow full automation.
-# Send Emails:
-# Automate email dispatch through an integrated SMTP or API (e.g., Gmail API, SendGrid).
-# Keep track of which emails were sent, bounced, or received replies.
-#
-# Scaling the Search:
-# Repeat for Multiple Keywords:
-# Run the same scraping and outreach process for a list of relevant keywords, either automatically suggested or uploaded by the user.
-# Keep Track of Sent Emails:
-# Maintain a log of all sent emails, responses, and follow-up reminders to avoid repetition or forgotten leads.
-#
-# Tracking Responses and Follow-ups:
-# Automated Responses:
-# If a website replies positively, AI can respond with predefined follow-up emails (e.g., proposing topics, confirming submission deadlines).
-# Follow-up Reminders:
-# If there's no reply, the system can send polite follow-up reminders at pre-set intervals.
-#
-#Key Features:
-#
-# Automated Web Scraping:
-# Scrape websites for guest post opportunities using a predefined set of search queries based on user input.
-# Extract key information like email addresses, names, and submission guidelines.
-#
-# Personalized Email Writing:
-# Leverage AI to create personalized emails using the scraped website information.
-# Tailor each email to the tone, content style, and focus of the website.
-#
-# Email Sending Automation:
-# Integrate with email platforms (e.g., Gmail, SendGrid, or custom SMTP).
-# Send automated outreach emails with the ability for users to review first (HITL - Human-in-the-loop) or automate completely.
-#
-# Customizable Email Templates:
-# Allow users to customize or choose from a set of email templates for different types of outreach (e.g., guest post requests, follow-up emails, submission offers).
-#
-# Lead Tracking and Management:
-# Track all emails sent, monitor replies, and keep track of successful backlinks.
-# Log each lead's status (e.g., emailed, responded, no reply) to manage future interactions.
-#
-# Multiple Keywords/Queries:
-# Allow users to run the same process for a batch of keywords, automatically generating relevant search queries for each.
-#
-# AI-Driven Follow-Up:
-# Schedule follow-up emails if there is no response after a specified period.
-#
-# Reports and Analytics:
-# Provide users with reports on how many emails were sent, opened, replied to, and successful backlink placements.
-#
-#Advanced Features (for Scaling and Optimization):
-#
-# Domain Authority Filtering:
-# Use SEO APIs (e.g., Moz, Ahrefs) to filter websites based on their domain authority or backlink strength.
-# Prioritize high-authority websites to maximize the impact of backlinks.
-#
-# Spam Detection:
-# Use AI to detect and avoid spammy or low-quality websites that might harm the user's SEO.
-#
-# Contact Form Auto-Fill:
-# If the site only offers a contact form (without email), automatically fill and submit the form with AI-generated content.
-#
-# Dynamic Content Suggestions:
-# Suggest guest post topics based on the website's focus, using NLP to analyze the site's existing content.
-#
-# Bulk Email Support:
-# Allow users to bulk-send outreach emails while still personalizing each message for scalability.
-#
-# AI Copy Optimization:
-# Use copywriting AI to optimize email content, adjusting tone and CTA based on the target audience.
-#
-#Challenges and Considerations:
-#
-# Legal Compliance:
-# Ensure compliance with anti-spam laws (e.g., CAN-SPAM, GDPR) by including unsubscribe options or manual email approval.
-#
-# Scraping Limits:
-# Be mindful of scraping limits on certain websites and employ smart throttling or use API-based scraping for better reliability.
-#
-# Deliverability:
-# Ensure emails are delivered properly without landing in spam folders by integrating proper email authentication (SPF, DKIM) and using high-reputation SMTP servers.
-#
-# Maintaining Email Personalization:
-# Striking the balance between automating the email process and keeping each message personal enough to avoid being flagged as spam.
-#
-#Technology Stack:
-#
-# Web Scraping: BeautifulSoup, Scrapy, or Puppeteer for scraping guest post opportunities and contact information.
-# Email Automation: Integrate with Gmail API, SendGrid, or Mailgun for sending emails.
-# NLP for Personalization: GPT-based models for email generation and web content understanding.
-# Frontend: React or Vue for the user interface.
-# Backend: Python/Node.js with Flask or Express for the API and automation logic.
-# Database: MongoDB or PostgreSQL to track leads, emails, and responses.
-#
-#This solution will significantly streamline the backlinking process by automating the most tedious tasks, from finding sites to personalizing outreach, enabling marketers to focus on content creation and high-level strategies.
-
-
-import sys
-# from googlesearch import search # Temporarily disabled for future enhancement
-from loguru import logger
-from lib.ai_web_researcher.firecrawl_web_crawler import scrape_website
-from lib.gpt_providers.text_generation.main_text_generation import llm_text_gen
-from lib.ai_web_researcher.firecrawl_web_crawler import scrape_url
-import smtplib
-from email.mime.multipart import MIMEMultipart
-from email.mime.text import MIMEText
-
-# Configure logger
-logger.remove()
-logger.add(sys.stdout,
- colorize=True,
- format="{level}|{file}:{line}:{function}| {message}"
- )
-
-def generate_search_queries(keyword):
- """
- Generate a list of search queries for finding guest post opportunities.
-
- Args:
- keyword (str): The keyword to base the search queries on.
-
- Returns:
- list: A list of search queries.
- """
- return [
- f"{keyword} + 'Guest Contributor'",
- f"{keyword} + 'Add Guest Post'",
- f"{keyword} + 'Guest Bloggers Wanted'",
- f"{keyword} + 'Write for Us'",
- f"{keyword} + 'Submit Guest Post'",
- f"{keyword} + 'Become a Guest Blogger'",
- f"{keyword} + 'guest post opportunities'",
- f"{keyword} + 'Submit article'",
- ]
-
-def find_backlink_opportunities(keyword):
- """
- Find backlink opportunities by scraping websites based on search queries.
-
- Args:
- keyword (str): The keyword to search for backlink opportunities.
-
- Returns:
- list: A list of results from the scraped websites.
- """
- search_queries = generate_search_queries(keyword)
- results = []
-
- # Temporarily disabled Google search functionality
- # for query in search_queries:
- # urls = search_for_urls(query)
- # for url in urls:
- # website_data = scrape_website(url)
- # logger.info(f"Scraped Website content for {url}: {website_data}")
- # if website_data:
- # contact_info = extract_contact_info(website_data)
- # logger.info(f"Contact details found for {url}: {contact_info}")
-
- # Placeholder return for now
- return []
-
-def search_for_urls(query):
- """
- Search for URLs using Google search.
-
- Args:
- query (str): The search query.
-
- Returns:
- list: List of URLs found.
- """
- # Temporarily disabled Google search functionality
- # return list(search(query, num_results=10))
- return []
-
-def compose_personalized_email(website_data, insights, user_proposal):
- """
- Compose a personalized outreach email using AI LLM based on website data, insights, and user proposal.
-
- Args:
- website_data (dict): The data of the website including metadata and contact info.
- insights (str): Insights generated by the LLM about the website.
- user_proposal (dict): The user's proposal for a guest post or content contribution.
-
- Returns:
- str: A personalized email message.
- """
- contact_name = website_data.get("contact_info", {}).get("name", "Webmaster")
- site_name = website_data.get("metadata", {}).get("title", "your site")
- proposed_topic = user_proposal.get("topic", "a guest post")
- user_name = user_proposal.get("user_name", "Your Name")
- user_email = user_proposal.get("user_email", "your_email@example.com")
-
- # Refined prompt for email generation
- email_prompt = f"""
-You are an AI assistant tasked with composing a highly personalized outreach email for guest posting.
-
-Contact Name: {contact_name}
-Website Name: {site_name}
-Proposed Topic: {proposed_topic}
-
-User Details:
-Name: {user_name}
-Email: {user_email}
-
-Website Insights: {insights}
-
-Please compose a professional and engaging email that includes:
-1. A personalized introduction addressing the recipient.
-2. A mention of the website's content focus.
-3. A proposal for a guest post.
-4. A call to action to discuss the guest post opportunity.
-5. A polite closing with user contact details.
-"""
-
- return llm_text_gen(email_prompt)
-
-def send_email(smtp_server, smtp_port, smtp_user, smtp_password, to_email, subject, body):
- """
- Send an email using an SMTP server.
-
- Args:
- smtp_server (str): The SMTP server address.
- smtp_port (int): The SMTP server port.
- smtp_user (str): The SMTP server username.
- smtp_password (str): The SMTP server password.
- to_email (str): The recipient's email address.
- subject (str): The email subject.
- body (str): The email body.
-
- Returns:
- bool: True if the email was sent successfully, False otherwise.
- """
- try:
- msg = MIMEMultipart()
- msg['From'] = smtp_user
- msg['To'] = to_email
- msg['Subject'] = subject
- msg.attach(MIMEText(body, 'plain'))
-
- server = smtplib.SMTP(smtp_server, smtp_port)
- server.starttls()
- server.login(smtp_user, smtp_password)
- server.send_message(msg)
- server.quit()
-
- logger.info(f"Email sent successfully to {to_email}")
- return True
- except Exception as e:
- logger.error(f"Failed to send email to {to_email}: {e}")
- return False
-
-def extract_contact_info(website_data):
- """
- Extract contact information from website data.
-
- Args:
- website_data (dict): Scraped data from the website.
-
- Returns:
- dict: Extracted contact information such as name, email, etc.
- """
- # Placeholder for extracting contact information logic
- return {
- "name": website_data.get("contact", {}).get("name", "Webmaster"),
- "email": website_data.get("contact", {}).get("email", ""),
- }
-
-def find_backlink_opportunities_for_keywords(keywords):
- """
- Find backlink opportunities for multiple keywords.
-
- Args:
- keywords (list): A list of keywords to search for backlink opportunities.
-
- Returns:
- dict: A dictionary with keywords as keys and a list of results as values.
- """
- all_results = {}
- for keyword in keywords:
- results = find_backlink_opportunities(keyword)
- all_results[keyword] = results
- return all_results
-
-def log_sent_email(keyword, email_info):
- """
- Log the information of a sent email.
-
- Args:
- keyword (str): The keyword associated with the email.
- email_info (dict): Information about the sent email (e.g., recipient, subject, body).
- """
- with open(f"{keyword}_sent_emails.log", "a") as log_file:
- log_file.write(f"{email_info}\n")
-
-def check_email_responses(imap_server, imap_user, imap_password):
- """
- Check email responses using an IMAP server.
-
- Args:
- imap_server (str): The IMAP server address.
- imap_user (str): The IMAP server username.
- imap_password (str): The IMAP server password.
-
- Returns:
- list: A list of email responses.
- """
- responses = []
- try:
- mail = imaplib.IMAP4_SSL(imap_server)
- mail.login(imap_user, imap_password)
- mail.select('inbox')
-
- status, data = mail.search(None, 'UNSEEN')
- mail_ids = data[0]
- id_list = mail_ids.split()
-
- for mail_id in id_list:
- status, data = mail.fetch(mail_id, '(RFC822)')
- msg = email.message_from_bytes(data[0][1])
- if msg.is_multipart():
- for part in msg.walk():
- if part.get_content_type() == 'text/plain':
- responses.append(part.get_payload(decode=True).decode())
- else:
- responses.append(msg.get_payload(decode=True).decode())
-
- mail.logout()
- except Exception as e:
- logger.error(f"Failed to check email responses: {e}")
-
- return responses
-
-def send_follow_up_email(smtp_server, smtp_port, smtp_user, smtp_password, to_email, subject, body):
- """
- Send a follow-up email using an SMTP server.
-
- Args:
- smtp_server (str): The SMTP server address.
- smtp_port (int): The SMTP server port.
- smtp_user (str): The SMTP server username.
- smtp_password (str): The SMTP server password.
- to_email (str): The recipient's email address.
- subject (str): The email subject.
- body (str): The email body.
-
- Returns:
- bool: True if the email was sent successfully, False otherwise.
- """
- return send_email(smtp_server, smtp_port, smtp_user, smtp_password, to_email, subject, body)
-
-def main_backlinking_workflow(keywords, smtp_config, imap_config, user_proposal):
- """
- Main workflow for the AI-powered backlinking feature.
-
- Args:
- keywords (list): A list of keywords to search for backlink opportunities.
- smtp_config (dict): SMTP configuration for sending emails.
- imap_config (dict): IMAP configuration for checking email responses.
- user_proposal (dict): The user's proposal for a guest post or content contribution.
-
- Returns:
- None
- """
- all_results = find_backlink_opportunities_for_keywords(keywords)
-
- for keyword, results in all_results.items():
- for result in results:
- email_body = compose_personalized_email(result, result['insights'], user_proposal)
- email_sent = send_email(
- smtp_config['server'],
- smtp_config['port'],
- smtp_config['user'],
- smtp_config['password'],
- result['contact_info']['email'],
- f"Guest Post Proposal for {result['metadata']['title']}",
- email_body
- )
- if email_sent:
- log_sent_email(keyword, {
- "to": result['contact_info']['email'],
- "subject": f"Guest Post Proposal for {result['metadata']['title']}",
- "body": email_body
- })
-
- responses = check_email_responses(imap_config['server'], imap_config['user'], imap_config['password'])
- for response in responses:
- # TBD : Process and possibly send follow-up emails based on responses
- pass
diff --git a/ToBeMigrated/ai_marketing_tools/ai_backlinker/backlinking_ui_streamlit.py b/ToBeMigrated/ai_marketing_tools/ai_backlinker/backlinking_ui_streamlit.py
deleted file mode 100644
index e5222671..00000000
--- a/ToBeMigrated/ai_marketing_tools/ai_backlinker/backlinking_ui_streamlit.py
+++ /dev/null
@@ -1,60 +0,0 @@
-import streamlit as st
-import pandas as pd
-from st_aggrid import AgGrid, GridOptionsBuilder, GridUpdateMode
-from lib.ai_marketing_tools.ai_backlinker.ai_backlinking import find_backlink_opportunities, compose_personalized_email
-
-
-# Streamlit UI function
-def backlinking_ui():
- st.title("AI Backlinking Tool")
-
- # Step 1: Get user inputs
- keyword = st.text_input("Enter a keyword", value="technology")
-
- # Step 2: Generate backlink opportunities
- if st.button("Find Backlink Opportunities"):
- if keyword:
- backlink_opportunities = find_backlink_opportunities(keyword)
-
- # Convert results to a DataFrame for display
- df = pd.DataFrame(backlink_opportunities)
-
- # Create a selectable table using st-aggrid
- gb = GridOptionsBuilder.from_dataframe(df)
- gb.configure_selection('multiple', use_checkbox=True, groupSelectsChildren=True)
- gridOptions = gb.build()
-
- grid_response = AgGrid(
- df,
- gridOptions=gridOptions,
- update_mode=GridUpdateMode.SELECTION_CHANGED,
- height=200,
- width='100%'
- )
-
- selected_rows = grid_response['selected_rows']
-
- if selected_rows:
- st.write("Selected Opportunities:")
- st.table(pd.DataFrame(selected_rows))
-
- # Step 3: Option to generate personalized emails for selected opportunities
- if st.button("Generate Emails for Selected Opportunities"):
- user_proposal = {
- "user_name": st.text_input("Your Name", value="John Doe"),
- "user_email": st.text_input("Your Email", value="john@example.com")
- }
-
- emails = []
- for selected in selected_rows:
- insights = f"Insights based on content from {selected['url']}."
- email = compose_personalized_email(selected, insights, user_proposal)
- emails.append(email)
-
- st.subheader("Generated Emails:")
- for email in emails:
- st.write(email)
- st.markdown("---")
-
- else:
- st.error("Please enter a keyword.")