Email automation

Hi Guys,

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,

Ev

Solved Solved
0 3 1,461
1 ACCEPTED SOLUTION

Hi @evan1,

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 looker_sdk
import csv
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')
file.write(look)
file.close()
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()
i=0
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, type = "email")]))
i = i + 1

View solution in original post

3 REPLIES 3

Hi @evan1,

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 looker_sdk
import csv
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')
file.write(look)
file.close()
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()
i=0
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, type = "email")]))
i = i + 1

Thanks for your reply, Eric. I’m currently looking into this right now! With regards to the email automation, what do you mean by cronjob? What would that involve? 

Hi @evan1, a cronjob is generally a schedule on a server or computer that allows use to run a program on a regular basis or at a specific time. The common one is crontab which is built into many linux operating systems. 

Top Labels in this Space
Top Solution Authors