Auth0 Twilio Flex SSO: How to use Actions instead of Rules

For those of you using Auth0 as IdP for Twilio Flex, you might have noticed that Auth0 moved from Rules to Actions, meaning the instruction at this page https://www.twilio.com/docs/flex/admin-guide/setup/sso-configuration/auth0 are unfortunately no longer valid, especially for all new Auth0 accounts, where the Auth Pipeline and Rules menu doesn’t exist anymore.

New instructions are here below:

  1. Go in Actions -> Library and create a Build Custom block
  2. The old Rules:
function (user, context, callback) {
 context.samlConfiguration.mappings={
    "email":"email",
    "full_name": "name",
    "first_name": "given_name",
    "last_name": "family_name",
    "image_url": "picture",
    "roles": "app_metadata.flex.roles"
  };
  console.log(context.samlConfiguration);
  callback(null, user, context);
}

It now become this:

exports.onExecutePostLogin = async (event, api) => {

    api.samlResponse.setAttribute("email", event.user.email);
    api.samlResponse.setAttribute("full_name", event.user.name); 
    api.samlResponse.setAttribute("first_name", event.user.given_name); 
    api.samlResponse.setAttribute("last_name", event.user.family_name); 
    api.samlResponse.setAttribute("image_url", event.user.picture); 
    api.samlResponse.setAttribute("roles", event.user.app_metadata.flex.roles);

};

3. Once you create this new block add it to the existing Login flow, between Start and Complete.

Done!

I hope this is clear enough, if not feel free to comment here below for additional clarification.

Cheers!