If the sender of a message appears in your message list as a phone number, or occasionally an email address, you will be able to add this information to your contacts. Messages which give a name will either be from people already in your contacts or from senders who don't want to receive replies. Here's what you need to do if a message comes from a phone number or email address.
Open the Messages app. If the app is in the conversation list view you should have a Messages heading near the top of the screen. If you aren't on this screen, you probably have an individual conversation open on screen and there will be a back button at top left indicating the number of unread messages. Use this to return to the conversations list. Swipe or scroll through the list until you find the message whose sender you want to add to your contacts. Open the message with a double tap.
Close to the top centre of the screen is a large circular button which will speak the phone number or email address to VoiceOver users. VoiceOver users should locate and double tap this button and non VoiceOver users can just tap it.This will bring up a scree with an info button at the right, about a third down the screen. VoiceOver users can swipe right a few times to find this button. Double tap for VOiceOver or tap if not using VoiceOver the info button and you willl have a page containing options to create new contact or add to existing contact. Create new contact will take you to an edit contact screen and you will need to enter a name for the contact. The phone number or email address will automatically be filled. When you have finished, use the Done button at top right to save the contact. If you choose to add the information to an existing contact, you will be taken to your contacts list from which you will need to select the contact you wish to update. The number or email address wil automatically be added, so all you need do is use the Done button to save.