Yes! Now Home Assistant can send WhatsApp Text Messages thanks to the CallMeBot Free API. You just need HA to execute a WGET or CURL command to send WhatsApp Messages. Find below the step-by-step instructions to implement it.

Setup:

You need to get the apikey form the bot before using the API:

1. Add the phone number +34 621 34 22 27 into your Phone Contacts. (Name it it as you wish)

  1. Send this message "I allow callmebot to send me messages" to the new Contact created (using WhatsApp of course)
  2. Wait until you receive the message "API Activated for your phone number. Your APIKEY is 123123" from the bot.
    Note: If you don't receive the ApiKey in 2 minutes, please try again after 24hs.
  3. The WhatsApp message from the bot will contain the apikey needed to send messages using the API.

You can send text messages using the API after receiving the confirmation.

Example:
58

5. Enjoy

5. Note, If you need any of the capabilities listed below, please check https://textmebot.com (low cost) or https://www.twilio.com/ (best official provider)
    - Send messages to others
    - Send messages to Groups
    - Send messages from your whatsapp number
    - Send Images
    - Send Buttons
    - Send documents
    - Receive the answers

How to send a WahtsApp message using the API:

You need to use the following URL:

https://api.callmebot.com/whatsapp.php?source=HA&phone=[phone]&apikey=[apikey]&text=[text]

Parameters:
[phone] is the destination phone number to send the message (For example: +34123123123)
[apikey] is the apikey that you received in the step 4 above
[text], is the message that you want to send. You can encode the URL (i.e. %20 istead of space, %0A for new lines) or use the symbol "+" for the spaces. WhatsApp formatting characters are allowed (i.e "*" for bold, etc.)

For example, to send the WhatsApp text message "Alarm from HomeAssistant to inform you that the alarm has been triggered" to the phone number +34 123 123 123, the URL will be:

https://api.callmebot.com/whatsapp.php?source=HA&phone=+34123123123&apikey=987654&text=Alarm+from+HomeAssistant+to+inform+you+that+the+alarm+has+been+triggered

And you can GET the URL with wget like this:

wget "https://api.callmebot.com/whatsapp.php?source=HA&phone=+34123123123&apikey=987654&text=Alarm+from+HomeAssistant+to+inform+you+that+the+alarm+has+been+triggered"

To do that in Home Assistance is pretty easy! You have two (or more) different ways to do it:

Instructions (OPTION 1): Using the HA Command Line Notify Component:

1) Create a "Command Line Notification" component in the configuration.yaml:

# Example configuration.yaml entry 
notify:
  - name: WhatsApp
    platform: command_line
    command: 'wget $(cat) -O /dev/null'
In this example, $(cat) is used to receive the URL from the scrip or automation that is calling to "WhatsApp" Notify Component and passing the message (url) as STDIN. You can also use command "curl" instead of "wget"
 
 2) Use the notification component from a script or automation passing the full URL as "message"
...
action:
  service: notify.WhatsApp
  data:
    message: 'https://api.callmebot.com/whatsapp.php?source=HA&phone=+34123123123&text=This+is+Home+Assistant+sending+you+a+WhatsApp+Message+to+you&apikey=456456'
 

Instructions (OPTION 2): Using the HA Shell Command integration:

1) Create the Shell Command in the configuration.yaml:

# Example configuration.yaml entry
shell_command:
  whatsapp: '/usr/bin/wget {{ url }} -O /dev/null'

In this example, the URL will be passed as a data template from the script or automation that is calling to this whatsapp shell command. You can also use the command "curl" instead of "wget"

2) Call to the Shell Command from script or automation

script:
  test_whatsapp_script:
    sequence:
      - service: shell_command.whatsapp
        data_template:
          url: 'https://api.callmebot.com/whatsapp.php?source=HA&phone=+34123123123&text=This+is+Home+Assistant+sending+you+a+whatsapp+message&apikey=456456'

Custom Activation Message & Answer with a dedicated bot

If you need a dedicated bot with custom activation message like "Please, send me reminders" (instead of the standard one) with a nice customized answer from the bot like "Got it! We will send you reminders by WhatsApp", please contact me at [email protected] to get a custom solution designed for you. You will have one single apikey to interact with the bot (send and receive messages)

Problems?

If you have problems, like not receiving the Call on Telegram, or not receiving the WhatsApp messages,  try to test the CallMeBot API using your Web Browser:

  • Telegram Phone Calls using Web Browser: here
  • Telegram Text Messages using Web Browsers: here
  • WhatsApp Text Messages using Web Browser: here

You might get some errors on the screen that will help you to identify the problem. (Ex: Calls disabled in the Telegram Security Settings, WhatsApp not activated, etc.)

If you still have problems using the API, don’t hesitate to contact me in Telegram @callmebot_com or by email at [email protected]. Remember to Follow me on Twitter to get news about coming features, changes, invitations, etc.