How to use Subscribers custom data inside html template using Handlebars
Hi team, I trying to send emails with some dynamic data, I want to use Subscribers custom data inside html template. I'm using it like below
why its not working for me ?
12 Replies
Hi @MP, I'm an AI assistant for Novu. While a team member reviews this question, I'll look through relevant sources and see if I can provide suggestions. Please tag @Ask Inkeep with any follow-up questions.
-----------------------------
While I generate an answer, here are some sources that might be helpful:
* Subscribers
* Workflow Editor
* Preferences
* Glossary
-----------------------------
Answer
To use subscriber's custom data within your HTML templates in Novu, ensure you're utilizing the correct syntax for referencing the data. According to the documentation, you can access the subscriber's custom data using the syntax
{{ subscriber.data.customKey }}
where customKey
is the key of the data you're trying to access. This allows you to dynamically include subscriber-specific information in your notifications (1) .
For example, if you have stored custom data like {"favoriteColor": "blue"}
for a subscriber, you can reference this in your HTML template as {{ subscriber.data.favoriteColor }}
to dynamically insert the subscriber's favorite color into the email.
Make sure your custom data is correctly set up in the subscriber object and you're using the exact key names in your template. If you continue facing issues, double-check the structure of your subscriber objects and ensure the custom data is correctly formatted and stored.Got it. Tagging @Support for additional help.
Check if CancelledDate field is there in data property of subject
Remove extra space between { and subscriber
{{subscriber.data.CancelledDate}}
@MP
Did you get a chance to take a look at this?
Hi @Pawan Jain , Yes its working
Thanks
@Pawan Jain @Ask Inkeep I want to know is there any option available for to find out if student already received email from one particular workflow? my use case will be like I don't want to send same emails to students who already received the notification ?
Please tag me in threads that I was a part of from the start.
@MP
Are you triggering the workflow based on some action?
Are you triggering to single subscriber or group of subscribers?
@Pawan Jain Its group of subscribers using broadcast API with step conditions
If step conditions are correctly set, email will be sent as per conditions.
Would you like to share why you think email has not been sent to user?
@Pawan Jain If a user is using an old version, I want to send a push notification to update the app. However, I don't want to send the same push notification repeatedly to the same user every day if they're still using the old version.
@MP
Do you have this information in your DB that this user has old version?
Can you sync this information with novu when the state changes and store it in
data
fieldYes @Pawan Jain, its synced with novu db