Webhook to Events API

Hi,

From an offsite Milestone I’m pushing a Webhook back to our Headend Milestone to ideally trigger a rule. I can see the webhook via Wireshark and can capture using node.js but not sure how to get it into the Milestone Events API. I also can’t do a Generic Event because its JSON HTTP but not TCP to capture it. (all on our own VPN not connected to the internet)

Looking for some help or even a developer to help me build this out.

Thanks,

Bryan

**Hi @Bryan P**​ ,

Webhooks use HTTP(S), so they should be able to trigger the Events API as long as you have a valid auth token. However, you mentioned TCP, which makes me think you might be referring to a WebSocket instead of a webhook.

If your communication is over raw TCP, I would suggest creating a middleware/controller in Node.js to:

  1. Capture and read the incoming TCP stream.
  2. Convert the TCP message into JSON.
  3. Trigger the Events API with the formatted JSON data.

Since you’re using Node.js, try capturing and parsing the TCP stream, then make an API call to the Events API to see if it works as expected.

Hi @Xavier Julies

Thanks for replying!

The Webhook is being pushed from another milestone server via a rule triggered by camera action.

I would like to capture this at our headend and that is what I’m having trouble with. Should I just see the entries come into the Event server (if so how) or should they be a generic event but that needs to be TCP I imagine.

If it can’t work low code perhaps you could point me in the direction of a Milestone Dev happy to scope out this work.

Hi @Bryan P​ ,

To clearly understand your intent:

Your camera is triggering a rule within Milestone, and you want to capture this event. Once captured, you intend to send the event to your headend, which expects communication over TCP.

If this is accurate, I recommend exploring WebSocket, which can listen for your events: https://doc.developer.milestonesys.com/mipvmsapi/api/events-ws/v1/#section/Events-and-State-WebSocket-API/Introduction.

Alternatively, based on my previous experience, you could create a background plugin that runs on the event server. This plugin would listen for all events and, when triggered, send the event to your headend via TCP or HTTP(S).

Let me take a step back.

Using the Milestone Webhook function can I push that to ANOTHER Milestone environment for it to come up as an event or alarm I can action as a rule?

Hi @Bryan P​ ,

I haven’t tested this but have a look at https://doc.milestonesys.com/latest/en-US/add-ons/add-on_webhooks/create_webhooks.htm. Perhaps this would be more helpful in answering your question.

Milestone XProtect Webhook functionality allows you to configure that upon event the XProtect sends a webhook.

Milestone XProtect does not have to functionality receive and use incoming webhooks.

I guess that this means webhooks cannot be used to push information from one XProtect site to another.

But looking at it differently: If you as a developer would like to develop an integration that makes events in a XProtect site it is possible. The source or trigger for those events could be anything, even webhooks originating from a Milestone XProtect or somewhere else.

I recommend one of these methods if you want to raise events…

https://doc.developer.milestonesys.com/mipvmsapi/api/events-rest/v1/#tag/Events/operation/Events_Post

https://doc.developer.milestonesys.com/html/index.html?base=samples/protocolsamples/triggeranalyticseventxml/readme.html&tree=tree_3.html

https://doc.developer.milestonesys.com/html/index.html?base=samples/componentsamples/analyticseventtriggervialibrary/readme.html&tree=tree_2.html

Thanks Bo.