Jump to content

Trying to make a workflow to send query to Grok


Recommended Posts

Posted

I'm trying to make a grok search in a workflow, basically type the keywords, space, and then whatever follows is sent to grok. I am not qualified to mess around with APIs, so I thought just opening the webpage https://x.com/i/grok/ and entering the text would be the easy approach. Given that I know nothing about workflows, I asked grok how to do this! It had a simple solution that almost works but I can't figure out why it isn't, and every time I tell grok what's happening, it complicates things. So here's where we started, and what does and doesn't work. Maybe someone here can tell me what's missing.

 

It's only three actions. Keyword, open URL, and a script.

 

Keyword

Keyword is simply this:

image.thumb.jpeg.40dd770eef7ce3c99680047a6a2aef31.jpeg

 

Open URL

Seems simple; this is it:

image.thumb.jpeg.02d39e5e6c14b9ebac413ccdbd83c5c3.jpeg

 

Run Script

Presumably this is where things go wonky:

image.thumb.jpeg.19b3e4b27c0d8f2c873360140aae9cad.jpeg

 

Now if I trigger the script, for example "x test", what happens is the https://x.com/i/grok/ page opens as expected, but the pasted search query is simply the end of the URL; it pastes "i/grok" into the "ask grok anything" field (which is, by the way, automatically in focus when that pages loads), instead of "test". 

 

Grok suggested changing the applescript to this, but then nothing at all happens when the webpage loads:

image.thumb.jpeg.db5248f146931bdcdaeaeb8529e1254e.jpeg

 

I've tried loads of other suggestions but I won't complicate this thread with those. Since the first one works except that it is pasting the URL instead of the argument, I figure that's the easiest to chase down.

 

thanks for any suggestions!

-Joseph 

Posted

There are a few places where the instructions led you astray, LLMs aren’t good for tasks which require accuracy and understanding. From your description, you shouldn’t need code at all to do what you want.

 

Connect your Keyword Input first to an Arg and Vars Utility and save your input to a variable. Then connect to the Open URL. Then use a Copy to Clipboard Output set to paste to the frontmost app with the variable you saved earlier. You may need a Delay Utility in there to wait for the page to load.

 

Even if you needed to fake typing, which you are unlikely to, that AppleScript would fail with things like diacritics. There is an Automation Task to fake type text which doesn’t have that issue (and again, no coding required).

 

See the Getting Started Guide for an interactive tutorial on making a workflow. There is further documentation on the website to follow up (tip: find help for any object fast by clicking the (?) icon while editing). You may also be interested in the YouTube channel, the Simple Ideas series of forum posts, or the learning workflows in the Alfred Gallery.

Posted

aha! That got it, thank you! Took a little digging but of course I learned a few things, and now it works! I'd attach it here but it seems I can't (it's not worthy of the gallery). Thank you for the help!

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...