-1

Is it in any way possible to send a push notification from our SFMC instance, to a 3rd party app that we don't have control over?

We can presumably access their API, but can SFMC send a push to an API endpoint?

Or what other options could I have to achieve this, if not API?

3
  • How do you see yourself initiate this push? Would this be from e.g. an automation in Automation Studio? From Journey Builder? Cloud Page form submission? Commented May 28 at 12:44
  • It would be primarily from Journey Builder Commented May 30 at 6:03
  • Was my answer helpful? Or do you have any follow-up questions? Commented Jun 6 at 11:15

1 Answer 1

0

You can call external APIs with multiple methods in SFMC.

In your case, as you prefer using Journey Builder, I would recommend building a custom Journey Builder activity. It is not really straightforward, as you will need to involve quite technical resources, and have it hosted outside of SFMC, but in the end it will really pay off. Having a custom JB activity would allow you to drag and drop it into any journey, allowing your marketeers to utilise it natively in any type of journey they might be building.

You can learn more about custom activities in this Trailhead module, or by reading the official documentation.

There are few examples out there, providing you a template with some code, to get you started, e.g. this and this.

Alternatively, if you are open for triggering the API from outside Journey Builder, you can do it in a Script Activity in Automation Studio utilising SSJS. Here is an overview of all the methods, and here is an example of performing a call with OAuth authentication:

 <script type="javascript" runat="server">
   Platform.Load("core","1.1.5");


    var authEndpoint = "your subdomain";
    var client_id = "your clientId";
    var client_secret = "your client_secret";
    var account_id = "your account_id";
    var grant_type = "client_credentials";

    // auth        
    var url = authEndpoint + '/v2/token';
    var contentType = 'application/json';
    var  payload = '{"grant_type":"' + grant_type + '",';
    payload += '"client_id":"' + client_id + '",';
    payload += '"client_secret":"' + client_secret + '",';
    payload += '"account_id":"' + account_id + '"}';

    try {
      // create token
      var accessTokenResult = HTTP.Post(url, contentType, payload);
      var statusCode = result["StatusCode"];
      var response = accessTokenResult["Response"][0];
      var access_token = Platform.Function.ParseJSON(response).access_token;

    }
    catch (err)  {
      // error
      //Write("error");
    }

</script>

This showcases how to obtain an OAuth token from SFMC, but it can be applied to any OAuth endpoints. You can use the token in subsequent calls for authentication.

Lastly, you can do the same in Ampscript, in e.g. an email or a Cloud Page. However I would not recommend doing this in bulk sends:

%%[
VAR @httppost,@authurl,@apiid,@apistatusCode,@apiresponse,@apitoken
SET @apiid = '{"client_id": "zzzzzzzzzzzzzzzzzz","client_secret": "xxxxxxxxxxxxxxxxxxxxxxx", "grant_type": "client_credentials"}'
SET @authurl = "https://ccccccccccccccccccccc.auth.marketingcloudapis.com/v2/token";
SET @httppost = HTTPPost2(@authurl,"application/json",@apiid,false,@apistatusCode,@apiresponse)
SET @access_token = REGEXMATCH(@apistatusCode,'^(?:.*"access_token":")(.*?)(?:".*)$',1)
SET @rest_instance_url = REGEXMATCH(@apistatusCode,'^(?:.*"rest_instance_url":")(.*?)(?:".*)$',1)
]%%

access_token: %%=v(@access_token)=%% <br>
rest_instance_url: %%=v(@rest_instance_url)=%% <br>
apistatusCode: %%=v(@apistatusCode)=%% <br>

You must log in to answer this question.

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