If I understand the question correctly, this is a good answer.
According to both Avos Derabbi Nasan and Rashi (as well as various other Mefarshim to Bamidbar 24:14), the Torah specifically states that Bil'am advised Balak in this capacity, and it immediately precedes the story of the Jews sinning with the daughters of Midian/Moav. Here is how Rashi puts it (Alhatorah translation):
לך איעצך COME AND I WILL COUNSEL THEE what you have to do. And what is the counsel? The God of these people hates unchastity, therefore tempt them to sin by means of thy women-folk, as is related in the chapter חלק (Sanhedrin 106a) — You can know that it was Balaam who gave this counsel, to make them fall by the sin of unchastity, for it is stated, of the women of Midian (Numbers 31:16), "Behold, these were an enticement to the children of Israel through the word of Balaam".
אשר יעשה העם הזה לעמך WHAT THIS PEOPLE SHALL DO TO THY PEOPLE – This is an elliptical verse, the meaning being: I will give thee counsel how to make them fall into sin, and I also will tell thee what evil they will once do to thy people Moab in later days: viz., (v. 17) "they will pierce the corners of Moab". — The Targum explains at length what is implied by the terseness of the Hebrew text ("Come I will give thee counsel what thou shouldst do and I will show thee what this people etc.")