TITLE: In which sense the GNS-construction is a functor?
QUESTION [17 upvotes]: I asked this at mathstackexchange a week ago, without success. 
I think the Gelfand–Naimark–Segal construction must be a functor in some sense, but I can't find an explicit statement anywhere. Can anybody enlighten me?
For example, is the following hypothesis true?

Let $\varphi:A\to B$ be an involutive homomorphism of C*-algebras, and let $f$ be a state on $B$. Consider the corresponding state $f\circ\varphi$ on $A$ and the GNS-constructions $\pi_{f\circ\varphi}:A\to {\mathcal B}(H_{f\circ\varphi})$ and $\pi_f:B\to {\mathcal B}(H_f)$. Let $\widetilde{A}$ and $\widetilde{B}$ be the von Neumann algebras in ${\mathcal B}(H_{f\circ\varphi})$ and ${\mathcal B}(H_f)$ generated by $\pi_{f\circ\varphi}(A)$ and $\pi_f(B)$ respectively, and let us consider $\pi_{f\circ\varphi}$ and $\pi_f$ as homomorphisms with ranges in $\widetilde{A}$ and $\widetilde{B}$. Is there a homomorphism $\widetilde{\varphi}:\widetilde{A}\to\widetilde{B}$ such that 
  $$
\pi_f\circ\varphi=\widetilde{\varphi}\circ\pi_{f\circ\varphi} \,\,\,\,\,\text{?}
$$ 

I believe, it is not essential here that $A$ and $B$ are C*-algebras, they can just be topological algebras with involution is some sense, and the states can be defined as continuous positive functionals $f:A\to{\Bbb C}$ such that the map $x\mapsto f(x^*\cdot x)$ is also continuous.
I need this for my current work, if anybody could help, I would appreciate this very much.

REPLY [10 votes]: Although this response is a bit late, perhaps this perspective may help nonetheless. It only addresses the question about functoriality of the GNS construction.
The GNS construction is not quite a functor, though as Nik Weaver's response indicates, it has a certain functoriality associated with it. The GNS construction, is, however, (almost) a natural transformation that satisfies a universal property, which is indicated in Westerbaan's response. Let me make this more precise.
Background: There are two relevant functors on the category of $C^*$-algebras. One is the functor that associates the set of all states to every $C^*$-algebra and the function that pulls back states to states to every $C^*$-algebra $*$-homomorphism. This is the ``states'' functor $\mathcal{S}:\mathbf{C}^*\text{-}\mathbf{Alg}^{\mathrm{op}}\to\mathbf{Set}.$ There is another functor that sends a $C^*$-algebra to its category of representations and a $*$-homomorphism to a functor between categories of representations $\mathbf{Rep}:\mathbf{C}^*\text{-}\mathbf{Alg}^{\mathrm{op}}\to\mathbf{Cat}.$ A representation is not enough to produce a state, so we add the additional data in the category of representations to include a normalized vector. Morphisms in this category are then taken to be intertwining isometries preserving unit vectors. Thus, we write $\mathbf{Rep}^{\bullet}:\mathbf{C}^*\text{-}\mathbf{Alg}^{\mathrm{op}}\to\mathbf{Cat}$ for this new functor. The codomains of $\mathcal{S}$ and $\mathbf{Rep}^{\bullet}$ are not the same so it does not make sense to compare them. By viewing every set as a discrete category, we can take the codomain of $\mathcal{S}$ to be $\mathbf{Cat}$ as well. To distinguish $\mathcal{S}$ from this functor, let's call the latter $\mathbf{States}.$ 
Statement: The GNS construction furnishes a pseudo-natural transformation $\mathbf{GNS}^{\bullet}:\mathbf{States}\Rightarrow\mathbf{Rep}^{\bullet}.$

It is not a strict natural transformation. Technically, it is a 1-morphism in the 2-category of functors from $\mathbf{C}^*\text{-}\mathbf{Alg}^{\mathrm{op}}$ to $\mathbf{Cat}.$ The objects here are functors, 1-morphisms are pseudo-natural transformations (natural transformations that satisfy naturality up to a higher coherence), and 2-morphisms are modifications.
Universal property: The GNS construction is actually part of an adjunction in this 2-category mentioned in the previous paragraph. It is left adjoint to the natural transformation (which is an honest natural transformation) that takes a representation with a unit vector and simply pulls back the canonical state associated to this unit vector to the underlying $C^*$-algebra.
[There is supposed to be an image here---sorry, not enough reputation points---please see the introduction in the paper below]
More details can be found in https://arxiv.org/abs/1609.08975 "From observables and states to Hilbert space and back: a 2-categorical adjunction," which was coincidentally posted not long after your question, though I was unaware of this until now.