Work in Progress: How to send data to Postcript

  • Create a new custom Data Output and select Manual Trigger Only

  • Follow the structure below for the function:

function output(userData, context) {
  const data = {
     "phone_number": userData.phone,
     "keyword": "KEYWORD", //replace with your keyword
     "origin": "website",
  }
  
  return fetch(`https://savvy-api-proxy-secure.heysavvy.workers.dev/?url=${encodeURIComponent('<https://api.postscript.io/api/v2/subscribers>')}`, {
      method: 'POST',
      headers: {
        Accept: 'application/json',
        'Content-Type': 'application/json',
        'Authorization': 'Bearer API KEY' //replace with your API KEY
      },
      body: JSON.stringify(data)
    })
    .then(response => response.json())
    .then(response => console.log('response', response))
}
  • Trigger on page complete of the page where the data is obtained

Last updated