Level
1st
Casting Time
1 Minute
Ritual
Range/Area
30 ft
(20 ft )
Components
V, S, M *
Duration
8 Hours
School
Abjuration
Attack/Save
None
Damage/Effect
Detection
You set an alarm against intrusion. Choose a door, a window, or an area within range that is no larger than a 20-foot Cube. Until the spell ends, an alarm alerts you whenever a creature touches or enters the warded area. When you cast the spell, you can designate creatures that won’t set off the alarm. You also choose whether the alarm is audible or mental:
Audible Alarm. The alarm produces the sound of a handbell for 10 seconds within 60 feet of the warded area.
Mental Alarm. You are alerted by a mental ping if you are within 1 mile of the warded area. This ping awakens you if you’re asleep.
* - (a bell and silver wire)
Alarm Legacy This doesn't reflect the latest rules and lore. Learn More Basic Rules, pg. 211
Link to the legacy version of this spell
I believe that you should be able to infuse a spell into the alarm. So to begin to cast the spell (instead of sounding the addible or mental alarm) on who-ever or what-ever set it off.
That’s what Glyph of Warding is for or even Magic Mouth.