Sometimes, commands provide an option to avoid any user interaction so that they can be run unattended (e.g. -y for apt).
When this isn't the case, you can pipe to stdin instead:
# Using pipes and echoecho-e"yes\nno"|your_command
# Using a fileecho-e"yes\nno">file.txt
your_command<file.txt
# Using a HEREDOC (not POSIX)your_command<< INPUTyesnoINPUT# Using a HERESTRINGyour_command<<<$'yes\nno'