This example demonstrates how the AppBlocks Cloud and its Workflows feature can be used to be notified on WhatsApp when some event occurs on a device connected to the cloud.
Here we assume you have set up a WhatsApp Business account with a phone number, id, bearer token and a message template to send messages via the WhatsApp API. Head over to the WhatsApp Business API website to get started.
Before you run the project provided with this example on your device, you need to associate the device with an AppBlocks Cloud Device. You can simply do this in the AppBlocks Designer by clicking on the 'Create' button in the prompt showing at the bottom right corner of the screen when you open the designer. Toggle the Cloud feature to Disabled then back to Enabled in the Features => AppBlocks Cloud section of the designer if you do not see the prompt.

Once the device is created, the Designer should have filled the Device ID and Device Password for you.

You can now run the project on your device. In another browser tab, head over to the Devices section of the AppBlocks Cloud. You should see your device listed there, with the green status icon indicating that it is online and connected.

Moving on to the Workflows section, create a new workflow and give it a name. You should now see a blank canvas similar to the the AppBlocks section of the AppBlocksDesigner. Workflows are simpler in that they only consist of one trigger and a chain of actions executed linearly.

In edit mode, set the trigger to Device Event. Our workflow will indeed be triggered when our device adds an entry to its Event Log.

To receive the message on WhatsApp, we will use the HTTP Request action. The parameters are straightforward if you are familiar with HTTP requests. In this case, we want to send a POST request that creates a message from a message template we named 'workflow_whatsapp_notification' that expects three parameters to one recipient. Note that to make the request work, you need to fill in your own Phone Number ID, recipient phone number and access token as shown in the screenshot below. You can find more information in the WhatsApp API documentation.

Before saving, we will move to the Settings tab to both enable the workflow and allow it to be triggered more than once.

Once the worklow is saved, let's finally add an entry to the device's Event Log by pressing the MD button on the device and see the magic happen:

Last, the Runs section of the workflow can also be used to see the history of the workflow runs and to get useful information about the actions and the device state when the workflow was executed.
