Running AppleScript copied from action got an error.

  1. Do "Copy Apple Script to Trigger Action" with "Use ChatGPT (Optionally on Selected Text). Copy Result to Clipboard / Variable."
  2. Run it.
  3. Get error:
execution error: BetterTouchTool got an error: AppleEvent handler failed. (-10000)

I prefer this "trigger_action" over "chat_gpt" since it has BTTAdditionalActionData, but it doesn't work anyway. Is this supposed to not work? Running the AppleScript in both in the BTT app action and outside of BTT fails.

tell application "BetterTouchTool"
trigger_action "{
  BTTActionCategory: 0,
  BTTIsPureAction: 1,
  BTTPredefinedActionType: 471,
  BTTPredefinedActionName: 'Use ChatGPT (Optionally on Selected Text). Copy Result to Clipboard  or  Variable.',
  BTTAdditionalActionData: '{\\\"BTTChatGPTTransformerShowMiniHUD\\\":0,\\\"BTTChatGPTTransformerExampleInput\\\":\\\"\\\",\\\"BTTChatGPTUseStreaming\\\":true,\\\"BTTChatGPTKeepSelectedText\\\":0,\\\"BTTChatGPTNumberOfHistoryItems\\\":0,\\\"BTTChatGPTTransformerUserPrompt\\\":\\\"write a short story\\\",\\\"BTTChatGPTTransformerSystemPrompt\\\":\\\"\\\",\\\"BTTActionPasteInputFormat\\\":\\\"public.utf8-plain-text\\\",\\\"BTTChatGPTAppendSelectedText\\\":0,\\\"BTTChatGPTCopyResponseToVariableName\\\":\\\"gpt_response\\\",\\\"BTTChatGPTCopyResponseToClipboard\\\":0,\\\"BTTChatGPTCopyResponseToVariable\\\":true,\\\"BTTChatGPTModelSelection\\\":\\\"gpt-4o-mini\\\"}',
  BTTEnabled2: 1,
}"


end tell

Device information:
Type of Mac: MacBook Pro 16-Inch, 2019
macOS version: 15.2
BetterTouchTool version: 5.157

Same error on 5.160

This is some sort of weird escaping issue, unfortunately it's hard to do this automatically for Apple Script, BTT tries to cover most cases but something here fails.

//edit: ah actually it might be something different because BTT tries to get a custom api key from the keychain but can not access the keychain api key when called from apple script at the moment. I'll think about whether I can fix this.

// might be working with 5.163 alpha

Thank you.
I look forward to it :slight_smile:

It is working on 5.164🔥
Now I can use variables in the prompt.
Thank you so much.

I think the prompt also allows variables when used from the UI, you need to place them in curly braces.

1 Like