TIL about debconf-set-selections and so should you if you use Debian.
It allows pre-seting the answers to the questions that dpkg-reconfigure asks.
So you can like
dpkg-set-selections <<EOF
package1 package1/some/setting select foo
package2 package2/other/setting select bar
EOF
dpkg-reconfigure --frontend=noninteractive package1 package2
in your scripts