Send LinkedIn invitations from spreadsheet
Tags: #googlesheets #invitation #automation #content #notification #email #linkedin
Description: This notebook allows users to quickly and easily send LinkedIn invitations to contacts stored in a Google Sheets spreadsheet.
import naas
from naas_drivers import linkedin, gsheet
👉 The spreadsheet needs to contains profil's url on the 1st column of the file.
spreadsheet_id = "YOUR_SPREADSHEET_ID"
sheet_name = "YOUR_SHEET_NAME"
profile_col_name = "url"
# LinkedIn cookies
LI_AT = "YOUR_COOKIE_LI_AT"
JSESSIONID = "YOUR_COOKIE_JSESSIONID"
# LinkedIn limit invitations up to 100 per week (Becareful !)
add_per_launch = 4
# Scheduler your invitation everyday at 8:00 AM
naas.scheduler.add(cron="0 8 * * *")
# Uncomment the line below to delete your scheduler
# naas.scheduler.delete()
df = gsheet.connect(spreadsheet_id).get(sheet_name=sheet_name)
# Alert when last than 20 urls remains in the gsheet
if len(df) < 20:
email_to = "YOUR_EMAIL"
subject = (
"Invite LinkedIn alert : "
+ str(len(df))
+ " lines left in the Linkedin's url database"
)
content = "You can add more lines to the gsheet or update the Notebook to set a new spreadsheet !"
naas.notification.send(email_to=email_to, subject=subject, html=content)
df = df.head(add_per_launch)
print("Invits will be send to :")
df
for index, row in df.iterrows():
profile = row[profile_col_name]
result = linkedin.connect(LI_AT, JSESSIONID).invitation.send(recipient_url=profile)
print(f"Invitation sent to : {profile}")
# Suppression de la ligne du gsheet
gsheet.connect(spreadsheet_id).delete(sheet_name=sheet_name, rows=[2])