  We study the categorical generalizations of a $BF$ theory to $2BF$ and $3BF$
theories, corresponding to $2$-groups and $3$-groups, in the framework of
higher gauge theory. In particular, we construct the constrained $3BF$ actions
describing the correct dynamics of Yang-Mills, Klein-Gordon, Dirac, Weyl and
Majorana fields coupled to Einstein-Cartan gravity. The action is naturally
split into a topological sector and a sector with simplicity constraints,
adapted to the spinfoam quantization programme. In addition, the structure of
the $3$-group gives rise to a novel gauge group which specifies the spectrum of
matter fields present in the theory, just like the ordinary gauge group
specifies the spectrum of gauge bosons in the Yang-Mills theory. This allows us
to rewrite the whole Standard Model coupled to gravity as a constrained $3BF$
action, facilitating the nonperturbative quantization of both gravity and
matter fields. Moreover, the presence and the properties of this new gauge
group open up a possibility of a nontrivial unification of all fields and a
possible explanation of fermion families and all other structure in the matter
spectrum of the theory.
