Given an $n$-step poly-$\mathbb{Z}$ group
$$H_n = (\dots((\mathbb{Z} \rtimes_{\bar{\phi_1}} \mathbb{Z})\rtimes_{\bar{\phi_2}} \mathbb{Z}) \rtimes_{\bar{\phi_3}} \mathbb{Z} \dots ) \rtimes_{\phi_{n-1}} \mathbb{Z}$$
with the star operation $\star$ as the semi-direct products of two groups depending on the group homomorphism $\bar{\phi}_i$. Then we take $e_i$ to be a vector of length $n$ where the $i$th entry is $1$ and else $0$. Thus $\{e_1, \dots, e_n\}$ is the polycyclic generating sequence of $H_n$. Furthermore, since a poly-$\mathbb{Z}$ group is a polycyclic group, hence for every $x \in H_n$, $\mathfrak{f} \in E(H_n)$ ($E(G)$ is the notation for endomorphism of $G$), it follows
$$ \mathfrak{f}(x) = \mathfrak{f}(e_1^{x_1} \star \dots \star e_n^{x_n}) = \mathfrak{f}(e_1)^{x_1} \star \dots \star \mathfrak{f}(e_n)^{x_n}.$$
Thus $\mathfrak{f}$ is entirely determined by $\mathfrak{f}(e_i)$ for $1 \leq i \leq n$. In other words $\mathfrak{f}$ can be represented as a $n \times n$ matrix.
Question: What concludes that $\mathfrak{f} \in E(H_n)$ can be represented as a $n \times n$ matrix? An injective homomorphism to $n \times n$ matrices over $\mathbb{Z}$ would be great since I only focuses on groups.
I'm asking this because if $G$ is an $n$-step poly-$\mathbb{Z}$ group then $\mathfrak{f} \in E(G)$ can be represented as a $n \times n$ matrix.
Furthermore, I want to make sure that $\mathfrak{f} \in E(\mathbb{Z}^{n-1} \rtimes_{\phi} \mathbb{Z})$ for a specific $\phi \in Aut(\mathbb{Z}^{n-1})$ can be represented as an $n \times n$ matrix. I've also proved that $\mathbb{Z}^{n-1} \rtimes_{\phi} \mathbb{Z} \cong \mathbb{Z}^{n-3} \times H$ where $H$ is the Heisenberg group. Probably someone can help me prove that $\mathfrak{f} \in E(\mathbb{Z}^{n-3} \times H)$ can be represented as an $n \times n$ matrix. If that's proven then $\mathfrak{f} \in E(\mathbb{Z}^{n-1} \rtimes_{\phi} \mathbb{Z})$ can be represented as an $n \times n$ matrix.
Alternative Question: Please help me prove that $\mathfrak{f} \in E(\mathbb{Z}^{n-3} \times H)$ can be represented as a $n \times n$ matrix? By groups analogy is recommended since I'm only working on groups.
Thanks!