You can create dataflows using Neo extensions to build payloads for APIs, used in Connect+ to create DIY templates. These dataflows receive input in JSON format and convert it into the desired API payload.
The section below provides steps to create a Neo dataflow for building a custom payload.
Create a Neo dataflow
Suppose you need to create a payload for adding customers through the Add Customer API.
To achieve this, through the Neo dataflow you need to do the following:
- Extract the
mobile number
andexternal ID
from the Transform-Data block in JSON format. - Build the
profile
object withidentifiers
andcommChannels
, and return a JSON payload for Add Customer API.
Follow the steps below to create the Neo dataflow in the Neo Extensions UI.
-
Create new dataflow
- Go to the Neo extension UI and click Create new dataflow.
- Enter a name for the dataflow.
- Enter the tag name as
connectplus
. - Click Done.
- In the Neo extension UI, select the dataflow you created.
- On the dataflow page, click on version v1.
Note: A new dataflow has only version v1.
-
Define an API Trigger
- Open the version of the dataflow you want to edit.
- Modify the Trigger block on the canvas to configure the API.
- Set the API method to
POST
. - Enter API url.
- Click Done.
-
Create a Java script block to create the payload
- Enter the block name in Block name field.
- In the Script section, implement the
execute
method to create theprofiles
object and retrieve themobile
andexternalId
using thegetIn()
DAO function . - Create the
commChannels
object and add the communication channel details. - In the Combine inputs to this block using section, select the radio button for
AND
operator, as the block depends on the output of the previous block. - In the Relationssection, under Path 1 Relationuse the DAO function
isSuccess()
to handle successful outcomes. - Click Done.
The following is the code snippet illustrating the Java Script block.
import dao from "neo/dao"; import logger from "neo/logger"; //These are some dao methods already imported. //Other methods on dao you can use by typing `dao.` and editor will suggest few available methods. const { getBody, getEffectiveHeaders, getIn, getApiRequest, getOut, } = dao; const script = { execute: () => { //Write your code here. return { "profiles":[ { "identifiers":[ { "type":"mobile", "value":getIn().mobile }, { "type":"externalId", "value":getIn().externalId }], "commChannels":[ { "type":"mobile", "value":getIn().mobile, "primary":false, "verified":false, "subscribed":false, "attributes":{ } }] }] }; } } export { script as default }
You have created the Neo dataflow that generates the payload to add customers.
This payload is forwarded to the Connect-to-Destination block to call the API.
For detailed information on the Connect+ DIY template, refer DIY Templates.