There is a tail gate relay that sounds like is acting up. Here is a guide and some tailgate wiring diagram to help you do some testing and get the problem fixed.
Repair Safety Notice: This information is for general instructional purposes only. Vehicle repair can be dangerous. Verify all information, follow manufacturer service procedures, use proper tools and safety equipment, and consult a qualified repair shop when needed.