Open the Messages app
Tap Edit in the top-left corner
Tap Show Recently Deleted
Select the conversations or messages you want to recover
Tap Recover
Tap Recover Messages to confirm
If you do not see the option, check whether the messages were deleted more than 30 days ago
If needed, restore from an iCloud or computer backup to recover older deleted messages
