Action
Bike on sidewalk
This reads the name of a street or address from the input draft and asks which service the offending bike belongs to. It then generates an email to that bike company asking them to come pick up that bike.
Steps
-
script
// Ask which service this is and map it to an email address var p = Prompt.create(); p.title = "Which service?"; p.addButton("LimeBike"); p.addButton("Ofo"); p.addButton("Vbikes"); //p.addButton("test"); var didSelect = p.show(); if (didSelect == false) { exit; } var emailAddress = serviceNameToEmail(p.buttonPressed); // Create the email var mail = Mail.create(); mail.toRecipients = [emailAddress] mail.subject = "Bike parked on sidewalk" mail.body = "There is a bike parked on the sidewalk in Plano, TX on " + draft.content + ". Please come pick it up."; // Attempt to send the email var success = mail.send(); if (!success) { console.log(mail.status); context.fail() } /** Map bike service names to their reporting email addresses * @param serviceName The name of the service * @return The email address of the service */ function serviceNameToEmail(serviceName) { switch(serviceName) { case "LimeBike": return "support@likebike.com"; case "Ofo": return "support@ofobike.com"; case "Vbikes": return "info@vbikes.com"; case "test": return "fakebikeservice@example.com" default: throw("Unknown bike service"); } }
Options
-
After Success Archive Notification Info Log Level Info
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.