Power outage using card-voltage with twillio sms

Hi, Im trying to set up a power outage similar to Cellular-Enabled Power Outage Detector w/ SMS Notifications - Hackster.io but using the new card-voltage option.

I can seen both
_health.qo {“text”:“USB power OFF {usb-disabled}”}
_health.qo {“text”:“USB power ON {usb-enabled}”}


I have also _health.qo to twillio and can receive sms when i populated the message filed with any field.

Cant seem to work out how to set the jsondata query in filter to receive in the msg body when the power is on/off depending on the condition.

Thanks in advance. any support is appreciated!

Hi @pitecantropo,

In your Twilio SMS route within Notehub, scroll to the bottom and you’ll see the Transform Data section. You can use a JSONata Expression to customize the SMS here:

This is the expression that I’ve been using (from our accelerator app):

    $alertMessage := function($e, $nodeID) {(
        $texts := [
            {"text":"USB power OFF", "msg":"ALERT! Power has failed to device "},
            {"text":"USB power ON", "msg":"Power restored to device "},
            {"text":"brown-out", "msg":"Power restored (LiPo battery discharged) to device "}
        $findPowerStatus := function($text, $index) <sn:s> {(
            $index >= $count($texts) ? "" :
                $contains($text, $texts[$index].text) ? $texts[$index].msg : $findPowerStatus($text, $index+1);
        $msg := $findPowerStatus($.body.text, 0);
        $result := $msg ? { "customMessage": $msg & $.best_id & "."} : {};
    $additional := $alertMessage($);
    $additional.customMessage ? $merge([$, {"body": $merge([body, $additional])}]) : $doNotRoute($);

Hi Rob,

Would the “Message” input in twillio settings be left blank?


I find that if I leave it blank

get the following error:
error building route request: error validating twilio message: %!w(), got that also from the expression you shared.

Sorry. Just understood.

added [.body.customMessage] the message guide and can now see both loss and restore sms!!!

Thanks again for your time and patience : )