question

drew avatar image
drew asked

Hooking Rule onto custom entity event

I am trying to write a custom event using WriteEvents endpoint, and I want to add a Rule which triggers only when a CONDITION happens on that event.

I can see my new custom event appearing in the Rules UI screen, but I dont see any attribute values for the conditions? For example, I have a "Player_Opened_Pack" event, and I want a rule to trigger if the CardsOpened is equal to 5. I have tried writing CustomTags with a key = PacksOpened and the value = the number, but I dont see how I can use this key/value inside of the conditions text box? It's not appearing there, and there's no documentation demonstrating how to do this, but I suspect it's possible.

PlayStream
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Gosen Gao avatar image
Gosen Gao answered

Since the custom attributes are written in the Payload, so you can access the value you want with Payload.[Key]. You can refer to the Rule config below.

And here is the request body of WriteEvents API.

{
  "Events": [
    {
      "Entity": {
        "Id": "{
                {TitleAccountID}}",
        "Type": "title_player_account",
        "TypeString": "title_player_account"
      },
      "EventNamespace": "custom",
      "Name": "test_event",
      "Payload": {
        "Foo": "Bar"
      }
    }
  ]
}

vbvjl.png (29.8 KiB)
3 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

drew avatar image drew commented ·

thanks for sharing @Gosen Gao. What is the functional difference between Payload and PayloadJSON for WriteEvents?

0 Likes 0 ·
Gosen Gao avatar image Gosen Gao drew commented ·

There is not much difference here, just two ways to transfer the payload, using an object or using a Json string.

0 Likes 0 ·
drew avatar image drew Gosen Gao commented ·

thanks @Gosen Gao. Is there a log somewhere that shows when a trigger is actually fired?

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.