You can make a difference in the Apple Support Community!

When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.

Looks like no one’s replied in a while. To start the conversation again, simply ask a new 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 Jun 10, 2012 8:50 AM

Reply
Question marked as Top-ranking reply

Posted on Jun 10, 2012 10:20 AM

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

4 replies
Question marked as Top-ranking reply

Jun 10, 2012 10:20 AM 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 1:25 PM 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.

Automator if-then-else possible?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.