0

I'm trying to get access to the contact information. Here's my config.json file (with a couple redactions)

{
    "workflowApiVersion": "1.1",
    "metaData": {
        "icon": "/images/icon.png",
        "iconSmall": "/images/iconSmall.png",
        "category": "message"
    },
    "type": "REST",
    "lang": {
        "en-US": {
            "name": "David's Custom",
          "description": "A Template for a custom Journey Builder activity",
          "step1Label": "Configure Activity"
        }
    },
    "arguments": {
        "execute": {
           "inArguments":[
                {"urlArg": "URL from iframe"},
                {"emailAddress": "{{Contact.key}}"}              
            ],
          "outArguments": [],
          "url": "<super secret>",
           "verb": "POST",
            "body": "",
            "header": "",
            "format": "json",
            "useJwt": true,
            "timeout": 10000
        }
    },
    "configurationArguments": {
      "applicationExtensionKey": "<super secret>",
      "save": {
        "url": "https://serene-cliffs-18388.herokuapp.com/journeybuilder/save",
          "verb": "POST",
        "useJwt": true
       },
       "publish": {
        "url": "https://serene-cliffs-18388.herokuapp.com/journeybuilder/publish",
           "verb": "POST",
        "useJwt": true
       },
      "stop": {
        "url": "https://serene-cliffs-18388.herokuapp.com/journeybuilder/stop",
           "verb": "POST",
        "useJwt": true
      },
      "validate": {
        "url": "https://serene-cliffs-18388.herokuapp.com/journeybuilder/validate",
        "verb": "POST",
        "useJwt": true
      }
    },
    "wizardSteps": [
        { "label": "Configure Activity", "key": "step1" }
    ],
    "userInterfaces": {
        "configModal": {
            "height": 400,
            "width": 1000,
          "fullscreen": false
        }
    },
    "schema": {
        "arguments": {
            "execute": {
                "inArguments": [
                    {"urlArg": {
                        "dataType": "text",
                        "isNullable": false,
                        "direction": "in"
                    }},
                    {"emailAddress":{
                        "dataType":"Text",
                        "isNullable":false,
                        "direction":"in"
                    }}
                ],
                "outArguments": []
            }
        }
    }
}

My execute code path is like this. Sorry for all the debug output, I've been trying to figure this out for a while:

exports.execute = function (req, res) {
    
    console.log("*************************EXEC*************************");

    // example on how to decode JWT
    JWT(req.body, process.env.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) {
            console.log(JSON.stringify(decoded));
            // decoded in arguments
            console.log("decodedArgs in args ******************************");
            var decodedArgs = decoded.inArguments[0];
            console.log(JSON.stringify(decodedArgs));
            console.log("URLArgs: " + decoded.inArguments.urlArg);
            console.log("emailAddress: " + decoded.inArguments.emailAddress);
            console.log("contactIdentifier: " + decoded.inArguments.contactIdentifier);
            console.log("END decodedArgs in args ******************************");
            
            logData(req);
            res.send(200, 'Execute');
        } else {
            console.error('inArguments invalid.');
            return res.status(400).end();
        }
    });
};

So then here's the console output from Heroku:

*************************EXEC*************************
2020-08-18T04:23:38.730865+00:00 app[web.1]: {"inArguments":[{"tokens":{"token":"02-owQbY1VNTJAchWMJQH8QojaMJdgL3HRnpDsOtAOb5iBPlaljPQzUuMqNm6jiGP6sJcl_VFHRuRtW7mdKcsWnLeOf16FzeuznLQRD4_xngaW7kQefu9Xb8uh6YWfchXFIqzDFx1I_WqqjAFv1EBQxe0MhmKcL505djPdaGD0CiTZ0T7qNk2U_QmoJ-ad0Xby8LtF1_ezFUWv6IpCTLFuZRJRFPilrg7ObI9nCZMdy6kLIjQLxxKD_TJqtes539Zsky-ZISwTiTE3Loo8VCiMA","fuel2token":"7lnLc17z4r3b84GRHlJgeoSC","expires":1597725778021,"stackKey":"S7"},"urlArg":"ppppp"}],"outArguments":[],"activityObjectID":"d3a2ea26-7da2-4177-85df-45b2c53b7754","journeyId":"a55b8538-b52a-4be0-a11e-dc5b8d97a9d7","activityId":"d3a2ea26-7da2-4177-85df-45b2c53b7754","definitionInstanceId":"8ed3a5dd-bc19-49e5-91a8-e5c5a5f7439e","activityInstanceId":"3fb169e2-5aaf-4277-8c2d-83967e8267ea","keyValue":"RecordB","mode":0}
2020-08-18T04:23:38.735295+00:00 app[web.1]: decodedArgs in args ******************************
2020-08-18T04:23:38.735392+00:00 app[web.1]: {"tokens":{"token":"02-owQbY1VNTJAchWMJQH8QojaMJdgL3HRnpDsOtAOb5iBPlaljPQzUuMqNm6jiGP6sJcl_VFHRuRtW7mdKcsWnLeOf16FzeuznLQRD4_xngaW7kQefu9Xb8uh6YWfchXFIqzDFx1I_WqqjAFv1EBQxe0MhmKcL505djPdaGD0CiTZ0T7qNk2U_QmoJ-ad0Xby8LtF1_ezFUWv6IpCTLFuZRJRFPilrg7ObI9nCZMdy6kLIjQLxxKD_TJqtes539Zsky-ZISwTiTE3Loo8VCiMA","fuel2token":"7lnLc17z4r3b84GRHlJgeoSC","expires":1597725778021,"stackKey":"S7"},"urlArg":"ppppp"}
2020-08-18T04:23:38.735543+00:00 app[web.1]: URLArgs: undefined
2020-08-18T04:23:38.735624+00:00 app[web.1]: emailAddress: undefined
2020-08-18T04:23:38.735749+00:00 app[web.1]: contactIdentifier: undefined
2020-08-18T04:23:38.735798+00:00 app[web.1]: END decodedArgs in args ******************************

If you ignore most of it; the first output of the entire decoded object is just:

{"inArguments":[{"tokens":{"token":"02-owQbY1VNTJAchWMJQH8QojaMJdgL3HRnpDsOtAOb5iBPlaljPQzUuMqNm6jiGP6sJcl_VFHRuRtW7mdKcsWnLeOf16FzeuznLQRD4_xngaW7kQefu9Xb8uh6YWfchXFIqzDFx1I_WqqjAFv1EBQxe0MhmKcL505djPdaGD0CiTZ0T7qNk2U_QmoJ-ad0Xby8LtF1_ezFUWv6IpCTLFuZRJRFPilrg7ObI9nCZMdy6kLIjQLxxKD_TJqtes539Zsky-ZISwTiTE3Loo8VCiMA","fuel2token":"7lnLc17z4r3b84GRHlJgeoSC","expires":1597725778021,"stackKey":"S7"},"urlArg":"ppppp"}],"outArguments":[],"activityObjectID":"d3a2ea26-7da2-4177-85df-45b2c53b7754","journeyId":"a55b8538-b52a-4be0-a11e-dc5b8d97a9d7","activityId":"d3a2ea26-7da2-4177-85df-45b2c53b7754","definitionInstanceId":"8ed3a5dd-bc19-49e5-91a8-e5c5a5f7439e","activityInstanceId":"3fb169e2-5aaf-4277-8c2d-83967e8267ea","keyValue":"RecordB","mode":0}

in which my other inArgument is not being provided. I know it says emailAddress, but I read here Custom Journey Builder Activity to try with Contact.key to test that it works (hence why the data type is text and not email).

I'm at a bit of a loss. The configuration from the custom activities UI has come through, that's the urlArg, but the data binding doesn't seem to work, even with this most basic example.

Results of interaction/v1/interactions/journeyID show:

"execute": {
    "inArguments": [
        {
            "tokens": {
                "token": "02-owQbY1VNTJAchWMJQH8eTmBJjNO51-7-2mQbC3WCdy_stdyWaK7X0moFofydcn4wCmahjsTaLCROG9XVzwongWgdzrUrwFZSi1sePSZYAfMdFRtWSC4cdzJP0U0AoxbfaX_HynwulNWbmBFTTWVPgbj9cIln5TfiZMLbdgA5s_FVGcDxDexVAvq1JuF1dSeM_FLL0bsGocB_JqX4HdpZh8vua38U5B0_j6JtpoguhS4M8z8zEkUV0z1fOQ8i4N_IxYJMyba9OrpQqA-Z4cSQ",
                "fuel2token": "7OD7EvRYQfqDKELXSkd3jVuf",
                "expires": 1597792500250,
                "stackKey": "S7"
            },
            "urlArg": "Saved URL Value"
        }
    ],
    "outArguments": [],
    "url": "https://serene-cliffs-18388.herokuapp.com/journeybuilder/execute",
    "verb": "POST",
    "body": "",
    "header": "",
    "format": "json",
    "useJwt": true,
    "timeout": 10000
},

Note that it has urlArg, which is one of my defined inArguments, but no email. It also has:

"schema": {
    "arguments": {
        "execute": {
            "inArguments": [
                {
                    "urlArg": {
                        "dataType": "text",
                        "isNullable": false,
                        "direction": "In",
                        "readOnly": false,
                        "access": "Hidden"
                    }
                },
                {
                    "emailAddress": {
                        "dataType": "Text",
                        "isNullable": false,
                        "direction": "In",
                        "readOnly": false,
                        "access": "Hidden"
                    }
                }
            ],
            "outArguments": []
        }
    }
}

You can see email address in the defined schema.

2
  • 1
    Hey David, When you look at the configured Journey using the GET /interaction/v1/interactions route, do you see the saved inArgs? If they're being saved, what's the data binding that's saved? If they're not being saved, do you have the client-side code that you're using on saving the Custom Activity and the inArgs configured by the user?
    – Macca
    Aug 18, 2020 at 7:52
  • 1
    Love you @Macca . I didn't realise you needed to save the data-bound inArgs; for some reason I just thought they'd magically do their thing. Aug 18, 2020 at 23:17

0

You must log in to answer this question.