How to skip 'Cancel' 'Continue' when running shell script with automator?
I'm not able to replicate your prompt issue if I code the sleepnow in a do shell.


Launch Automator
Go to File &gt; New
Select Service and click Choose
Select "No input" in drop-down list
Select in drop-down list "Any application"
Select "Run AppleScript" and double-click or drag and drop
Replace the script with a do shell
Save the service
Add service in keyboard




The code:

try
    display notification "Attempting sleep"
    delay 2
    set result to do shell script "pmset sleepnow"
on error result
    display dialog result
end try


The service with shortcut:



System specs:

macOS Sierra Version 10.12.6 on Macbook Pro