쿼리 라이브러리사용자에게 개인화된 이메일 보내기
사용자에게 개인화된 이메일 보내기
이 쿼리는 사용자 목록을 가져와 각 사용자의 데이터(이름, 이메일 주소, 그리고 메타로 저장된 남은 크레딧 수)를 조회한 후, 각 사용자에게 개인화된 이메일을 전송합니다.
이 쿼리를 실행하려면 엔드포인트에서 중첩 Mutation이 활성화되어 있어야 합니다.
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
}
}
}
}
}