2

I'm lost in the woods... We're creating a node application that needs to use the SOAP api to TriggeredSend one-off transactional emails using FuelSDK-Node-SOAP. Looking for a code example.

0

I've tried using the api and I keep getting slapped for my customerKey

  var soapOptions = {
    CustomerKey: 'FROM-EXTERNAL_KEY-IN-DATA-EXTENSION',
    Subscribers: {
      EmailAddress: 'fake@email.com',
      Lists: {ID: '12345'},
      SubscriberKey: '1235-42434-43434-434434'
    },
    TriggeredSendDefinition: {
      CustomerKey: 'EXTERNAL_KEY_FROM_TRIGGERED_SEND',
      Email: {
        CustomerKey: 'EMAIL_ID'
      }
    },
    ClientID: { ID:BUSINESS_UNIT_INT },
  };

 SoapClient.create(
      'TriggeredSend',
      soapOptions,
      {},
      function (err, response) {})

Is what I have and may help, although I'm not sure where to get the proper customer keys for the respective items...

0

I was am doing this with fuel-rest and it works well.

src/controllers/mcloud.utils.js

var FuelRest = require('fuel-rest');
var BPromise = require('bluebird');

module.exports = function(app) {

  var mcloudTools = {};
  mcloudTools.messageDefinitionSends = function(options) {

    var sendKey = "8123631-87a4-428b-80dc123a4bc0a1"; // Trigger email
    var fromAddress = "code@exacttarget.com";

    var options = {
        uri: '/messaging/v1/messageDefinitionSends/' + 'key:' + sendKey + '/send',

        headers: {
            'Content-Type': 'application/json'
        },
        json: {
            "From": {
                "Address": fromAddress,
                "Name": "Sender"
            },
            "To": {
                "Address": 'first.last@company.com'
                , "SubscriberKey": "SDKSubscriberDS"
                , "ContactAttributes": {
                    "SubscriberAttributes": {
                        "ConversionReferenceId": req.attributes.uuid_card_url
                    }
                }
            }
            , "OPTIONS": {
                "RequestType": "ASYNC"
            }
        }
    };

    return new BPromise(function(fulfill, reject) {

        var restOptions  = {
            auth: {
                clientId: process.env.MCLOUD_CLIENTID
                , clientSecret: process.env.MCLOUD_SECRET
            }
            // , origin: 'https://www.exacttargetapis.com' // default --> https://www.exacttargetapis.com
        };
        var RestClient = new FuelRest(restOptions);
        return RestClient
            .post(options)
            .then(function(response) {
                fulfill(response);
            })
            .catch(function(err) {
                reject(err);
            });

    });
};
0

If you want to create a triggered send, I had success with:

var BPromise = require('bluebird');
var ET_Client = require( 'fuelsdk-node' );
var clientId = process.env.MCLOUD_CLIENTID;
var clientSecret =  process.env.MCLOUD_SECRET;

///////////////////
// SOAP - fuelsdk-node - Mcloud
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
mcloudTools.IET_Client = new ET_Client(clientId,clientSecret);

/**
 * CREATE TRIGGERED SEND - SOAP
 */
mcloudTools.postTriggeredSend = function(options, app) {

    var options = {
        props: {
            "Name" : "SDKTriggeredSend"
            ,"Description" : "SDK Created TriggeredSend"
            ,"AutoAddSubscribers" : true
            ,"Email": {"ID" : 8275974}
            ,"List": {"ID" : 39333082}
            ,"SendClassification": {"CustomerKey" : "371"} // Default Transactional
        }
    };

    var triggeredSend = this.IET_Client.triggeredSend(options);

    return new BPromise(function(fulfill, reject) {

        return triggeredSend.post(function(err,response) {
            if (err) {
                reject(err);
            } else {
                fulfill(response);
            }
        });
    });
};

As for the "SendClassification - CustomerKey"...

mc.exacttarget.com - go to Email Studio, then top menu "Admin" Left sidebar, you should see "Send management ≥ Send Classifications"

I use "Default Transactional" = 371, that worked for me.

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.