Thursday, April 3, 2025

Social Media Marketing Automation - Auto-Reply DM Bot

 Notes:

  • Problem: Manually responding to messages takes time.

  • Benefit: Automates DM replies based on predefined triggers.

  • Adoption: Can integrate with AI for smarter responses.

Python Code:


import time

from selenium import webdriver


def reply_to_dm(driver):

    driver.get("https://www.instagram.com/direct/inbox/")

    time.sleep(3)

    messages = driver.find_elements("xpath", "//div[@class='RK8tT']")

    for message in messages:

        message.click()

        time.sleep(2)

        try:

            reply_box = driver.find_element("xpath", "//textarea[@aria-label='Message...']")

            reply_box.send_keys("Thank you for reaching out! We'll get back to you soon." + Keys.RETURN)

        except:

            pass


if __name__ == "__main__":

    driver = webdriver.Chrome()

    driver.get("https://www.instagram.com/accounts/login/")

    time.sleep(2)

    reply_to_dm(driver)


No comments:

Post a Comment

IoT (Internet of Things) Automation - Smart Energy Usage Tracker

  Notes: Problem Solved: Logs and analyzes power usage from smart meters. Customization Benefits: Track per-device energy and set ale...