Line Notification

jemkewl3 months ago

Hello, I would like to be able to send a notification upon a Geofence condition to a Line group chat.

To successfully post a message to the group chat, the following can be used and works without issue:

curl -X POST -H 'Authorization: Bearer redacted' -F 'message=test' https://notify-api.line.me/api/notify

In an effort to use the sms notification configuration, the following was tried. Any tips on how to troubleshoot further?

    <entry key='notificator.types'>web,mail,sms</entry>
    <entry key='sms.http.url'>https://notify-api.line.me/api/notify</entry>
    <entry key='sms.http.authorizationHeader'>Authorization: Bearer redacted</entry>
    <entry key='sms.http.template'>{message}</entry>

Setting the error logs to all or warning did not produce anything I was able to find when clicking "Test Channels" with the SMS channels notification selected for the Geofence Notification.

Anton Tananaev3 months ago

Your sms.http.authorizationHeader value doesn't make sense. And your sms.http.template value doesn't match your CURL request, which also doesn't make sense to me.

jemkewl3 months ago

Appreciate the response Anton!

I could not find any details in the logs to understand what was being constructed or posted by Traccar when I clicked "Test Channels" to troubleshoot further. I tried numerous permutations of the configuration before posting. This was the original I had tried which I thought would make the most sense.

    <entry key='notificator.types'>web,mail,sms</entry>
    <entry key='sms.http.url'>https://notify-api.line.me/api/notify</entry>
    <entry key='sms.http.authorization'>Bearer redacted</entry>
    <entry key='sms.http.template'>message=test</entry>

Can you help me understand how to construct that curl message with the sms entries or where I can see what Traccar is creating in the logs upon "Test Channels" to be able to reverse into what the configuration should be?

Anton Tananaev3 months ago

This version makes sense to me. I don't think you can see it in the logs, but you can either debug the code or point it to some service to capture the request.

jemkewl3 months ago

Appreciate the prompt response!

Utilizing webhook.site, the traccar configuration was modified and traccar service was restarted.

    <entry key='notificator.types'>web,mail,sms</entry>
    <entry key='sms.http.url'>https://webhook.site/61f16429-cb05-4321-afaf-af94fd87d136</entry>
    <entry key='sms.http.authorization'>Authorization: Bearer abc</entry>
    <entry key='sms.http.template'>message=testing</entry>

This curl works well from the traccar server and the webhook.site is able to capture the request and act as a service to capture the request.

curl -X POST -H 'Authorization: Bearer abc' -d 'message=testabc' https://webhook.site/61f16429-cb05-4321-afaf-af94fd87d136

Unfortunately, upon clicking "Test Channels" or by moving devices in and out of a Geofence, the call to https://webhook.site/61f16429-cb05-4321-afaf-af94fd87d136 is not happening or making it to the site.

Success of the manual curl can be viewed here: https://webhook.site/#!/view/61f16429-cb05-4321-afaf-af94fd87d136/48f0e3bb-b7d7-4f8c-8d30-25b58c458184/1

Anton Tananaev3 months ago

The sms.http.authorization should be just Bearer abc. But otherwise it should work fine, as far as I can tell. Maybe something is blocking requests from your server, like firewall for example?

jemkewl3 months ago

Thanks! Made that change:

    <entry key='notificator.types'>web,mail,sms</entry>
    <entry key='sms.http.url'>https://webhook.site/61f16429-cb05-4321-afaf-af94fd87d136</entry>
    <entry key='sms.http.authorization'>Bearer traccarxmltest</entry>
    <entry key='sms.http.template'>message=testing</entry>

No difference in observation.

There were no blocks observed from the firewall. Am able to execute the curl command from the traccar server.

jemkewl3 months ago

Since the traccar logs do not have a record of the attempted sms invocation, Wireshark traces were attempted.
Upon clicking Test Channels, there is still no evidence the post to the webhook.site is occurring. Still trying to troubleshoot on if the calls are being made since there is not evidence of a drop / block.

The configuration is quite simple with webhook.site - is anyone else able to try and see if the call is made?

Anton Tananaev3 months ago

Can you show a screenshot of the screen.

jemkewl3 months ago

Are these the screenshots that would help?

Device connections:
Screenshot_20240902_133826_Brave.jpg

Notifications:
Screenshot_20240902_133746_Brave.jpg

Anton Tananaev3 months ago

And you restarted the service after configuration change, right? No other ideas.

jemkewl3 months ago

Yessir! Restarted the service after the config change.
Appreciate the help and ideas - any way to get the sms details logged in a future release if debug / all is turned on?

Anton Tananaev3 months ago

If you enable debug logs, I'm sure you should see something if it is sent. But I suspect it doesn't send it. And just to confirm another obvious thing. You have a phone number on the account, right?

jemkewl3 months ago

Ah - perhaps this is the issue and is all my fault.

I probably understood incorrectly. I thought the sms feature could be overriden / overloaded to call a web-based endpoint. For this use case, I wanted traccar to hit an endpoint via a direct web Post.

No phone number is required for this notification service. A Post to the endpoint shared previously is all that is needed. The header bearer token authenticates and redirects the message to the proper Line chat.

Is this use case not supported?

Anton Tananaev3 months ago

You can call any endpoint, but you have to set something as a phone number.