How to set up role attributes in Keycloak?

Can anyone tell me how to set up role attributes in keycloak and also I need to get that information in id token. I have some requirements based on that. Thanks in advance.

I don’t believe there is a built-in mapper that can do this. A few people have used script mappers to achieve it: