0

we have developed a custom activity to integrate Twilio in Marketing Cloud, it is working fine connecting Marketing Cloud to the Twillio account and sending SMS to the contacts in the source Data Extension.

However, the Marketing Cloud instance has 4 Business Units, and they will be adding more in the future. So, for the custom activity to be scalable, it needs to identify from what Business Unit the Journey is being triggered, and use the corresponding phone number to send the messages.

What can I use as an identifier for the triggering Business Unit? (I was thinking about the MID) and how cna I get that information from marketing cloud in the custom activity logic?

This is a snippet of the code that is currently working

        var auth = "authentication code";
 
var config = {
  endpoint: "https://api.twilio.com/2010-04-01/Accounts/twilio account/Messages.json",
  contentType: "application/x-www-form-urlencoded",
  payload : "From=+phone number&To=+" + payload.inArguments[0].mobile + "&Body=" + msg
};

var httpResult = HTTP.Post(
  config.endpoint,
  config.contentType,
  config.payload,
  ["Authorization"],
  ["Basic " + auth]
);

And this is what I've tried so far with no success:

var auth = "authentication code";
 
var businessUnitIds = {
  "MID of the Marketing Cloud account": +phone number,
};

var businessUnitData = RetrieveSalesforceObjects(
  "BusinessUnit",
  "BusinessUnitId",
  "Id",
  "=", _subscriberkey
);

if (RowCount(businessUnitData) > 0) {
  journeyBusinessUnit = Field(businessUnitData, "BusinessUnitId");
}

var config = {
  endpoint: "https://api.twilio.com/2010-04-01/Accounts/twilio account/Messages.json",
  contentType: "application/x-www-form-urlencoded",
  payload : "From="+businessUnitIds[journeyBusinessUnit]+"&To=+" + payload.inArguments[0].mobile + "&Body=" + msg
};

var httpResult = HTTP.Post(
  config.endpoint,
  config.contentType,
  config.payload,
  ["Authorization"],
  ["Basic " + auth]
);
1

1 Answer 1

0

You can have a look at the postmonger events you can trigger in you custom activity (CA). https://developer.salesforce.com/docs/marketing/marketing-cloud/guide/using-postmonger.html#events-broadcast-by-the-custom-activity

In your case I think you should get the token by firing the connection.trigger('requestTokens').It will fire the function you define in connection.on('requestedTokens', someFunction) there you will get 2 tokens.

You should send the token to your backend and using the rest api call to get the token info https://developer.salesforce.com/docs/marketing/marketing-cloud/guide/getUserInfo.html, the organization.member_id atribute should work for you

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .