question

HectorRodriguezFigueroa avatar image
HectorRodriguezFigueroa asked

How can you pass data to custom email templates when using something like PlayFabServer.SendEmailFromTemplate?

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

·
pfnathan avatar image
pfnathan answered

We need some clarifications, do you mean custom attributes which is specific to the request or custom to the player, like player.Username?

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

HectorRodriguezFigueroa avatar image HectorRodriguezFigueroa commented ·

I'm actually interested in both. Say I'm sending an email that needs to be personalized with the player username, title statistics, custom data or some other item that is stored in PlayFab. How can I find a reference to access all the $someLocal$ accessors to populate the email? In the same token I want to know if I can also inject things into the email that come from the request like a date or promotional code or some other information that does is not persisted on PlayFab but that is relevant to the game and that needs to be communicated to our players on PlayFab.

0 Likes 0 ·
pfnathan avatar image pfnathan ♦ commented ·

On your question: "In the same token I want to know if I can also inject things into the email that come from the request like a date or promotional code or some other information that does is not persisted on PlayFab but that is relevant to the game and that needs to be communicated to our players on PlayFab.", for this, we do not support yet but this is on the plan to be added later.

On the document: https://api.playfab.com/docs/tutorials/landing-players/push-notification-basics, shows that "profile.DisplayName" which also works for email template as well.

0 Likes 0 ·
HectorRodriguezFigueroa avatar image HectorRodriguezFigueroa pfnathan ♦ commented ·

I see, OKI'll be looking forward to that. On the other hand if I understand you correctly you are saying that the other case, i.e. things that are persisted in PlayFab, is supported. Is this correct? If it is, where can I find the info of what is available? I believe that example you are pointing to, doesn't make use of a template though. I think its just interpolating a value into a string and then making the request passing the string as message. What I meant to ask for in this case is if there is a way to access documentation with more elaborate example or a reference to the list of data that I can access in a custom email templates (i.e. other than profile.displayname). This link https://api.playfab.com/blog/announcing-email-messaging provides an example of a couple of templates that use $ConfirmationUrl$ and $Profile.DisplayName$ in the template but I want to know what else is available and when and how to use this API. Say if I were to write a new custom email template $WhereIsTheListOfThingsICanUseHere$ if they are not coming from the request?

0 Likes 0 ·
brendan avatar image brendan HectorRodriguezFigueroa commented ·

We'll file a work item to make sure there's a doc added to the site that provides the specifics, but it's effectively three things:

1. The ConfirmationUrl, as described above,

2. The player profile (ex: Profile.DisplayName), for which you can find the elements here: https://api.playfab.com/documentation/Server/datatype/PlayFab.Server.Models/PlayFab.Server.Models.PlayerProfileModel, and

3. The elements of the event that was the trigger for the email (if the email is being sent as a result of a PlayStream Rule). So that would be, for example, Event.PreviousDisplayName would be one you could use if you were firing the email as a result of a Rule that triggered on a player_displayname_changed event (https://api.playfab.com/playstream/events/player_displayname_changed).

0 Likes 0 ·
joel-2 avatar image joel-2 commented ·

I'm now trying to follow the instructions here to get the Player DisplayName in the email template but not having any luck.

The template includes:

<p>Hi $Profile.DisplayName$</p>

However there is just a blank space in the email. Am I missing something?

If it's relevant, I just set a display name on that player for testing (was previously blank). I'm not sure if there is an issue with time to propagate or something?

0 Likes 0 ·
brendan avatar image brendan joel-2 commented ·

Yes, $Profile.DisplayName$ would be the correct way to get the player's Title Display Name in the email. Can you provide the Title ID and PlayFab ID of the user, so that we can have a look?

0 Likes 0 ·
joel-2 avatar image joel-2 brendan commented ·

Sure. Title ID is 1218. User PlayFab ID (master) is 9C0C6421DB31F2FE and ID (title) is D30FB39B267CA427. Called 'BONECRUSHER' for fun. The email template is called 'Password Reset Template' and we call it with the ServerAPI SendEmailFromTemplate function.

0 Likes 0 ·
Show more comments
Show more comments

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.