Agent Deck

GuidesWhatsApp

Connect WhatsApp

Agent Deck reads new messages to you from WhatsApp for Mac's own files on your Mac, without ever changing them, and hands them to your sessions like mail. Sessions send from your account through a shortcut you make once in the Shortcuts app. There is no WhatsApp API and no business account involved.

Time
About 10 minutes
You need
WhatsApp for Mac, linked to your phone, and the Shortcuts app (it comes with macOS)
Costs
Nothing at WhatsApp

Reading new messages

Step 1: Install WhatsApp for Mac and link it

  1. Install WhatsApp from the Mac App Store, or from whatsapp.com/download. It has to be the Mac app: WhatsApp in a browser keeps nothing on the Mac to read.
  2. Open it and link it to your phone: on the phone, in WhatsApp's settings, Linked devices, Link a device, and scan the code on the Mac.
  3. Wait until your chats have loaded on the Mac.

Step 2: Let Agent Deck read WhatsApp's files

  1. In Agent Deck, open Settings (⌘,), then Connections, Add a connection and WhatsApp.
  2. If macOS asks whether Agent Deck may access data from other apps, click Allow.
  3. Your chats appear under Chats.

Step 3: Choose what is read

  1. Tick Read new WhatsApp messages.
  2. Leave the mode on Watch only for a day: it only logs where each message would have gone (Routing rules… shows the log). Then switch to Live: hand messages to sessions.
  3. Under Chats, direct chats are read and groups are not. Set a chat to Never read and it is never even opened; set a group to Read to have it read.

A chat's messages go on together after a minute of quiet. Deciding where they go needs your Spikefrost account, signed in under Settings › Account: their text is sent to Agent Deck's decision service.

Sending

Sessions send through a shortcut of yours named Deck WhatsApp Send. Agent Deck runs it with two values, To (a phone number with + and the country code) and text, and it hands them to WhatsApp's own Send Message.

Step 4: Add the shortcut

  1. On Agent Deck's WhatsApp page, under Sending, click Add the Shortcut…. (It shows while no shortcut of that name is found.)
  2. Shortcuts opens and shows Deck WhatsApp Send. Click Add Shortcut.
  3. Within a few seconds Agent Deck says Found in Shortcuts.

It is a ready-made copy of the shortcut below, signed by Apple, with nothing in it but these steps. You can open it in Shortcuts to look before you send anything.

The shortcut, from top to bottom
Get dictionary from  Shortcut Input
Get  Value  for  To    in  Dictionary
Get dictionary from  Shortcut Input
Get  Value  for  text  in  Dictionary
Send  [Dictionary Value: text]  to  [Dictionary Value: To]   (WhatsApp)

Or make it yourself

  1. Open Shortcuts and choose File › New Shortcut (⌘N).
  2. Click the name at the top and call it exactly Deck WhatsApp Send. (Another name works too, if you type it in Agent Deck's Sending field.)
  3. In the search field of the actions on the right, type Get Dictionary from Input and add it. It reads Get dictionary from Shortcut Input.
  4. Add Get Dictionary Value. Make it read Get Value for To in Dictionary: click Key and type To, with a capital T.
  5. Add Get Dictionary from Input again, so it reads the Shortcut Input once more.
  6. Add Get Dictionary Value again, this time for the key text, all small letters.
  7. Search for Send Message and add the one from WhatsApp (it shows WhatsApp's logo), not the one from Messages.
  8. In it, set the message to the Dictionary Value of the text step, and the recipient to the Dictionary Value of the To step. To pick a step's value, Control-click the field, choose Select Variable, and click that step's result.
  9. Close the window: Shortcuts saves as you go.

Step 5: Try it once, and allow it

Run it once from Terminal with your own number (WhatsApp's chat with yourself), so that you answer any question macOS or WhatsApp asks the first time, rather than a session meeting it later.

Terminal
printf '{"To":"+441234567890","text":"Test from Agent Deck"}' > /tmp/deck-wa-test.json
shortcuts run "Deck WhatsApp Send" --input-path /tmp/deck-wa-test.json
rm /tmp/deck-wa-test.json
  • Put your own number in place of +441234567890: + and the country code, then the number.
  • If you are asked whether the shortcut may send messages with WhatsApp, choose Always Allow.
  • The message shows up in your chat with yourself within a few seconds.

Step 6: Check it in Agent Deck

On Agent Deck's WhatsApp page, under Sending, the shortcut's name is followed by Found in Shortcuts. Sessions can now send to a phone number with the country code, or to the name of a direct chat or contact. Sending to groups is not supported yet.

After each message, Agent Deck looks for it in WhatsApp and tells you if one did not land as sent.

If something goes wrong

Agent Deck says the shortcut is “Not in Shortcuts yet”
The names differ. Rename the shortcut to Deck WhatsApp Send, or type its exact name in the Sending field.
The test runs, but nothing is sent

Check that the Send Message action is WhatsApp's, not Messages', and that the keys are exactly To and text. The ready-made shortcut (step 4) has all of this right.

WhatsApp for Mac must be signed in; it does not need to be in front.

The message went to the wrong chat, or the number was sent as the message
The two values are swapped in Send Message: the text goes in the message, the To value in the recipient.
“It has not shown up in WhatsApp on this Mac within 15 seconds”
The shortcut finished, but Agent Deck could not find the message yet. Look in WhatsApp before sending it again: it may still arrive, or WhatsApp may have asked something on screen.
“WhatsApp has changed how it keeps its chats”
A WhatsApp update changed its files. Nothing is read until Agent Deck is updated for it.
A number is refused
Give it in international form: + and the country code, then the number (for example +44 20 7946 0000).

What is read, and where it goes

WhatsApp's files are only read, each time opened and closed at once, and never changed. Chats set to Never read are never opened. A new message's text goes to Agent Deck's decision service only to decide where it goes, and then to the sessions it is handed to. Your shortcut runs on your Mac, and the message goes out through WhatsApp itself.