You'll have to set up key authentication so you will be able to use a here-script for automation.
sftp does not work with feeding a password in a script. That's unsecure and that's why keys should be used.
If possible and key authentication is set up, maybe use scp instead of sftp. Might be more comfortable than using a here-script.
For how to set up a passwordless key based communication with ssh/scp/sftp search this forum or the web, there are plenty of guides.
Don't forget to enter no password when creating the key pair with ssh-keygen.