/ chat commands via ui

Hello how hard would it be if at all possible to assign a /chat command to a button that shows inside the UI and when pressed runs the command and closes the UI ?   Thanks 

you would have to look at binding a key to do chat say.