Action
Send to Pushover
Posted by deanfx,
Last update
9 days ago
UPDATES
9 days ago
- Included the ability to set a title of your draft prior to it sending to Pushover. This defaults to the date/time for quick-send.
This action will send the contents of the active draft to Pushover.
At first run, it will require you to provide your userKey and appToken. Be sure to have this ready!
The token and key are stored within drafts credentials.
To manage the credentials used, or to change:
Drafts Settings > Credentials > Pushover Credentials
Steps
-
script
let credential = Credential.create("Pushover Config", "Enter your Pushover API details once."); credential.addTextField("uKey", "User Key"); credential.addPasswordField("aToken", "API Token"); if (credential.authorize()) { const userKey = credential.getValue("uKey"); const appToken = credential.getValue("aToken"); let now = new Date(); let timestamp = now.getFullYear() + "-" + String(now.getMonth() + 1).padStart(2, '0') + "-" + String(now.getDate()).padStart(2, '0') + "–" + String(now.getHours()).padStart(2, '0') + ":" + String(now.getMinutes()).padStart(2, '0'); let p = Prompt.create(); p.title = "Notification Title"; p.addTextField("titleInput", "Title", timestamp); // Defaults to the timestamp p.addButton("Send"); if (p.show()) { let finalTitle = p.fieldValues["titleInput"]; let http = HTTP.create(); let response = http.request({ "url": "https://api.pushover.net/1/messages.json", "method": "POST", "parameters": { "token": appToken, "user": userKey, "title": finalTitle, "message": draft.content || "(No Body Content)" } }); if (response.statusCode == 200) { app.displaySuccessMessage("Pushed: " + finalTitle); } else { alert("Error: " + response.responseText); context.fail(); } } else { context.cancel("User cancelled the send."); } }
Options
-
After Success Default Notification Info Log Level Info
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.