question

Gerar avatar image
Gerar asked

Sending an automated email after level is completed

Good day!

Our sales department would like to reach players by sending them an email with a discount code.

The thing is that they would like to introduce a delay of 45 minutes from the moment the player reaches the success screen until the mail is sent.

We are currently storing the time the player takes to finish the game in the field name "GameCompletionTime".

We have set the SMPT add-on, made an email template and created the correspondend scheduled task, but we are lost on what are we supposed to code in the JSON cloud script in order to achieve the expected result.

Could somebody who has done this before give us a hand?

Thanks in advance for your time and help,

Gerardo from SkyrocketYourTeam.com



2 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.

Citrus Yan avatar image Citrus Yan commented ·

To better understand your scenario, may I know more details about your current flow, like the configurations of the scheduled task, how "GameCompletionTime" is used, etc. ?

0 Likes 0 ·
Gerar avatar image Gerar Citrus Yan commented ·

Thank you for your answer!

The configuration of the scheduled task is a question for us on its own.


We get some functions available (probably coming from the photon integration?) in the drop down menu but we are not very sure how to use them.

Gamecompletion time is curently storing the time (in seconds) that passes between a player starts playing until the escaperoom is completed, and it shows up in the success screen letting the player know how long it took for him/her to complete the room.

The question is how to extract that time to put it into the email, which on its own would need to be sent when this value is created. Or can it be done by using the function "completed level" so after the last level is completed, the email is sent?

In any case, we don't really know what to write in the JSON code to make it work.

Thank you very much in advance for your time and help!

0 Likes 0 ·
scheduledtask.png (79.5 KiB)

1 Answer

·
Citrus Yan avatar image
Citrus Yan answered

First, those functions in the drop down menu are not supposed to be used in your case. And, is Gamecompletion stored in Player Data? In that case you can not extract it to put into the email because only the following data can be personalized:

Please check out the "What's this" section in the "New Email Template" page for more details:


4 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.

Gerar avatar image Gerar commented ·

Thank you very much @Citrus Yan for your answer!

We can save it either in player data or in the shared group data. Since the player profile contains a time for lastlogin, perhaps we can use that instead, but might not be ideal.

From the "What's this" section we can see the example of "You completed your quest at $Event.Timestamp$". Is that "$Event.Timestamp$" basically our GameCompletionTime?


That is still not solving the question of the automated email, so we would like to ask what would be your recommendation then to create this automated email, how could we make the scheduled task send an email 45 minutes after the player has reached a certain point in the game? (in this case, the success screen)?


Thanks in advance for your time and help!

0 Likes 0 ·
Citrus Yan avatar image Citrus Yan Gerar commented ·

No, $Event.Timestamp$ is not your GameCompletionTime in this case, it is the timestamp of the triggered playstream event: https://docs.microsoft.com/en-us/gaming/playfab/features/automation/playstream-events/

And, I don't think Scheduled Task could be the best approach for solving your question. Since you're introducing a 45min delay, which is a bit hard to implement with the current system. Here is a workaround for you to consider:

1.Send custom event using https://docs.microsoft.com/en-us/rest/api/playfab/events/playstream-events/writeevents?view=playfab-rest to PlayFab when the player reached a certain point in the game.

2.Set up Webhooks so that it'll post these events to your custom server, where you can implement your custom logic, like, wait 45 mins, get completion time, and send the email.

-1 Like -1 ·
Gerar avatar image Gerar commented ·

Thank you ery much @Citrus Yan for your detailed answer. We will give it a go and see where do we get!

Regards from Estonia and have a lovely start to the week.

0 Likes 0 ·
Citrus Yan avatar image Citrus Yan Gerar commented ·

Thanks, have a nice week:)

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.