Trigger badge when roles is added

I don’t know how to do the query to add badge automatically after add roles for users

Thank’s for your help