SMS Notifications - Twilio Transport - Alert Template Conditional Formatting

I am trying to change the content of notifications received via SMS (Twilio transport). The plan is to recieve html to email and more plain text to sms. Both sent out at the same time.

So far I found out that conditional formatting is the way to achieve this.

The SMS and email get delivered, but the content in the SMS completely ignores any changes to the template.

The SMS I receive is either:

Alert for device 192.168.1.1 - Devices up/down

or

Device 192.168.1.1 recovered from Devices up/down

I want to add more info to the SMS, like $alert->hostname, $alert->sysName, $alert->timestamp…etc.

According to the docs here: Templates - LibreNMS Docs
…thy syntax is:

@if ($alert->transport == mail) Content
@else
Other transport content
@endif

If I use double = the template can not be saved, says “Template failed to be parsed, please check the syntax”. So I am using single =. This already might be an issue? Is the docs example wrong here or is my LibreNMS installation wrong?

I tried all kinds of options and now I reduced my testing to the most basic content:

@if ($alert->transport = twilio) Send me this sms.
@else
{{ $alert->hostname }}
@endif

In this example I get “Send me this sms.” on my email. And the SMS is the same as mentioned in the beginning of this topic.

My suspicion is that this ($alert->transport = TRANSPORT_TYPE) gets ignored, and for some reason ($alert->transport == TRANSPORT_TYPE) does not work - cannot be parsed. I also tried @if ($alert->transport_name == Twilio) and its the same behaviour.

Note: If I create a completely separate alert rule and separate template (without the @if ($alert->transport = twilio) ) and only include the twilio transport the SMS content also does not change.

Any ideas what I am missing here? Is the twilio sms template defined somewhere else and the docs are out of date on this?

Any help or hint in the right direction appreciated.

LibreNMS Version: 1.55-23-g565833a

Got the solution on discord from user: jozefrebjak, posting here if it helps anyone else:

it’s because of the code in /opt/librenms/LibreNMS/Alert/Transport/Twilio.php, where is specified that text => obj[‘title’] so you are getting title of the alert and not a text, just change it to $obj[‘msg’] and you will get a text from alert tamplate