You'll receive this randomly triggered quest — limited to the settlements aligned with The Minutemen — by speaking to Preston Garvey or listening to Radio Freedom. Once received, head to the designated settlement and speak to the marked settler for the details.
You'll need to build defenses in anticipation of a coming raid, so construct turrets until you satisfy the quest's requirements.
Shortly after this (you might need to wait by sitting or sleeping one hour at a time), the invaders will arrive. To ease the burden on the turrets, take out any enemies you find. Note that some invaders might come from other factions, if they oppose The Minutemen. After you've saved the settlement, speak with the marked settler and then see Preston Garvey for your reward.