A 12V 40A "Bosch" style relay, a bunch of heavy ga wire and most important.. A BIG FUSE within 18" of the truck battery.
So, you have truck battery, then fuse, then fuse connects to the common terminal of the relay, the normally open (N.O.) terminal of the relay connects to your heavy ga wire which then goes to the trailer charging connection on the truck 7 pin connector.
One side of the relay coil is grounded and the other side of the coil goes to a KEY ON switched power (you will need to hunt this down since it is difficult to say where you will find that now days).
Wire ga size, well 8ga might be a good place to start..
Fuse size, size no larger than allowable current of the wire size or the lightest part (like the 7 pin connector).
10 ga wire 30A max fuse
8 ga wire 40A max fuse.
Any larger wire and I would say you are going to melt the 7 pin connector if you fuse larger than 40A..