You can insert some data from the iframe before the journey is activated by saving data inputs in the config.js - inArguments. When you click "Done" in the iframe, the Postmonger event connection.on('clickedNext', save)
will be fired and you can save the inputs:
customActivity.js
function save() {
var message = $('#idMessage').val();
payload['arguments'].execute.inArguments = [{
"tokens": authTokens,
"smsMessage": message,
"phone":"{{Contact.Attribute." + '\"' + eventDefinitionKey + '\"' + ".\"Contact:MobilePhone\"}}",
"key":"{{Contact.Key}}"
}];
payload['metaData'].isConfigured = true;
connection.trigger('updateActivity', payload);
}
Once the journey is activated, the Execute function will run and there you can get your inputs from the inArguments.
server.js
app.post('/journeybuilder/execute', (req, res) => {
verifyJwt(req.body, Pkg.options.salesforce.marketingCloud.jwtSecret, (err, decoded) => {
//verification error -> unauthorized request
if (err) {
console.error(err);
return res.status(401).end();
}
if (decoded && decoded.inArguments && decoded.inArguments.length > 0) {
var phone = decoded.inArguments[0].phone;
var message = decoded.inArguments[0].smsMessage;
var data = {
auth_id: 'xxxxxxx',
auth_secret: 'xxxxxxxx',
message: message,
phone: phone };
sendSms (data);
} else {
console.error('inArguments invalid.');
return res.status(400).end();
}
});
return res.status(200).json({success: true});
});
If you want to use data coming from your data extension you can use merge fields: