A connector is provided for connecting a deformable bag (2) for liquid or semi-liquid products to a machine (3) for distributing the product and comprises a body (4) with an opening (5) passing therethrough and acting as a product outlet and connected to the machine (3), with a thermal sensor (10) supported so as to be positioned inside the bag (2), in contact with the liquid or semi-liquid product. The sensor (10) is fixed in a second opening (25) that is parallel or almost parallel to the product transit opening (5) and a connecting cable (11) comes out of the end of the body intended to remain outside the bag (2). Also described is the assembly formed by the bag and the connector and the machine for distributing a liquid or semi-liquid food product supplied with the bag (2) equipped with the connector (1).