@Sam Michel As a heads-up alongside Vítor's response (for you and anyone else who comes across this thread), every workflow object has a question mark icon in the configuration, which will take you to the documentation for that specific object This is the best starting point for insight on configuring that particular workflow object!
Very handy script, but it stopped working for me with Mac OSX Mojave.
I found this alternative AppleScript which seemed to do the trick - just replaced the Run NSAppleScript section of the workflow and it works now:
#!/usr/bin/osascript
on alfred_script(q)
tell application "System Preferences"
reveal pane id "com.apple.preferences.Bluetooth"
-- activate
set the current pane to pane id "com.apple.preferences.Bluetooth"
try
tell application "System Events" to tell process "System Preferences"
click button "Turn Bluetooth Off" of window "Bluetooth"
click button "Turn Bluetooth Off" of sheet 1 of window "Bluetooth" of application process "System Preferences" of application "System Events"
end tell
delay 1
on error
tell application "System Events" to tell process "System Preferences"
click button "Turn Bluetooth On" of window "Bluetooth"
quit
end tell
end try
end tell
end alfred_script