Send Message on Instagram Using Instabot module in Python
Last Updated :
31 Oct, 2021
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
from instabot import Bot
bot = Bot()
|
Step 2: Now we need to login into our account using the bot.
Python3
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
urer_ids = [ "username1" , "username2" , "....." ]
|
Step 4: Write a message
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
bot.send_messages(text, urer_ids)
|
Below is the full implementation:
Python3
from instabot import Bot
bot = Bot()
bot.login(username = "Your_username" ,
password = "Your_password" )
urer_ids = [ "username1" , "username2" , "....." ]
text = "I like GFG"
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.
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...