Add Custom Message in Journey Authentication Success Response

Hi Folks,

Is it possible to add some custom message to include variables from shared state in the journey 200 success response? Thanks.

Best,
Le

Hi @ldengiam, Yes, it is possible to include custom message with shared state variables in the journey response. For this, we can use a scripted decision node and update the successUrl from the script. Like below:

var username = sharedState.get(“username”);
sharedState.put(“successUrl”, “User " + username + " successfully logged in”);

The above example script will take username from sharedState and updates it in the successUrl. The same goes for “failureUrl” property as well.

Hope this is what you were looking for.

Thank you!

2 Likes

@vinay_midships , thanks for the response and explanation. Yep, that one works. But I’m wondering if there is a more decent way where you can add a custom attribute so that the attribute name is not fixed at ‘successUrl’ or ‘failureUrl’.

Best,
Le

I am in a similar situation and decided to go another route. As last nodes in the failure and success paths I have a scripted decision node “Failure Handler” respective “Success Handler” both with outcome done routing into the failure node respective success node. These Handler nodes take all the necessary information I want to return and send information callbacks to the client. I leave the final success and failure messages untouched. This seems to be the most flexible way and decouples authentication outcome from additional information sharing with the client.

1 Like

@thomas.liebeck Thanks Thomas. I was thinking about that too. One issue is the http status code returned when routed to failure. It will cause confusion/concerns. I wish AM could have a more decent way to handle this use case.

@ldengiam, for now, I am not sure if there is any straightforward way in AM to send custom key-value pairs as response to the success/failure outcomes of the journeys/trees.
However, there is one other way to achieve this, provided you have FR Identity Gateway also implemented in your environment and the AM journeys/trees are invoked/proxied via IG routes.
In this approach, first, in AM, you put whatever the custom data you need into either successUrl or failureUrl in the JSON format, using a custom scripted decision node. Then, at the IG, we can write a simple groovy script to read the response coming from AM, extract the custom data from the successUrl or failureUrl properties and then create a new response in our own required JSON format as needed, and then send this new response to client. We can even send a custom http status code as well. Hope this helps.

If at all, there is any way to do this directly in AM, I will update this thread with the information.

Thank you!

1 Like