Open In App

Send Message on Instagram Using Instabot module in Python

Improve
Improve
Like Article
Like
Save
Share
Report

In this article, we are going to see how to send messages on Instagram using the Instabot module in Python.

Instagram is a nice platform for chatting but when it comes to sending the same message to all friends this is a really boring and time-consuming task especially if you have a large number of followers. To make this easy we make a bot using Python to send messages on Instagram. So without further delay, let’s jump right in.

Module required:

Instabot library: It is a script of promotion and API Python wrapper for Instagram.

pip install instabot

Stepwise implementation:

Step 1: First we import the Bot from the Instabot library and make a variable bot.

Python3




# importing Bot form instabot library.
from instabot import Bot
 
bot = Bot()


Step 2: Now we need to login into our account using the bot.

Python3




# Login using bot
bot.login(username="Your_username",
          password="Your_password")


Step 3: It’s time to make a list of friends/followers to whom messages will be sent. Don’t forget any name because everyone is important. 

Python3




# Make a list of followers/friends
urer_ids = ["username1", "username2", "....."]


Step 4:  Write a message

Python3




# Message
text = "I like GFG"


Step 5: It’s time to send the message. To send messages to more person use the “send_messages” function and to send messages to a single person “send_message” function also can be used.

Python3




# Sending messages to one or more friends
bot.send_messages(text, urer_ids)


Below is the full implementation:

Python3




# Program to send message
# on Instagram using Python.
 
# importing Bot form instabot library.
from instabot import Bot
 
# Creating bot variable.
bot = Bot()
 
# Login using bot.
bot.login(username="Your_username",
          password="Your_password")
 
# Make a list of followers/friends
urer_ids = ["username1", "username2", "....."]
 
# Message
text = "I like GFG"
 
# Sending messages
bot.send_messages(text, urer_ids)


Output:

Note: Sometimes it’s difficult to rerun the program because of login errors to avoid this you need to delete a config folder that is auto-created after running the program once. 



Last Updated : 31 Oct, 2021
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads