@T-N-T I think I know what might be causing the issue. The ?
character in whatsapp://send?phone=
needs to be escaped with a \
character. If it's not escaped, then the command won't work correctly.
Here's the full script:
async (clipboardContentString) => {
// remove whitespace, -, (, and )
let phoneNumber = clipboardContentString.replace(/[\s\-\(\)]/g, "");
// open whatsapp and escape the `?` character with `\`
let script = `/usr/bin/open whatsapp://send\?phone=${phoneNumber}`;
runShellScript({ script: script });
return phoneNumber;
};
I've been able to use this Keyboard Shortcut trigger & Transform Clipboard Contents with JavaScript action combination successfully with a verify of different phone number formats in Google Sheets.
[
{
"BTTActionCategory" : 0,
"BTTLastUpdatedAt" : 1730318371.1017189,
"BTTTriggerType" : 0,
"BTTTriggerClass" : "BTTTriggerTypeKeyboardShortcut",
"BTTUUID" : "8CF06DC7-72D3-4BC3-8148-E15B1DE788F1",
"BTTPredefinedActionType" : 366,
"BTTPredefinedActionName" : "Empty Placeholder",
"BTTAdditionalConfiguration" : "262145",
"BTTKeyboardShortcutKeyboardType" : 2302,
"BTTTriggerOnDown" : 1,
"BTTLayoutIndependentChar" : "v",
"BTTEnabled" : 1,
"BTTEnabled2" : 1,
"BTTShortcutKeyCode" : 9,
"BTTShortcutModifierKeys" : 262144,
"BTTOrder" : 1,
"BTTAutoAdaptToKeyboardLayout" : 0,
"BTTAdditionalActions" : [
{
"BTTActionCategory" : 0,
"BTTLastUpdatedAt" : 1730321104.0419459,
"BTTTriggerParentUUID" : "8CF06DC7-72D3-4BC3-8148-E15B1DE788F1",
"BTTIsPureAction" : true,
"BTTTriggerClass" : "BTTTriggerTypeKeyboardShortcut",
"BTTUUID" : "B06FB1AF-686C-44D6-B09F-82E1B481BE9E",
"BTTPredefinedActionType" : 448,
"BTTPredefinedActionName" : "Transform Clipboard Contents with Java Script",
"BTTAdditionalActionData" : {
"BTTClipboardTransformerExampleInput" : "7 123 456-78-90",
"SelectedTransformerTab" : 1,
"BTTClipboardTransformerJS" : "async (clipboardContentString) => {\n \/\/ remove whitespace, -, (, and )\n let phoneNumber = clipboardContentString.replace(\/[\\s\\-\\(\\)]\/g, \"\");\n\n \/\/ open whatsapp and escape the `?` character with `\\`\n let script = `\/usr\/bin\/open whatsapp:\/\/send\\?phone=${phoneNumber}`;\n\n runShellScript({ script: script });\n\n return phoneNumber;\n};\n"
},
"BTTGenericActionConfig" : "phone_number_to_whatsapp",
"BTTKeyboardShortcutKeyboardType" : 0,
"BTTEnabled" : 1,
"BTTEnabled2" : 1,
"BTTShortcutKeyCode" : -1,
"BTTOrder" : 3,
"BTTAutoAdaptToKeyboardLayout" : 0
}
]
}
]
I hope this helps.