简体   繁体   English

从 Config.Json、Journey Builder、Marketing Cloud 获取 InArguments

[英]Getting InArguments from Config.Json, Journey Builder, Marketing Cloud

I have been trying without success to understand how to work with the InArguments/OutArguments from Journey Builder on marketing cloud.我一直在尝试了解如何在营销云上使用 Journey Builder 的 InArguments/OutArguments,但没有成功。 I have been reading through the documentation on Marketingcloud as well as GitHub examples and still can't understand.我一直在阅读有关 Marketingcloud 的文档以及 GitHub 示例,但仍然无法理解。 I believe much of the information online is outdated or incomplete.我相信网上的很多信息已经过时或不完整。

Here is my config.json:这是我的 config.json:

    "workflowApiVersion": "1.1",
    "metaData": {
        "icon": "images/icon.png",
        "iconSmall": "images/iconSmall.png",
        "category": "customer updates"
    },
    "type": "REST",
    "lang": {
        "en-US": {
            "name": "SampleCA",
          "description": "A Template for a custom Journey Builder activity",
          "step1Label": "Configure Activity"
        }
    },
    "arguments": {
        "execute": {
           "inArguments":[
                {
                    "ContactKey": "{{Context.ContactKey}}"
                }                                   
            ],
          "outArguments": [],
          "url": "https://programb.herokuapp.com/execute",
           "verb": "POST",
            "body": "",
            "header": "",
            "format": "json",
            "useJwt": true,
            "timeout": 10000
        }
    },
    "configurationArguments": {
      "applicationExtensionKey": "6f382672-1c0f-42e1-ac02-6bec3ad0e57b",
      "save": {
        "url": "https://programb.herokuapp.com/save",
          "verb": "POST"
       },
       "publish": {
        "url": "https://programb.herokuapp.com/publish",
           "verb": "POST"
      },
      "stop": {
        "url": "https://programb.herokuapp.com/stop",
           "verb": "POST"       
      },
      "validate": {
        "url": "https://programb.herokuapp.com/validate",
        "verb": "POST"
      }
    },
    "wizardSteps": [
        { "label": "Get User Input", "key": "step1" }
    ],
    "userInterfaces": {
        "configModal": {
            "height": 400,
            "width": 1000,
          "fullscreen": false
        }
    },
    "schema": {
        "arguments": {
            "execute": {
                "inArguments": [
                  {
                    "ContactKey": {
                      "dataType": "ContactKey",
                      "isNullable": false,
                      "direction" : "in"
                    }
                  }
                ],
                "outArguments": []
            }
        }
    }
}

and my customActivity.js:和我的 customActivity.js:

define([
    'postmonger'
], function (
    Postmonger
) {
    'use strict';
    var connection = new Postmonger.Session();
    var token;
    var payload = {};
    var contactKey;

    $(window).ready(function() {
        connection.trigger('requestTokens');
        connection.trigger('ready');
    });

    connection.on('clickedNext', save);

    connection.on('getTokens', function( data ) {
        if( data.error ) {
            console.error( data.error );
        } else {
            tokens = data;
        }
    });
    
    connection.on('initActivity', function(payload) { 
        console.log("INITACTIVITY INITACTIVITY INITACTIVITY INITACTIVITY INITACTIVITY ");
        var hasInArguments = Boolean(
            payload['arguments'] &&
            payload['arguments'].execute &&
            payload['arguments'].execute.inArguments &&
            payload['arguments'].execute.inArguments.length > 0
        );

        var inArguments = hasInArguments ? payload['arguments'].execute.inArguments : {};

        console.log("INARGS INARGS INARGS INARGS INARGS INARGS INARGS INARGS INARGS INARGS INARGS INARGS ");
        console.log(inArguments);
        console.log("INARGS INARGS INARGS INARGS INARGS INARGS INARGS INARGS INARGS INARGS INARGS INARGS ");

        $.each(inArguments, function (index, inArgument) {
            $.each(inArgument, function (key, val) {
                if (key === 'contactKey') {
                    contactKey = val;
                }            
            });
        });
        console.log(payload);

        connection.trigger('updateButton', {
            button: 'next',
            text: 'done',
            visible: true
        });
        console.log("INITACTIVITY INITACTIVITY INITACTIVITY INITACTIVITY INITACTIVITY ");
     });



    connection.on('requestedTokens', function(tokens) { 
        token = tokens;
    });

       function save() {
        payload['arguments'].execute.inArguments = [{
            "tokens": token,
            "contactKey": contactKey
        }];
        
        payload['metaData'].isConfigured = true;

        console.log(payload);
        connection.trigger('updateActivity', payload);
    }
});

Could you please tell me how to get these InArguments for each contact going into my customActivity and manipulate them in my app?你能告诉我如何让每个联系人的这些 InArguments 进入我的 customActivity 并在我的应用程序中操作它们吗?

As I understand my app.js serves my index.html when a request is made to "/" this then launches my customActivity.js script which uses Postmonger module to reply to events such as Init/Ready.据我了解,当向“/”发出请求时,我的 app.js 会为我的 index.html 提供服务,然后启动我的 customActivity.js 脚本,该脚本使用 Postmonger 模块来回复诸如 Init/Ready 之类的事件。 Any clarification on this would be much appreciated.对此的任何澄清将不胜感激。

Thank you.谢谢你。

通过您的自定义活动的每个联系人都将对 arguments.execute.url 中的 url 执行 POST 调用,在您的情况下为https://programb.herokuapp.com/execute ,并使用您在 InArguments 属性中设置的参数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM