Is there any difference between an alert and a warning message? When it should be used, under what condition and scenario?
At a conceptual level an alert is usually a cue used to raise a users attention. For instance a phone may vibrate to send an alert that something requires attention.
A warning is usually related to the consequence of an action (or inaction). A warning can be given before or during an action, but not (usually) after.
Let's says you're running out of battery. Then an alert can be shown as a message. The text can simply say "Battery: 2%", which is contextual and may be interpreted as a warning. If the text says: "Battery low. Please recharge soon or device will shutdown." - then it's an alert shown as a message containing a warning.
In other words this discussion becomes a discussion about semiotics, signs and signifiers and signified meanings.
It's simple really. They are all alerts, dialogs, modals, etc.
Warning is the type of the alert along with Error, Information, and many more.
You could think of the two in terms of how critical the user message is, in the context of completing the task. Is the user able to proceed to the next step after the message? Or will they encounter an error? This should help you prioritize the different types of user messages and design accordingly e.g. a discreet snackbar/toast type of message box or huge pop-up overlay with bold, red text!
Generally, an alert is informational and contains additional info that needs to be communicated to the user.
A warning is used when the user cannot proceed to the next step unless the required action is taken. It is also used to let the user know that that the next step is difficult or impossible to recover, e.g. deleting files permanently or closing an account.