Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Question:

Question: Automator if-then-else possible?

Hi, I am trying to create a workflow that will monitor a web page and send me email if the page contains a certain keyword. I got it working, I get email; the email contains the keyword, or is an empty message when the keyword is missing.

I would rather not get these empty messages is possible. Until I figure this out, I may send these message at some gmail address and create a fiter there to forward only message with that keyword. Not elegant but should work. Anyway, long term I want a more elegant solution. Here is what I have in Automator:

1) Get Specific ULRs

2) Get Text from Webpage

3) Filter Paragraphs (and here is where I check whether the keyword shows up or not)

4) New mail message (which contains they keyword from #3, or is empty)

5) Send outgoing messages.

As I said, the workflow always works, and will send a message with that keyword, or an empty message. How do I make the workflow send email ONLY if they keyword is detected? There is not IF in Automator as far as I can see. This is the first time I try to do something in Automator so maybe I am missing something.

Thanks folks.


Mac OS X (10.6.8)

Posted on

Reply
Question marked as Helpful

Jun 10, 2012 10:20 AM in response to space-time In response to space-time

Automator doesn't have any control actions, so any comparisons you will need to do yourself. This is easy though, you can run a script after your Filter Paragraphs action to quit the workflow if the result is empty - for example, add a Run AppleScript action after the filter/before the new message and paste the following script into it:


onrun {input, parameters}



ifinputis {} thenerror-128-- cancel on empty input list



returninput

endrun

Question marked as Helpful

Jun 10, 2012 1:25 PM in response to space-time In response to space-time

The Run AppleScript action I posted quits the workflow (and thus skips the Mail bits), so if you are doing something like using the Loop action and waiting 15 minutes each time through, then it won't work. Is this run as an application, or is it a workflow run from Automator? I haven't seen anything that will conditionally execute an action, although there may be a way to enable/disable an action within Automator.

There’s more to the conversation

Read all replies

Page content loaded

Question marked as Helpful

Jun 10, 2012 10:20 AM in response to space-time In response to space-time

Automator doesn't have any control actions, so any comparisons you will need to do yourself. This is easy though, you can run a script after your Filter Paragraphs action to quit the workflow if the result is empty - for example, add a Run AppleScript action after the filter/before the new message and paste the following script into it:


onrun {input, parameters}



ifinputis {} thenerror-128-- cancel on empty input list



returninput

endrun

Jun 10, 2012 10:20 AM

Reply Helpful (1)

Jun 10, 2012 1:08 PM in response to red_menace In response to red_menace

Thanks a lot, will try this. I also put everything in a loop so I check said page every 15 minutes for example. Would this Applescript work thought, I want the loop to keep going all day long, and send email only when the keyword is detected. Anyway, I have now ideas to try.


Thanks

Jun 10, 2012 1:08 PM

Reply Helpful
Question marked as Helpful

Jun 10, 2012 1:25 PM in response to space-time In response to space-time

The Run AppleScript action I posted quits the workflow (and thus skips the Mail bits), so if you are doing something like using the Loop action and waiting 15 minutes each time through, then it won't work. Is this run as an application, or is it a workflow run from Automator? I haven't seen anything that will conditionally execute an action, although there may be a way to enable/disable an action within Automator.

Jun 10, 2012 1:25 PM

Reply Helpful (1)

Jun 10, 2012 1:45 PM in response to red_menace In response to red_menace

I saved it as an Application. I now have enough hints to try different ideas on my own later when I have time to work on this project. I know there are other ways to do this, but I wanted to see if ti can be done in Automator, thanks a lot for your helpful answers

Jun 10, 2012 1:45 PM

Reply Helpful
User profile for user: space-time

Question: Automator if-then-else possible?