braze-community / braze-node

📫 Node.js library for Braze API.
https://braze-community.github.io/braze-node
MIT License
13 stars 10 forks source link

How to identify user before send email #746

Open Yasinilhan61 opened 3 hours ago

Yasinilhan61 commented 3 hours ago

Question

How to identify user before send email

Keywords

I want to send an email on the server side, but first I need to identify the user in the Braze system. I'm trying, but I'm not getting any results! How can I register the user first

This is my method which i am trying to :

`async function identifyUser(email, userId) { // get firebase user id

// create user on braze

try { const identifyPayload = { aliases_to_identify: [ { external_id: userId, user_alias: { alias_name: "email", alias_label: email, }, }, ], emails_to_identify: [ { external_id: userId, email: email, prioritization: ["unidentified", "most_recently_updated"], }, ], }; await brazeClient.users.identify(identifyPayload); } catch (error) { logger.error(Failed to identify user ${email}: ${error.message}); } } `

remarkablemark commented 3 hours ago

Take a look at https://www.braze.com/docs/api/endpoints/user_data/post_user_identify/

I think your approach looks good, you can stick with either aliases_to_identify or emails_to_identify, you don't need both