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]
);