At the moment I have a dashboard up and running and it has a list of names with corresponding deals (where values are missing) and links to these deals. I want to be able to set up an email automation so that any person who has a name on this list will receive an email, say weekly.
I have googled my question and it seems that it is possible to set up an email automation weekly. However, the problem I am having is getting the list of people to change week to week. Is this possible to do on looker?
Thank you in advance,
Best answer by Eric_Lyons
We potentially could use the API to do this. I created an example below where I used our Python SDK and the popular python library Pandas. Let’s say we have a look with emails and a yesno field. If we want to conditional send users in this look a dashboard (in the example with an id of 857), we can download the data from the Look, (this could be a tile on the dashboard) then we parse the email and yesno column. If the value is YES, we create a schedule plan and send them a copy of dashboard 857. We could set this up with a cronjob to fully automate this process on a custom schedule.
import pandas as pd
# from typing import cast, MutableSequence, Sequence
####Initialize API/SDK for more info go here: https://pypi.org/project/looker-sdk/
from looker_sdk import methods40, models40
sdk = looker_sdk.init40() # or init40() for v4.0 API
me = sdk.me()
## Run look and write data as a CSV
look = sdk.run_look(look_id=1995,result_format="csv")
file = open('read.csv','w')
df = pd.read_csv("read.csv")
## Filter DataFrame so it only returns Yes values for YESNO field
sends = df[df['YESNO']=="Yes"]
#create a list of emails
emails = sends['Users Email'].tolist()
while i < len(emails):
schedule = sdk.scheduled_plan_run_once(body=models40.WriteScheduledPlan(name="New Dynamic Email List Test",run_as_recipient=False, dashboard_id=857, crontab="0 0 1 * *", scheduled_plan_destination = [models40.ScheduledPlanDestination(format="csv_zip", address=emails[i], type = "email")]))
i = i + 1