Triggers, Webhooks, Templates, and what's available

I am just getting started with my AutoPi, and I am a bit frustrated with the lack of specific documentation regarding webhooks and triggers… only a repeated link to a “tutorial” that is really light on details.

From that “tutorial” it is evident that this webhook is possible:

  • Payload: {“text”: “{{ trigger[‘description’] }} was executed, by device: {{ trigger[‘device’][‘callName’] }}”}

That’s great. Now I know that there is a hash (dict? i’m not strong on python) called trigger that is available.

  • Well, what else is in there that I can leverage?
    the {{ }} tells me that Jinja-type templating is available. GREAT… but what can it access?
  • How can I find out the lat, lon that event took place? or sample other key/values to emit something a webhook of data like “you’re vehicle stopped at ,, and you’re fuel here was % and battery was at volts” ?
  • Other than the Trigger data itself, how can I get at the other data?

I was hoping to be able to use these triggers to cause “things to happen” by passing on the events to a receiver on my server, but if the events can’t contains the data I need, then there’s not going to be value in the webhooks being sent…

I appreciate any insight here!

Thanks!

@Nikola - any insight here as to what {{ }} items are available, or how we can determine that, to use in webhooks?

Hi @d2inco.

We’re going to update the guide you’re referring to (link) with some more documentation on the available fields that you can use. Once the guide has been updated (should be in the next few days), we will let you know.

Best
Nikola

Great! I’ll keep an eye out! I’ve got ideas churning in my mind for how to use this!

Thanks Nikola!

Hi David.

We’ve updated the triggers guide with some more information on what fields can be used.

Best
Nikola

1 Like

I just did a quick look, and will have to dive deeper later…

but I do not see that the vehicle-position data is available at all? How can this be? The device surely has to know where it’s “at” if it is logging it every 5 seconds, so, why can this not be accessed within the webhook template?

(or, if I missed it because I am reading too fast this morning, I apologize!)

Thanks!

Hi.

Yes, you’re correct. Unfortunately, it’s currently not possible to get the current location of the device from a trigger. This is because, GPS data isn’t being passed to the trigger. However there is plans on adding this in future iterations.

Best
Nikola

Hello… So I was finally able to get out for a drive and test this.

It seems like the “Device” “Model” and “Make” data is not really exported, but is only implied by the presence of the “device: Device” item in the trigger."

So it seems like you just expanded the docs on the two items ‘trigger’ and ‘event’ but didn’t indicate that there are any other values/structures that can be accessed… Really, none at all?? Am I understanding this right now? What about the other data being colected by any loggers that I turn on? That data is not available either?? Nothing??

My current webhook I’m testing with is:

{ "event": "{{ event }}",
"track":" {{ track | default('no-track-data') }}", 
"tracking":" {{ tracking | default('no-tracking-data') }}",
"trigger":" {{ trigger | default('no-trigger-data') }}",
"Device":" {{ Device| default('no-Device-data') }}",
"Profile":" {{ Profile | default('no-Profile-data') }}",
"Model":" {{ Model | default('no-Model-data') }}",
"device":" {{ device| default('no-device-data') }}",
"profile":" {{ profile | default('no-profile-data') }}",
"model":" {{ model | default('no-model-data') }}"
}

which only emits the ‘event’ and ‘trigger’ fields, with the rest indicating ‘no data’.

So, really… Just the event and trigger and nothing else?

Hi.

Yes, unfortunately, we haven’t implemented this functionality yet. The data that’s being logged is being sent to our backend servers to be processed but not sent as data to the triggers. There are plans in the future to update triggers and include that functionality.

You can get the Device, Profile, Model and Make fields through the trigger field. You can do so by typing in

{
    "device": {{ trigger['device'] }},
    "profile": {{ trigger['device']['vehicle'] }},
    "model": {{ trigger['device']['vehicle']['model'] }},
    "make": {{ trigger['device']['vehicle']['model']['make'] }}
}

Best
Nikola