4

I'm trying to find out whether it's possible to retrieve the Interaction ID (for a running Interaction) using Data Binding. The Interaction ID is different from {{Context.PublicationId}} and {{Context.DefinitionId}} (in the Interaction context).

I'm referring to the ID that is indicated in the Interaction Plan Canvas URL. The identifier appears between the %23 string (a URL encoded # character) and before the / character. For example, an Interaction identifier is highlighted below.

Retrieiving Interaction Key

Is it possible to retrieve this value using Data Binding?

I'd like to use this as part of an inArgument for a Custom Activity. For example, in the custom-activity-deskapi-node sample application, the Interaction ID is "hard coded" in the update-case config.json file:

"arguments": {
    "execute": {        
        "inArguments":[ 
            { "caseID":"{{Interaction.0d59b900-04bd-443b-9c21-e0c09e76e9dc.caseID}}" }
        ],          
        "outArguments": [               
        ],
        "url": "https://mydomain.herokuapp.com/ixn/activities/update-case/execute/",
        "verb": "POST",
        "body": "",
        "header": "",
        "format": "json",
        "useJwt": false,
        "timeout": 10000
    }
},

While this works and is fine for demonstrative purposes, it means that this Custom Activity can only be used in a defined Interaction. Ideally, I'd like to retrieve this value at runtime and change my inArgument so it can be used by any Interaction.

5

Realizing this question is over a year old I thought I would still add my answer that does not require an API call but instead uses Postmonger.

Using the Postmonger events requestInteraction and requestedInteraction you can get the JSON of the entire interaction, including the InteractionID and any activity keys. You can then parse the JSON and set that value as an inArgument.

Postmonger Interaction Events

2

You can also use the 'activity customer key' there. It will look like "REST-1", "WAIT-3", "MOBILE-2", etc.

{ "caseID":"{{Interaction.REST-1.caseID}}" }

You can get it by querying for details about your interaction:


headers: 
Authorization: Bearer <token>
Content-Type: application/json
GET https://jbinteractions.exacttargetapps.com/fuelapi/interaction/v1/interactions/<guid>?extras=all&versionNumber=9

Have you tried any of the Context values?

From the doc:

  • Context.PublicationId - The publication ID may be important for the currently executing activity if it needs to be associated to a particular publication (version) of the interaction.
  • Context.DefinitionId - The definition ID is an identifier that can be used to specify the interaction. It could have similar uses as PublicationId.
  • Context.DefinitionInstanceId - This is the identifier for the actual instance of an interaction, meaning, each Contact ran through the engine would have a different identifier. This would be useful for matching logs.

Also, JB posts a payload to your activities' execute method with some values may be useful at runtime:


      "body": {
        "inArguments": [
          ...
        ],
        "outArguments": [
          ...
        ],
        "activityObjectID": "<guid>",
        "journeyId": "<guid>",
        "activityId": "<guid>",
        "definitionInstanceId": "<guid>",
        "activityInstanceId": "<guid>",
        "keyValue": "jdoe@bh.exacttarget.com",
        "mode": 0
      },

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.