question

harsh avatar image
harsh asked

Custom Event Won't Trigger Action

POST /Server/WriteTitleEvent HTTP/1.1
Host: d5611.playfabapi.com
X-SecretKey: 
Content-Type: application/json
Content-Length: 139

{
    "EventName" : "transaction_finished",
      "Body" : {
          "Hook" : "https://webhook.site/0f49d79f-a73e-4f41-8718-53b7a5091c79" 
    }
}

I'm sending this from some online rest verifier.

The event is registered in PlayStream/Event History. This is the JSON:

{
  "EventName": "transaction_finished",
  "EventNamespace": "title.D5611",
  "EntityType": "title",
  "Source": "D5611",
  "EventId": "20a0bf2ebc3544bda24fe0d34e84a5d6",
  "EntityId": "D5611",
  "SourceType": "GameServer",
  "Timestamp": "2020-08-27T18:36:00.9677012Z",
  "PlayFabEnvironment": {
    "Vertical": "master",
    "Cloud": "main",
    "Application": "mainserver",
    "Commit": "2c5a25d"
  },
  "Hook": "https://webhook.site/0f49d79f-a73e-4f41-8718-53b7a5091c79"
}

The image attached is what my Rule looks like.

Finally, here's the cloudscript method.

var failedWebhookQueues = [];

handlers.syncTransactions = function (args, context) {
    let hook = context.playStreamEvent.Hook;
    if(!hook)
    {
        log.error("No response url.");
    }
    else
    {
        let content = {TxnId : "TX10222", Status: "Success"};
        server.WriteTitleEvent({EventName : "cs_ran_syncTransactions"});
        let hookResult = http.request(hook, "post", JSON.stringify(content) , "application/json", {owo, whats : this});
        let parsed = JSON.parse(hookResult);
        if(parsed.code !== "200")
        {
            failedWebhookQueues.Add(content);
        }
    }
    return {failedWebhookQueues, hook};
}

Any help would be appreciated.

TradingPlayStream
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

·
Citrus Yan avatar image
Citrus Yan answered

Currently, Rules only runs against player events, in your case, you’ d need to use WritePlayerEvent to generate the “transaction_finished” event and therefore being triggered by the rule. For more info, please see: https://community.playfab.com/questions/23695/playstream-rules-custom-event-name-wrong-or-rule-i.html?childToView=23864#comment-23864

10 |1200

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

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.