Pandoc is a tool for conversion between document formats, and supports docx and rtf.
It's a command line tool, so should be easy enough to integrate into almost any program.
https://pandoc.org/MANUAL.html#using-pandoc