Schedule posts
Tags: #twitter #automation #ifttt #naas_drivers #gsheet #content
Description: This notebook allows you to plan and schedule posts to your Twitter account.
from datetime import datetime
import naas_drivers
import naas
spreadsheet_id = "1rFzw8eeVNXyD5CEUjnpxVn_iA2hzabYKU6pRdmnZ3FQ"
df = naas_drivers.gsheet.connect(spreadsheet_id).get(sheet_name="Sheet1")
df
now = datetime.now().replace(
second=0, microsecond=0
) # the Naas scheduler only allow minutes
now
# dd/mm/YY H:M:S
dt_string = now.strftime(
"%d/%m/%Y %H:%M:%S"
) # To mach date time format in google sheet
dt_string
If BROADCAST_DATE matches the current time then send twit from text column.
# naas.scheduler.delete()
naas.scheduler.add(recurrence="* * * * *") # to run every minute
for i in range(len(df)):
print(dt_string, df["BROADCAST_DATE"][i])
if dt_string == df["BROADCAST_DATE"][i]:
twitter_post = df["TEXT"][i]
event = "naas_demo"
key = "ke4AigvXI5-EABaowdLt4fju1aOUxeMxSXQoN8FVyA"
data = {"value1": twitter_post}
result = naas_drivers.ifttt.connect(key).send(event, data)
Last modified 1mo ago