how to make a send request and accept request chat app?

Suppose I am making a chat app. One user will only be able to chat with another user if he accepts his request. Basically first user sends message to other user. The second user accepts by clicking on the accept button … and then the friend list is created and they are able to communicate. Can anyone tell the request sending and accepting button code?