Commands
CLI WhatsApp
List a QwryAI agent's approved WhatsApp templates and send one to your contacts from the terminal
Use the WhatsApp tools to see which approved templates your connected numbers can send, and to send a template to one or more contacts as an Outbound campaign. Sign in first (see CLI Auth) and keep the agent's id in $AGENT (see CLI Agents).
Connect a WhatsApp number to your agent before you start; see WhatsApp in the user guide.
List templates
List the approved templates of the agent's first connected number:
qwryai-cli tools:call list_whatsapp_templates --args "{\"chatbotId\":\"$AGENT\"}"{
"success": true,
"data": {
"templates": [
{
"name": "order_shipped",
"language": "en_US",
"body": "Hi {{1}}, good news: your order {{2}} is on its way and should arrive by {{3}}. Reply here if anything looks wrong.",
"category": "UTILITY",
"parameters": 3
}
]
}
}parameters is how many {{n}} values the body takes. When the agent has more than one number, add "number" with the number as listed to read that number's account. A template can only be sent from a number on its own WhatsApp Business Account.
Send a template
Sending is done through Outbound, so it needs the Change actions and procedures permission and is reviewed before anything goes out.
- Find the sending number
qwryai-cli tools:call get_outbound --args "{\"chatbotId\":\"$AGENT\",\"page\":1,\"channel\":\"whatsapp\"}" | jq '.data.options.whatsapp.numbers'[{"id":"<numberId>","label":"Support · +1 415 555 2671"}] - Check what the number can send
qwryai-cli tools:call list_outbound_templates --args "{\"chatbotId\":\"$AGENT\",\"number_id\":\"<numberId>\"}"This lists each template's variables and, if one can't be sent, why.
- Prepare the send
Pick the contact by their phone number, email or name with
search, and send a template with no variables:qwryai-cli tools:call send_campaign --args "{\"chatbotId\":\"$AGENT\",\"channel\":\"whatsapp\",\"name\":\"Order 1042 shipped\",\"fromNumberId\":\"<numberId>\",\"template\":{\"name\":\"hello_world\",\"language\":\"en_US\"},\"replyBehavior\":\"ai_reply\",\"audience\":{\"mode\":\"all\",\"search\":\"+14155552671\",\"filter\":{\"conditions\":[]},\"excludedIdentifiers\":[]}}"The review shows how many contacts it reaches, who it skips and why, and the credits it costs: one per message.
- Send it
qwryai-cli apply <reviewId>
Send with variables
Give each template variable a value in mapping, keyed by component and number such as body:1. A value is either fixed text (static) or a contact field (contact), with an optional fallback for contacts who don't have it:
qwryai-cli tools:call send_campaign --args "{\"chatbotId\":\"$AGENT\",\"channel\":\"whatsapp\",\"name\":\"Order 1042 shipped\",\"fromNumberId\":\"<numberId>\",\"template\":{\"name\":\"order_shipped\",\"language\":\"en_US\"},\"mapping\":{\"body:1\":{\"type\":\"contact\",\"field\":\"name\",\"fallback\":\"there\"},\"body:2\":{\"type\":\"static\",\"value\":\"#1042\"},\"body:3\":{\"type\":\"static\",\"value\":\"Friday\"}},\"replyBehavior\":\"ai_reply\",\"audience\":{\"mode\":\"all\",\"search\":\"+14155552671\",\"filter\":{\"conditions\":[]},\"excludedIdentifiers\":[]}}"Use template.language to pick between language versions of the same template, and supply every variable list_outbound_templates reports. Add start_at with a date and time to schedule the send instead of sending now.
To reach a group rather than one person, leave search out and add filter.conditions, such as contacts with a tag: {"field":"tags","op":"has_any","values":["vip"]}.
Order automations
Read the automation that messages customers on WhatsApp when a Shopify order is created, with its rules, templates and fallback:
qwryai-cli tools:call list_whatsapp_automations --args "{\"chatbotId\":\"$AGENT\"}"Change it with save_whatsapp_automation and remove it with delete_whatsapp_automation; both are reviewed.
Commands
| Tool | Purpose |
|---|---|
list_whatsapp_templates | List a number's approved templates, with how many variables each takes |
get_outbound | Read the sending numbers and the agent's campaigns |
list_outbound_templates | List the templates a number can send as a campaign, with their variables |
send_campaign | Send a template to contacts (reviewed) |
get_outbound_campaign | Follow a campaign's recipients and delivery |
list_whatsapp_automations | Read the Shopify order automation |
save_whatsapp_automation / delete_whatsapp_automation | Change or remove it (reviewed) |