question

Deekshith avatar image
Deekshith asked

Trigger Cloudscript/Azure function on statistic reset

I want to trigger a cloudscript/azure function when a statistic version is changed/resetted.

This function has to be called exactly once and it should be instantly called as statistic gets resetted as it will do some things which should not be called more than once.

How can this be achieved?

CloudScriptLeaderboards and Statistics
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

·
Sarah Zhang avatar image
Sarah Zhang answered

Playfab does not support to trigger any native PlayFab action by the title-level PlayStream events, such as title_statistic_version_changed event. But you can consider using PlayFab Webhook to trigger an Azure function by title-level Play Stream Events. Webhooks allow you to have some or all of your PlayStream events forwarded to any web URL you want. The event data is sent via POST in the request body as JSON. So you can add a custom Http trigger function to your Azure function app. Then you can create a new PlayFab Webhook, let it forward the title_statistic_version_changed event to this Http trigger function to trigger something. If you use Webhook to forward the events to Azure function, you would need to handle these POST requests in the Azure functions on your own.

Besides, PlayFab leaderboard provides Prize Table feature that can trigger emails, send push notifications, grant Inventory Items and Virtual Currency, or execute a CloudScript function at the reset of a leaderboard. Actions in Prize table are triggered by the event player_ranked_on_leaderboard_version. And a prize table would trigger a set of actions on a group of players within a range of ranks. So only when you set the rank from 1 to 1 in the Prize Table, and this leaderboard has at least one rank, Prize Table would be a workaround for your case.

If it’s necessary for you to trigger a PlayFab action (like [Execute CloudScrip] or [Execute Azure Function]) through the title_statistic_version_changed event, you can try to add a feature request for it.

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.