Repository navigation
Expand file tree
/
Copy pathtwitter.json
More file actions
executable file
·136 lines (136 loc) · 6.58 KB
/
Copy pathtwitter.json
File metadata and controls
executable file
·136 lines (136 loc) · 6.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
{
"script":{
"released":"2018-06-04",
"license":"Licensed under the Apache License, Version 2.0",
"copyright":"Copyright 2020 Google LLC",
"icon":"perm_phone_msg",
"title":"Twitter Targeting",
"description":"Adjusts line item settings based on Twitter hashtags and locations specified in a sheet.",
"image":"https://google.github.io/starthinker/static/twitter_targeting.png",
"sample":"https://docs.google.com/spreadsheets/d/1iYCGa2NKOZiL2mdT4yiDfV_SWV9C7SUosXdIr4NAEXE/edit?usp=sharing",
"test":"https://github.com/google/starthinker/blob/master/tests/twitter.json",
"from":["twitter", "sheets"],
"to":["bigquery", "dv360"],
"pitches":[
"Create campaigns that respond to twitter trends.",
"Activate spend when a specific tag trends.",
"Protect brand by disabling advertising based on trends.",
"Fully automated, just provide locations, hashtags and line item settings to change."
],
"impacts":{
"spend optimization":100,
"spend growth":80,
"time savings":90,
"account health":60,
"csat improvement":70
},
"instructions":[
"Click **Run Now** and a sheet called **Twitter Targeting {field:recipe_name}** will be generated with a tab called **Twitter Triggers**.",
"Follow instructions on the sheets tab to provide triggers and lineitems.",
"Click **Run Now** again, trends are downloaded and triggered.",
"Or give these intructions to the client."
],
"authors":["kenjora@google.com"],
"managers":["kenjora@google.com"]
},
"setup":{
"day":["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
"hour":[2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24]
},
"tasks":[
{ "dataset":{
"description":"Create a dataset where data will be combined and transfored for upload.",
"auth":{"field":{ "name":"auth_write", "kind":"authentication", "order":1, "default":"service", "description":"Credentials used for writing data." }},
"dataset":{"field":{ "name":"recipe_slug", "kind":"string", "order":1, "description":"Place where tables will be created in BigQuery." }}
}},
{ "sheets":{
"description":"Read mapping of hash tags to line item toggles from sheets.",
"auth":{"field":{ "name":"auth_read", "kind":"authentication", "order":0, "default":"user", "description":"Credentials used for reading data." }},
"template":{
"sheet":"https://docs.google.com/spreadsheets/d/1iYCGa2NKOZiL2mdT4yiDfV_SWV9C7SUosXdIr4NAEXE/edit?usp=sharing",
"tab":"Twitter Triggers"
},
"sheet":{"field":{ "name":"recipe_name", "kind":"string", "prefix":"Twitter Targeting For ", "order":2, "description":"Name of sheet where Line Item settings will be read from.", "default":"" }},
"tab":"Twitter Triggers",
"range":"A7:E",
"out":{
"bigquery":{
"dataset":{"field":{ "name":"recipe_slug", "kind":"string", "description":"Place where tables will be created in BigQuery." }},
"table":"Twitter_Triggers",
"schema":[
{ "name":"Location", "type":"STRING", "mode":"REQUIRED" },
{ "name":"WOEID", "type":"INTEGER", "mode":"REQUIRED" },
{ "name":"Hashtag", "type":"STRING", "mode":"REQUIRED" },
{ "name":"Advertiser_Id", "type":"INTEGER", "mode":"REQUIRED" },
{ "name":"Line_Item_Id", "type":"INTEGER", "mode":"REQUIRED" }
]
}
}
}},
{ "twitter":{
"description":"Read trends from Twitter and place into BigQuery.",
"auth":{"field":{ "name":"auth_write", "kind":"authentication", "order":1, "default":"service", "description":"Credentials used for writing data." }},
"secret":{"field":{ "name":"twitter_secret", "kind":"string", "order":3, "default":"", "description":"Twitter API secret token." }},
"key":{"field":{ "name":"twitter_key", "kind":"string", "order":4, "default":"", "description":"Twitter API key token." }},
"trends":{
"places":{
"single_cell":true,
"bigquery":{
"dataset":{"field":{ "name":"recipe_slug", "kind":"string", "description":"Place where tables will be created in BigQuery." }},
"query":"SELECT DISTINCT WOEID FROM {dataset}.Twitter_Triggers",
"legacy":false,
"parameters":{
"dataset":{"field":{ "name":"recipe_slug", "kind":"string", "description":"Place where tables will be created in BigQuery." }}
}
}
}
},
"out":{
"bigquery":{
"dataset":{"field":{ "name":"recipe_slug", "kind":"string", "description":"Place where tables will be created in BigQuery." }},
"table":"Twitter_Trends_Place"
}
}
}},
{ "google_api": {
"description":"Combine sheet and twitter data into API operations for each line item. Match all possibilities and PAUSE if no trigger match.",
"auth":{"field":{ "name":"auth_write", "kind":"authentication", "order":1, "default":"service", "description":"Credentials used for writing data." }},
"api": "displayvideo",
"version": "v1",
"function": "advertisers.lineItems.patch",
"kwargs_remote": {
"bigquery": {
"dataset":{"field":{ "name":"recipe_slug", "kind":"string", "order":4, "default":"", "description":"Name of Google BigQuery dataset to create." }},
"query": "
SELECT
CAST(S.Advertiser_Id AS STRING) advertiserId,
CAST(S.Line_Item_Id AS STRING) AS lineItemId,
STRUCT(
IF(LOGICAL_OR(T.Name is NULL), 'ENTITY_STATUS_ACTIVE', 'ENTITY_STATUS_PAUSED') AS entityStatus
) AS body,
'entityStatus' AS updateMask,
FROM `{dataset}.Twitter_Triggers` AS S
LEFT JOIN `{dataset}.Twitter_Trends_Place` As T
ON S.WOEID=T.WOEID AND REPLACE(LOWER(S.Hashtag), '#', '')=REPLACE(LOWER(T.Name), '#', '')
GROUP BY 1,2
",
"parameters":{
"dataset":{"field":{ "name":"recipe_slug", "kind":"string", "description":"Place where tables will be created in BigQuery." }}
}
}
},
"results": {
"bigquery": {
"dataset": {"field":{ "name":"recipe_slug", "kind":"string", "order":4, "default":"", "description":"Name of Google BigQuery dataset to create." }},
"table": "Trigger_Results"
}
},
"errors": {
"bigquery": {
"dataset": {"field":{ "name":"recipe_slug", "kind":"string", "order":4, "default":"", "description":"Name of Google BigQuery dataset to create." }},
"table": "Trigger_Errors"
}
}
}}
]
}