In this paper we discuss {\em final semantics} for the $\pi$-calculus, a process algebra which models systems that can dynamically change the topology of the channels. We show that the final semantics paradigm, originated by Aczel and Rutten for CCS-like languages, can be successfully applied also here. This is achieved by suitably generalizing the standard techniques so as to accomodate the mechanism of {\em name creation} and the behaviour of the binding operators peculiar to the $\pi$-calculus. As a preliminary step, we give a {\em higher order} presentation of the $\pi$-calculus using as metalanguage $LF$, a {\em logical framework} based on typed $\lambda$-calculus. Such a presentation highlights the nature of the binding operators and elucidates the r\^ole of free and bound channels. The final semantics is defined making use of this higher order presentation, within a category of {\em hypersets}.