We can't guess the model of your TV and the make and model of the soundbar so we can't give you an exact answer. There is no "automatic" way to set it up.
If both the TV and the soundbar have HDMI-ARC then you would connect the soundbar HDMI out to the HDMI-ARC input on the TV. There will only be one. Then you have to turn ARC on in the TV menu. You may also have to turn the TV speakers off and change the audio output type. Select ARC as your source on the soundbar.
If you don't have ARC on both then you will likely be able to connect the optical audio output of the TV to the soundbar. You will have to turn it on in the TV menu and select it as your source on the sounbar.
If you don't have matching TV audio output and soundbar audio...