Post event (HTTP) to custom item manager in plugin

Hi!

I have created a plugin that can manage events that came from the Background using the EnvironmentManager.Instance.SendMessage.

Now, I want to do that “communication” throught the REST API, but I dont know how to get the Id of the Event, I mean, check that when I retrieve the eventTypes I get the events from the custom item I created:

“displayName”: “Dev Active (MIP Device Status)”,

       "id": "04e51bba-dcd2-4a47-8aa6-2980326bb4c2",

       "name": "Dev Active (MIP Device Status)",

       "lastModified": "2025-01-03T15:35:21.1070000Z",

       "description": "",

       "generatorType": "MIP",

       "generatorSubtype": "",

       "generatorName": "Device Test Plugin",

       "generatorID": "9A8E41B1-70DF-4184-8407-6A92851DF3CF",

       "generatorGroupName": "MIP Device Status",

       "generatorGroupId": "cbe96f4d-f482-48d0-b00a-19b044652959",

       "occursGlobally": true,

       "builtIn": false,

       "counterEventID": "04e51bba-dcd2-4a47-8aa6-2980326bb4c2",

       "sourceArray": \[

           "MIPItem"

       \],

       "sourceFilterArray": \[

           "6a3061f1-31c0-40bc-8515-7c1b27ab2533",

           ""

       \],

       "stateGroupId": "2321526b-4630-497a-aa53-419ebdcd057c",

       "state": "Active",

       "relations": {

           "parent": {

               "type": "eventTypeGroups",

               "id": "cbe96f4d-f482-48d0-b00a-19b044652959"

           },

           "self": {

               "type": "eventTypes",

               "id": "04e51bba-dcd2-4a47-8aa6-2980326bb4c2"

           }

       }

But the trigger has different “”

{

"data": {

    "specversion": "1.0",

    "type": "06c5010d-11f2-4d70-bd79-4cec3a20d589",

    "source": "sites/514babee-ec9d-4339-9d63-780c6a469a16",

    "time": "2025-02-01T10:31:35.7282852Z",

    "id": "93ac93e4-6dbd-4cf9-9e36-e58bbded2d3a",

    "localId": 0,

    "datatype": "free-form"

}

}

So I dont know how to “link” the Id from the custom item and the trigger

How can I do it? Do I have to create and specific event in the configuration to manage it?

Thank you for your help!

Milestone Development have started an investigation, we will update here with information on what we find.

Hi Cristina,

I would assume that the received event in your example, is not the one you have triggered via MIP Message (NewEventCommand).

Mainly because (as you mentioned) the type differs (event type).

Please bear in mind that if you trigger events via MIP messages, you have to set the

MessageId

field of the EventHeader of the BaseEvent/AnalyticsEvent. This is the one that is seen as a Type later in the REST API.

If you don’t specify the MessageId, the type field would be null or empty Guid.

Therefore I believe your example is not about the event you have triggered via MIP Message.

Now to the main question - how such events, defined in the custom integration MIP plug-in, could be triggered via new REST API (aka POST).

And the simple answer is - there is not such way.

And that is a deliberate choice.

The idea is that they are plug-in defined and thus should only be allowed to be triggered from the plug-ins, in order to ensure that the source could be trusted.

And we are still in doubt, if we would like to change that.

If you want to POST (trigger) events via new REST API, I could offer you to use User Defined Events (UDE) or Analytics Events (AE). You could define (custom) types of them and use them according to your needs.

Hi Petar,

Thank you for your answer, I have realized that I considered as events the messages to do an internal communication between processes. I found in your documentation, correct me if I’m wrong, I have to use websockects to attach to receive/send messages (as this is the new aproach that comes to sustitute the EnvironmentManager.Instance.SendMessage which is going to be legacy?).

Hi Cristina,

you are right, MIP Messages and Events differs. Let me elaborate:

  • MIP Messages are fire and forget. Event could have retention and thus history is available.
  • MIP Messages are intended for easy communication (between environments) and integration. Ex passing info between two plugins - one in the SC (Smar Client) and another in EvS (Event Server).
  • Events represents “something happened into the system”.
  • Messages could be used for many other things - sending commands (like NewEventCommand), receiving responses, getting notification for “event” (NewEventIndication), sending custom messages (understandable only by particular integrations), etc.

Having that in mind and especially the multipurpose nature of the current MIP messages, you would understand why we consider decommissioning them at some point. They just became a Swiss knife - we are doing too many different things with them.

We imagine in the future we are going to have different communication channels, which to be single purposed (if possible).

Thus, we introduced new WebSocked messaging API, which we hope would be used for between environments (integrations) communication. Aka if you need to send messages between your plug-ins, this is a nice way doing it.

Resp if you need to use Event, there are dedicated APIs - Events REST API and Event WebSocket API.

You would choice what to use, depending on your needs.

P.S. We are still supporting current MIP Messaging. It is widely used. You could still use it as well.

Hi Petar,

Thank you for your quick answer, I have started preparing an example by myself to learn about websockets but I also realized that maybe I have taken another deadend but now that I read your message I think I’m not that wrong:

I’m trying to implement a plugin (MIP Plugin) with custom items (I’m using item and itemManager - taken from the SensorMonitor example in c#) that receive information about their state and changes their icon depending on the status given by a message received containing the status and all of it is shown in the Smart Client. The status is given by another service, I prefer not to use the “background plugin” so I can use NET8 and AWS.

When the “Status Service” needs to communicate to the MIP plugin, I use the publish (connect, start sending pulses and publish) to communicate and send the status messages.

Using to identify the messages

“topic”: “my-company.my-plugin.my-topic”

“id”: “3a564ea5-ef64-4215-9eba-9384f37489a6”

Then, in the ItemManager side.. using Init method create same websocket structure and use suscribe to be attached to Status Server Messages (with the common topic and id) (pulse and so on…), is that right?

Thank you for your help!

Hi Christina,

Sounds pretty much okay to me (as far as I understood it ofc :-)).

Actually, your example seems right into the point why we wanted to introduce yet another ‘MIP message like’ API. Namely to get rid of the SOAP and provide an easy way for external (protocol) integrations from services.