Try using the headphones with the microphone attachment plugged into the headphone socket of the phone and check that you can be heard OK when on a call.
If you can be heard OK then there is a problem with the phone’s internal microphone or the voice inlet hole located on the bottom edge of the phone may be blocked with lint or other debris or even by a protective case if the phone is in one.
To eliminate the latter possibility, remove the phone from its protective case (if it is in one) and then try making a call etc. If it is not in a protective case try using a vacuum cleaner to clear any blockage from the voice inlet hole, do not use a pin or probe to try and clear it as you may damage the microphone which is behind the hole.
If clearing the voice inlet hole doesn’t solve the problem then most probably there is a problem with the microphone itself or perhaps it may be a software problem.
Try the following to determine if it is software or hardware that is the cause.
Wipe the cache partition and then check if you can be heard OK when on a call.
Start the phone in safe mode and check if you can be heard OK. If you can be heard OK when using the phone in safe mode then a downloaded app is the cause of the problem. The trick is to find out which one. A downloaded app is one that you installed on the phone and not one that came pre-installed with the phone when you first got it.
If neither of these resolves the problem then most likely it is a hardware problem on the systemboard.
The phone would have to be opened and the microphone checked and or replaced. Here’s the ifixit Samsung Galaxy J6 Teardown guide for the phone which may help. Unfortunately, if the microphone is faulty I have been unable to find a replacement part online. You may have better luck.
Hopefully this will help you to find the problem with the phone.