Skip to content

Instantly share code, notes, and snippets.

@melangue
Last active April 17, 2020 08:51
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save melangue/820c7de9b8e9ed811fba1a8fb41934a8 to your computer and use it in GitHub Desktop.
Save melangue/820c7de9b8e9ed811fba1a8fb41934a8 to your computer and use it in GitHub Desktop.
Run workflows in Workflow app from your Mac

Run workflows in Workflow app from your Mac

Choose your workflow from a list, pass some input, hit OK.
You'll get a push notification from Pushbullet on your iOS device.
It will run the specified workflow with your input when opened.

Instructions:

  • Create a Pushbullet account
  • Get an API Access Token
  • Download the Pushbullet iOS app
  • Create a workflow in Workflow app to test the script - you can use this one
  • Replace workflow names in choose from list
  • Replace <your-access-token> with your token
  • Run the script to test it
  • Save the script and bind it to a keyboard shortcut for easy access
  • Success!

What can you do with it?
Use your imagination. 💡

If you have got another idea for send as push notification with link - let me know - @melangue
Applescript URL encoding part found here.

# Run workflows in Workflow app from your Mac
# 19-07-2017 @melangue
# Pushbullet Access Token
set theToken to "<your-acces-token>" as text
# Workflow names
set workflowname to (choose from list {"Test", "Test2", "Test3"} with title "Workflow:" default items {"Test"}) as text
if result is "false" then return
# Input
set input to text returned of (display dialog "Input:" buttons {"Cancel", "OK"} default button 2 default answer "" with icon 1)
# URL-encode the workflow name
set encodedWorkflow to do shell script ¬
"perl -MURI::Escape -lne 'print uri_escape($_)' <<<" & quoted form of workflowname
# URL-encode the input
set inputWorkflow to do shell script ¬
"perl -MURI::Escape -lne 'print uri_escape($_)' <<<" & quoted form of input
# Create the link for Workflow
set theURL to "workflow://run-workflow?name=" & encodedWorkflow & "&input=text&text=" & inputWorkflow
# Send the link via Pushbullet
do shell script "curl -H 'Content-Type: application/json' -H 'Access-Token: " & theToken & "' -X POST -d '{\"type\":\"link\",\"url\":\"" & theURL & "\"}' https://api.pushbullet.com/v2/pushes"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment