Send realtime transactional emails from a Marketing instance to a Message Center instance β€” useful when your marketing and transactional email infrastructures are separated.

Using JavaScript in a workflow with SOAP calls, you can trigger Message Center events from a Classic instance without direct database access.

Preparation

  • Access to both Classic (Marketing) instance and Message Center instance
  • External account with Execution Instance type configured
  • Primary key of the external account

Walkthrough

Configure External Account

Create an external account of Type=Execution Instance (internal value 11). Make sure to fill in the URL, login and password:

Message Center external account settings showing server URL, login, and password fields

Get its Primary key for later use in the JavaScript code.

Execute from Workflow

In a workflow, paste the following code:

loadLibrary("/nl/core/shared/nl.js");
NL.require("/nl/core/shared/xtk.js")
  .require('/nms/executionInstance.js');
var extAccount = 11111; // change External Account Primary Key here
var event = <rtEvent type="my_event_type" wishedChannel="0" email="[email protected]" externalId="xxx">
                <ctx>
                      <vars attribute1="value 1">
                        <element1>Value xxx</element1>
                      </vars>
                </ctx>
        </rtEvent>
var rtCell = NL.ExecutionInstance.getExtAccount(extAccount, NL.ExecutionInstance.MESSAGECENTER_TYPE);
logInfo(rtCell); // <extAccount account="xxx" active="1" name="xxx" [...]/>
vars.login = String(rtCell.@account);
vars.password = String(rtCell.@password);
vars.url = String(rtCell.@server);
document.cnx = new HttpSoapConnection(vars.url + '/nl/jsp/soaprouter.jsp', 'utf-8', 0)
document.soapSrv = new SoapService(cnx, 'urn:nms:rtEvent')
document.soapSrv.addMethod('ExecuteQuery', 'xtk:queryDef#ExecuteQuery',
                           ['sessiontoken', 'string','entity', 'NLElement'],
                           ['pdomOutput', 'NLElement'])
var tokens = NL.ExecutionInstance.logonRemote(vars.url, vars.login, vars.password);
logInfo(JSON.stringify(tokens)); // {"sessionToken": "xxx", "securityToken": "xxx"}
document.cnx.addTokens(tokens["sessionToken"], tokens["securityToken"]);
document.soapSrv.addMethod("PushEvent","nms:rtEvent#PushEvent",["sessiontoken", "string", "domDoc", "NLElement"],
[]);
document.soapSrv.PushEvent("",event);

Validation & troubleshooting

  • Verify the external account connection by checking logInfo(rtCell) output β€” it should return the account details
  • Check logInfo(JSON.stringify(tokens)) to confirm session and security tokens were obtained
  • If the event doesn’t trigger, verify the type in the rtEvent matches a valid Message Center event type
  • Ensure the Message Center instance URL is accessible from the Marketing instance

Going further

  • Extend the event payload with additional context variables for personalized content
  • Add error handling around the SOAP calls to manage connection failures gracefully
  • Consider using a JavaScript activity template to standardize this pattern across workflows