Jump to content

Calling External Triggers with alfred://runtrigger URI scheme - Inbound Configuration vs "legacy" way


Recommended Posts

I feel silly asking this very basic question, but here we go:

 

I read https://www.alfredapp.com/help/workflows/inbound-configuration/ and also https://www.alfredapp.com/help/workflows/triggers/external/ and can't figure out if it's possible...

 

I like the clean layout and simplicity of adding Inbound Configuration to objects which support it. The docs say "An Inbound Configuration set up with an external identifier will behave the same as using an external trigger and provides additional configuration options." - but it appears that one missing feature is that these objects don't allow calling in via the alfred://runtrigger URI scheme. Am I missing something?

 

Link to comment
Posted (edited)

For now I wrote this little JXA helper to use in shell scripts, but man being able to just call open 'alfred://runtrigger/...' would be a lot cleaner.

 

#!/usr/bin/env osascript -l JavaScript

function run(argv) {

  if (argv.length < 2) {
    console.error('needs at least 2 args: workflow_bundle_id, trigger');
    return;    
  }

  const wf = argv[0];
  const trigger = argv[1];
  const arg = argv[2] ?? '';
  // console.log(`wf:${wf}, trigger:${trigger}, arg:${arg}`);

  const App = Application('com.runningwithcrayons.Alfred');
  // App.includeStandardAdditions = true;
  App.runTrigger(trigger, {
    inWorkflow: wf,
    withArgument: arg
  });

}

 

Edited by luckman212
Link to comment

Don’t think of the URL handler as the new way that replaces the old one, but as a different way that complements the existing one. Using AppleScript is still the preferred method. The goal is to provide you the option to trigger workflows from places where AppleScript wouldn’t work, e.g. a reminder.

We’re mindful of security and intentionality, which is why the URL handler is off by default. Having it hidden further inside an Inbound Configuration could make a trigger very hard to find, and we want users to know it exists. That’s not to say this will never change, but it was very much a conscious choice to have it this way.

Link to comment

I see. Well that does explain what I was experiencing. Thanks as always.

 

While we're discussing the URI schemes, is there a complete documented list somewhere for all the alfred:// and alfredpreferences:// handlers?

 

Here are some that I have collected from nooks and crannies of the forums, but I'm not aware of a definitive list.

 

alfred://runtrigger/...
alfred://gallery/workflow/...
alfredpreferences://navigateto/update
alfredpreferences://navigateto/workflows>workflow>user.workflow.{uuid}...
alfredpreferences://navigateto/features>clipboard>{history}

 

Link to comment
1 hour ago, luckman212 said:

is there a complete documented list somewhere for all the alfred:// and alfredpreferences:// handlers?

 

I was wondering the same recently and found that the breadcrumbs you get when typing, for example ?history, seem to translate to paths you can navigate to.

Link to comment

There’s no documented list of them all. If memory serves, alfred://runtrigger/ is the only one.


The others (I could be misremembering but I think you got them all) are more for Alfred’s internal use than general consumption. In theory their format could change or they could have unpredictable behaviour when called unorthodoxly so you should avoid relying on them. In practice Andrew is really good at this programming stuff and cares so much that things are robust from the get go that we end up latching on to those. It’s kindda like reading the Clipboard History’s SQLite: you shouldn’t really do it but I’ve been at it for a decade and even explain how. In my defence, there is a bolded caveat!


So, yeah. We don’t mind that you use those approaches and may even tweak them to be more useful to you but they’re not advertised as features to allow for some flexibility. The people who use those well and smartly (like you two) tend to be the ones who find them.


That said, we all like good documentation so the door is not closed on someday deciding to write those up.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...