Most of the alkaloids have a tertiary amine group, so the explanation for color reaction could be the following:
:( = anions of acid)
Then the insoluble complex salt is formed from the reaction between ammonium salt and potassium tetraiodobismuthate.
This ion pair has different colors: yellow, orange, red, and brown, which depend on the nature of alkaloids.