Email Automation

So I’m trying to setup an automation that will process emails that meet certain criteria. A specific URL will be extracted. There are two possible situations when the URL is opened:

  1. it will directly open a PDF that needs to be downloaded to a DEVONthink inbox, or

  2. it will open a webpage that gives the option of either downloading several PDFs individually, or selecting a “Download All” button that will download all of the PDFs in a .zip file. In this case I need to select the Download All button and then extract the .zip contents into the DT Inbox.

Where I’m at:
I’ve got an Automator workflow/service that processes the email and extracts the correct URL. If only situation 1 was possible, an Automator action could easily download the PDF that the URL points to into the DT Inbox. But situation 2 throws a wrench. And I don’t think there is a way to setup an if/else within Automator for each use case.

I need to figure out the best way to accomplish situation 1 or 2 at this point. I figure KM is my best bet. But if anyone thinks there is another, better way to get this done, I would love to know.

Does anyone have any ideas for how I can take the URL that is extracted by Automator to accomplish both 1 and 2?

Thank you in advance for any help or suggestions!!