Skip to main content
Solved

How to send notification mail to a specific user's email from the server side through the API?

  • November 24, 2023
  • 5 replies
  • 204 views

Forum|alt.badge.img+1

I have a use case where  I want to send an email with placeholders to a single user, like a notification email. For example, when a user’s subscription is about to end, I want to send a reminder email only to that one user whose subscription is about to end from the server side.
Is there a way to manually trigger the flow from the server side using API by passing recipient’s email or profile Id and notification content as placeholders.
I looked for all the APIs klaviyo-api npm package provided, but couldn’t find any API suitable for my use case.
Please help me with this. Thank you

Best answer by saulblum

Metric-triggered flows will fire for a profile each time the profile gets that event, unless you have a trigger filter that excludes certain instances of that event. (Segment flows can only be entered once per profile.)

Are you using the {{ event.property }} syntax to embed event properties in emails?

View original
Did this topic or the replies in the thread help you find an answer to your question?

5 replies

Forum|alt.badge.img+7
  • Klaviyo Employee
  • 169 replies
  • November 24, 2023

You’d want to use the Create Event call to send a custom event to just one profile (assuming you also have a flow triggered off that event). All of the SDKs support this method. Include in the event properties any custom properties you’d want to include in the flow’s email.


Forum|alt.badge.img+1
  • Author
  • Contributor II
  • 3 replies
  • November 27, 2023

Thank you so much for the answer.

I followed this and was able to send a notification email but I faced two issues.
1. The custom properties I added while creating the event are not reflected in the email or I am not finding a right way to add the properties in email template. 
 

 const createEventInput = {
      data: {
        type: 'event',
        attributes:   {
          // the below properties are not showing up in the email.
          properties: {
            notification_title: 'This is notification title',
            notification_content: 'This is notification content.',
            content: 'hi, this is content'
          },
          metric: {
            data: {
              type: 'metric',
              attributes: {
                name: 'Web notification'
              }
            }
          },
          profile: {
            data: {
              type: 'profile',
              attributes: {
                email: 'sample@example.com'
              }
            }
          }
        }
      }
    }
  1. The email is being sent only once per profile, but my use case is to trigger the flow as many times the user triggers the event ! 
     

Please help me with the answers. Thank you.


Forum|alt.badge.img+1
  • Author
  • Contributor II
  • 3 replies
  • November 27, 2023

thanks for the answer. 
When I follow this approach, I am facing two issues: 
1. The flow will be triggered only once for one profile, but I need to send the notification mail each time when I Create Event for a profile. 
2. The custom properties are not showing up in the mail which are set while creating a event.


Forum|alt.badge.img+7
  • Klaviyo Employee
  • 169 replies
  • Answer
  • November 27, 2023

Metric-triggered flows will fire for a profile each time the profile gets that event, unless you have a trigger filter that excludes certain instances of that event. (Segment flows can only be entered once per profile.)

Are you using the {{ event.property }} syntax to embed event properties in emails?


Forum|alt.badge.img+1
  • Author
  • Contributor II
  • 3 replies
  • November 28, 2023

Thank you so much, yes metric-triggered flows will fire for a profile each time the profile gets that event. The smart sending feature was on because of that while testing for a single profile the email was not being sent multiple times.

also {{ event.property }} syntax worked perfectly.✌🏽🙌