The Message Center API (nms:rtEvent#PushEvent) can be used to send transactional messages. It should be called on the Message Center execution instances, not on the marketing instances.
Two authentication mechanism are possible for Message Center. It is possible to use a user/password authentication and call the Logon method to get a session and security token, as all other APIs. When using this authentication mechanism, the caller is responsible to handle token expiration and must explicitely handle the case when the Message Center API call fails because of an expired token.
Another common authentication strategy is to define a trusted Security Zone for message center clients and setup this security zone to use the "user/password" as a session token.
Here's an example of authentication with this method
const connectionParameters = sdk.ConnectionParameters.ofSessionToken(url, "mc/mc"); const client = await sdk.init(connectionParameters);
Events can be pushed using the nms:rtEvent#PushEvent API call. For instance
var result = await NLWS.nmsRtEvent.pushEvent({ wishedChannel: 0, type: "welcome", email: "aggmorin@gmail.com", ctx: { $title: "Alex" } }); console.log(`>> Result: ${result}`);
There are a couple of noteworthy things to say about this API when using SimpleJson serialization.
There's no scalable API to get the status of a message center event. One can use the QueryDef API to query the nms:rtEvent table for testing purpose though.
To do so, the first step is to decode the event id returned by PushEvent. It is a 64 bit number, whose high byte is the message center cell (instance) id which handled the event. It's a number between 0 and 255. The lower bytes represent the primary key of the event. Note that this is subject to change in future versions of Campaign and should not be considered stable.
Clear high byte
eventId = Number(BigInt(eventId) & BigInt("0xFFFFFFFFFFFFFF"));
Get event status
var queryDef = { schema: "nms:rtEvent", operation: "get", select: { node: [ { expr: "@id" }, { expr: "@status" }, { expr: "@created" }, { expr: "@processing" }, { expr: "@processed" } ] }, where: { condition: [ { expr:`@id=${eventId}` } ] } } query = NLWS.xtkQueryDef.create(queryDef); var event = await query.executeQuery(); console.log(`>> Event: ${JSON.stringify(event)}`);