Skip to main content
Solved

Trigger a flow via NodeJS SDK

  • November 1, 2022
  • 3 replies
  • 203 views

Forum|alt.badge.img+2

My goal is to delay the delivery of an email flow to the recipient of gifts from my store.

The user will provide `recipient_email` and `email_send_date` as properties on the Shopify line item.

From what I can tell, there is no way to delay a flow to begin at a specific time, this is why I intend to use another service to delay a call to start the flow.

The issue I’m having is that I’m just not clear on the concepts being used, the language in the documentation does not have some of the concepts I see in the UI. 

When I go to set up a flow, it says `What action will trigger this flow?`. So I’m looking for a way using the API to trigger an action, or to even register one.

My question is - what are the relationships between Actions, Triggers, Metrics, Events?
 

const { URLSearchParams } = require('url');
const fetch = require('node-fetch');
const encodedParams = new URLSearchParams();

encodedParams.set('data', `{"token": ${process.env.KLAVIYO_KEY}, "event": "Foof", "customer_properties": {"$email": "abraham.lincoln@klaviyo.com"}, "properties": {"item_name": "Boots","$value": 100}}`);

const url = 'https://a.klaviyo.com/api/track';
const options = {
  method: 'POST',
  headers: {accept: 'text/html', 'content-type': 'application/x-www-form-urlencoded'},
  body: encodedParams
};

const foo = await fetch(url, options)
const poo = await foo.json()

console.log('foo:'+ Object.getOwnPropertyNames(foo))
console.log('poo:'+ poo)

I thought calling the above code would create `Foof` as an option in my trigger setup.
I can’t tell if my calls are successful, or if I’m calling the right endpoint at all.

I saw in the `klaviyo-node-api` SDK there are nice helpers, but I can’t tell from the documentation in github (https://github.com/klaviyo/klaviyo-api-node) what the shape of `body` should be.

Best answer by alex.hong

Hi there @frankyfraaank ,

Welcome to the Community and thanks for sharing.

If you are looking to mark something as transactional, you would have to Contact Support to get that sorted. 

First you will create a Flow and build out the email(s) to be sent within the Flow. Once you have configured all the content in your flow, you can reach out to the Support Team and use the subject line "Transactional Email Request" so that the email(s) reach the appropriate team for review. In your message, include:

  • URL link(s) to the flow(s)
  • Flow name(s)
  • Subject line of the email(s) that are transactional

 
Once support verifies that your email is transactional, you will see a green badge on the email card. You will also see the transactional status enabled for a given email under the email’s settings.
 
Feel free to check out this help guide on Using Flows to Send Transactional Emails for more in-depth information. 

 

Thanks,

Alex.

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

3 replies

Forum|alt.badge.img+2
  • Author
  • Contributor I
  • 2 replies
  • November 1, 2022

Is there any documentation that could explain to me what an `Event` is in this context? I think I’m misunderstanding the concept.


Forum|alt.badge.img+2
  • Author
  • Contributor I
  • 2 replies
  • November 1, 2022

Mods can remove this post I think. I’m trying to create transactional emails and it looks like special arrangements need to be made for this to work.


alex.hong
Forum|alt.badge.img+58
  • Klaviyo Alum
  • 1552 replies
  • Answer
  • November 1, 2022

Hi there @frankyfraaank ,

Welcome to the Community and thanks for sharing.

If you are looking to mark something as transactional, you would have to Contact Support to get that sorted. 

First you will create a Flow and build out the email(s) to be sent within the Flow. Once you have configured all the content in your flow, you can reach out to the Support Team and use the subject line "Transactional Email Request" so that the email(s) reach the appropriate team for review. In your message, include:

  • URL link(s) to the flow(s)
  • Flow name(s)
  • Subject line of the email(s) that are transactional

 
Once support verifies that your email is transactional, you will see a green badge on the email card. You will also see the transactional status enabled for a given email under the email’s settings.
 
Feel free to check out this help guide on Using Flows to Send Transactional Emails for more in-depth information. 

 

Thanks,

Alex.