Jump to content

Modularize parts of Workflow to avoid redundancy


Recommended Posts

Hi, I have been creating workflows with alfred but find myself using lot of alfred objects that kinda do the same thing, but in a different flow (in the same workflow). How can I reduce this redundancy?

 

For instance, here a workflow I created for amazon.com order search and amazon prime video:

 

Goals:

  1. amazon search orders - search or open (keyword trigger "azo"):
    • If I passed in an arg, then search it with amazon order's search (with search url), else open amazon orders page (order's page url)
    • AND, If am holding cmd, then open whatever in chrome, else in firefox
  2. prime video - open or search (keyword trigger "pv"):
    • If I passed in an arg, then search it with amazon prime video, else open prime video home page
    • AND, If am holding cmd, then open whatever in chrome, else in firefox

 

 

The entire pipeline between the trigger and "Open URL" is almost the same for both the workflows, except setting variables in the args. work link: https://www.dropbox.com/s/cmkovpjix8mlyuc/Amazon Search.alfredworkflow?dl=0.

 

How do I reduce this duplication?

 

 

 

624026533_ScreenShot2021-11-26at2_28_57AM.thumb.png.61caebdef13075a138236c5b0e824df3.png

 

 

 

Edited by andy4222
Link to comment
30 minutes ago, andy4222 said:

How can I reduce this redundancy?

 

You could probably compress it all into one flow, with just a Keyword and an Arg & Vars per search if you add variables for your search and listing URLs and a JSON Config for your Open URL action.

 

But at some point, the answer has to be "implement your logic in code". Alfred's built-in components aren't really suitable for implementing complex logic.

Edited by deanishe
Link to comment
20 hours ago, deanishe said:

You could probably compress it all into one flow, with just a Keyword and an Arg & Vars per search if you add variables for your search and listing URLs and a JSON Config for your Open URL action.

 

I tried a few ways, but could not figure out what you recommended. Can you please elaborate a bit?

Workflow: https://www.dropbox.com/s/h91j62un0iauylq/Amazon Search.alfredworkflow?dl=0

 

 

 

 

Edited by andy4222
Link to comment
On 11/26/2021 at 2:53 AM, deanishe said:

You could probably compress it all into one flow, with just a Keyword and an Arg & Vars per search if you add variables for your search and listing URLs and a JSON Config for your Open URL action.

@deanishe Apologies for buzzing you again, but I still couldn't comprehend how to make it work ⬆️ way

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...