Biblioteka queriesWyślij spersonalizowany e-mail do swoich użytkowników
Wyślij spersonalizowany e-mail do swoich użytkowników
To zapytanie pobiera listę użytkowników, uzyskuje ich dane (imię, e-mail i liczbę pozostałych kredytów, przechowywanych jako meta), a następnie wysyła spersonalizowany e-mail do każdego z nich.
To zapytanie wymaga, aby endpoint miał włączone Zagnieżdżone mutacje.
mutation SendPersonalizedEmailToUsers {
users {
email
displayName
credits: metaValue(key: "credits")
# If the user does not have meta entry "credits", use `0` credits
hasNoCreditsEntry: _isNull(value: $__credits)
remainingCredits: _if(condition: $__hasNoCreditsEntry, then: 0, else: $__credits)
emailMessageTemplate: _strConvertMarkdownToHTML(
text: """
Hello %s,
Your have **%s remaining credits** in your account.
Would you like to [buy more](%s)?
"""
)
emailMessage: _sprintf(
string: $__emailMessageTemplate,
values: [
$__displayName,
$__remainingCredits,
"https://mysite.com/buy-credits"
]
)
_sendEmail(
input: {
to: $__email
subject: "Remaining credits alert"
messageAs: {
html: $__emailMessage
}
}
) {
status
errors {
__typename
...on ErrorPayload {
message
}
}
}
}
}