JB RESTful Activity - This is app allows SFMC journey builder to integrate with third party API in real time
Reference links:
- https://github.com/axios/axios
- https://developer.salesforce.com/docs/atlas.en-us.mc-apis.meta/mc-apis/how-data-binding-works.htm
- https://github.com/janl/mustache.js/
NOTE: You won't be able to run this locally. It is intended to be ran on a publicly available web server/cloud only.
- Node.js (to test locally)
- Must have an Salesforce Marketing Cloud account
- Journey Builder and all associated applications must be provisioned into this account
- A publicly accessible web server or cloud (netlify)
- Understanding of client-server communications, JavaScript, HTML(5), Node.js and Express
- Deploy to Rnder using the button above, load the environment variables based on the ones in .env file
- Login to your account on Marketing Cloud
- Select Setup -> App Integration from navigation
- Select "Create New App"
- Create a custom activity for journey builder, and fill in the endpoint for the app,
{subdomain}.netlify.app/public/jbcustom/
hit save then hit finish - Go to Journey Builder and you should see the custom activity appearing in the bottom
Now that you have updated your configurations to point to the appropriate resources, push your changes.
- Log into the Marketing Cloud
- Choose Journey Builder and create a new journey.
- Add a data extension source
- Drag the custom activity from the list onto the Interaction Canvas
- Hover and click the activity
- The custom activity dialog should appear (this is loading from your app)
- fill in the request body using json object specified by axios. Leverage data binding to access any part of the data structure sent in from SFMC.
example:
{
method: 'post',
url: 'https://apidev.example.com/',
params: {
apikey: "",
function: 'InsertRecord',
module: 'data',
datasetid: 8088,
},
"data": {
"FirstName": "{{Contact.Attribute.testlist.firstname}}",
"salary": "{{Contact.Attribute.testlist.salary}}",
"age": "{{Contact.Attribute.testlist.age}}",
"id": {{Contact.Attribute.testlist.id}}
}
}
- fill in webhook url and Oauth 2.0 if required
- fill in pre/post run options if you need to run your own javascript, SFMC data binding variables such as InArguments are accessible. Pre-run script aimes to address use case where request logging or data transformation is required. Post-run script allows developers to transform the server response into a format that can be consumed back in SFMC via outArguments
- activiate the journey, validate result via nodejs server log and destination API endpoint