Try this:
var oldUserInteractionLevel = app.scriptPreferences.userInteractionLevel;
app.scriptPreferences.userInteractionLevel = UserInteractionLevels.NEVER_INTERACT;
// Put code here that would create the alert.
// E.g. If the alert is caused by opening the document, then open the document here.
app.scriptPreferences.userInteractionLevel = oldUserInteractionLevel;
// After this line you can safely show dialogues to the user.