A Marketers Tool — The Art of Automation using Python

Aryan Bajaj
7 min readSep 4, 2022

This blog will help you to understand Instagram automation. It will also help you to build your own Instagram Bot in just 3 Steps & help you to automate your tasks.

Disclaimer

This article is only for educational purposes. If anyone misuses it, I am not responsible.

Introduction

Marketing is the activity, collection of institutions, and procedures for producing, conveying, delivering, and exchanging value-added solutions for consumers, clients, partners, and society as a whole.

Some of the major roles of a marketer include:

The Advertising

Advertising is a major factor in both the success and failure of any business. In regard to cannabis businesses, advertising can sometimes be misunderstood. What a person may think is marketing is actually just simple promotion. Marketing is the act of encouraging people to buy something they might not have bought otherwise. When it comes to marijuana businesses, these advertisements should not only promote the product but also educate potential customers about the industry. These ads should not make the user feel bad about their decision to purchase marijuana. Advertisements need to give information about the product without making users feel guilty while at the same time giving them reassurance that what they are buying is safe.

Promotional Events

Another type of marketing that many people don’t realize is promotional events. Many companies hold events that they invite people to attend, usually free of charge, to learn more about the company. A cannabis business could do this by holding a party at night where guests can walk around and meet different vendors. They might even allow guests to sample some of the products available.

Branding

Branding refers to how a particular brand is represented in the public eye. Branding can either help or hurt a business depending on the image the business chooses to portray. If the company wants to convey a certain message, then it should choose a logo that reflects that message. If a company wants to appear professional and trustworthy, then it should use the correct colors and fonts for its website, social media sites, and other forms of communication.

Have noticed anything common?

The common thing is to promote the product by understanding customers' requirements such as demographics, behavior, etc. & then promote the product using the appropriate channel like direct, social media, organic, etc.

What if we can automate a few channels so that marketers can focus on making new strategies. In this blog, we’ll be trying to automate social media channels using python.

Automation

According to the dictionary automation can be defined as “the method of making an apparatus, a process, or a system run automatically”.

I define Automation as “the development and deployment of technology to monitor and manage the production and delivery of goods and services.”

Let’s talk about automating social media.

Social media automation is the technique of employing computer programs to automate social media users’ activity. These automated operations promote content across numerous channels by using software programs and scripts. The idea is to boost content exposure and interaction at scale without having to spend time manually managing each individual account.

It is believed that just 2% of account managers employ automation technologies today. However, some analysts believe that this figure might rise to 20% in the next years.

Before proceeding further, I would like to talk about a few questions which are very common after listening to the term Social Media Automation.

The first question is:

Why would someone want to do anything like this?

Time is saved by automation. It’s difficult to keep track of what’s going on 24/7 when you’re constantly marketing and connecting with hundreds of thousands of prospective followers across different platforms — especially if you’re juggling many projects.

And, as previously said, automation allows you to focus on larger activities while automating minor ones that require less attention.

It promotes the development of relationships. Many companies (and even celebrities!) now have Facebook Messenger bots. By configuring them, they will automatically communicate with fans and offer them information about new items and events.

Hootsuite, Sprout Social, and Buffer are three of the most popular social media automation programs.

But today we will learn, how to make your own bot to automate different tasks at once.

The last question is:

What exactly does it entail?

To begin, you must make an account on the site you intend to utilize. Then you’ll decide what kind of stuff you want to upload. The bot will then be configured. You may write code yourself or hire someone else to do it for you. Once everything is in place, you may schedule it to run whenever you choose. Finally, keep an eye on your accounts and respond to comments as soon as possible!

Now, I think everyone understands the meaning, methodology, and importance of social media automation.

Let’s start automating Instagram.

Yay! Let’s start coding.

IDE: Visual Studio Code (VSC)

Language: Python

Step — 1

You need to have an Instagram Account. If you don’t have any then you need to create an Instagram Account.

To create an account, go to https://www.instagram.com/ or install the App from Play Store or App Store.

Step — 2

First install Instabot:

pip install instabot

The Next step is to call the necessary libraries.

from instabot import Bot
Step — 3
my_bot = Bot()

Activation of the Bot

Call the Bot Function & enter your ID and Password

my_bot.login(username=input("Type your ID here"), password=input("Type your Password here")

Output:

Follow

Let us put our bot to the test by following someone. To follow we’ll use the code:

my_bot.follow("aryanbajaj8527")

Output:

Follow Multiple Users at Once

To follow multiple users at once, use code:

my_bot.follow_users(["user1", "user2","user3"]) #Add as many users as you want.

Upload Pictures/Videos without Caption

If you want to upload a picture then use the below-mentioned code:

my_bot.upload_photo("Best-Instagram-Bots.jpg")

I have uploaded:

Upload Pictures/Videos with Caption

If you also want to write caption then use below-mentioned code:

my_bot.upload_photo("Best-Instagram-Bots.jpg", caption= "Hello, I am Insta BOT. I am new to Instagram. Any tips for me ?")

If you want to upload a Video then replace photo with video in the above-mentioned code.

Output:

Like Anyones Posts

If you want to like anyones posts then use the below-mentioned code:

my_bot.like_user("aryanbajaj8527", amount=3, filtration=False)

Select as many pictutres/videos/reels as you want to like. All you need is to change the amount from 3 to your desired number. The bot will like all the images/videos/reels in a sequence.

Send Messgaes

If you want to send personalized messages then use the below-mentioned code:

my_bot.send_message("Hello, I am insta bot and How can I help you today?", "username")

Comment of Anyones Posts

If you want to comment then use the below-mentioned Code:

user = my_bot.get_user_id_from_username("user")media = my_bot.get_last_user_medias(user, 1)my_bot.comment(media[0], "Aryan, you are the best!")

To understand how to comment, we must first obtain the userID of the person whose post we wish to remark on and send it in as an arg.

We will obtain the username’s media and the 0’s comment.

Use 0 to comment on most recent media as keep in mind that Python counts from 0 and not 1, thus 0 is the most recent.

After using the Bot, don’t forget to logout. Use the below mentioned code to log out.

my_bot.logout()

Tip

You can write all the codes in one column so that all you need is to run the script.

Before running this code, Instagram will recognise that we are using a bot since the instructions are too quick and lack the feel of a human user.

As a result, we’ll add a pause to allow our bot to wait for a few seconds after running one line of code.

Sleep/Pause

To add sleep to make it like a human use the below-mentioned Code:

sleep(randint(1,30))

randint meaning here is that you don’t need to get confuse like how much time should I select for sleep after each line of code. Jus use the above-mentioned code, python will select random integer value for sleep and each time you run the codes, pyhton will select different values. Now, instagram won’t be able to differentiate whether a human is using instagram or a Bot.

In case of questions, leave a Comment or Email me at aryanbajaj104@gmail.com

ABOUT THE AUTHOR

I recently completed BBA (BUSINESS ANALYTICS) from CHRIST University, Lavasa, Pune Campus.

Website — acumenfinalysis.com (CHECK THIS OUT)

CONTACTS:

If you have any questions or suggestions on what my next article should be about, please write to me at aryanbajaj104@gmail.com.

If you want to keep updated with my latest articles and projects, follow me on Medium.

Subscribe to my Medium Account: https://aryanbajaj13.medium.com/subscribe

CONNECT WITH ME VIA:

LinkedIn

--

--

Aryan Bajaj

Passionate about studying how to improve performance and automate tasks.