Alarm email if doors remains open for longer time

I do something similar with lights left on when my presence is not detected in the house.

I use the telegram binding to ask question


rule "Send telegram with question"
when
    Item Presence changed to OFF
then
    val telegramAction = getActions("telegram","telegram:telegramBot:2b155b22")
    telegramAction.sendTelegramQuery("No one is at home, but some lights are still on. Do you want me to turn off the lights?", "Reply_Lights", "Yes", "No")
end

Handle incoming mesage

rule "Reply handler for lights"
when
    Item telegramReplyId received update Reply_Lights
then
    val telegramAction = getActions("telegram","telegram:telegramBot:2b155b22")

    if (telegramMessage.state.toString == "Yes")
    {
        gLights.sendCommand(OFF)
        telegramAction.sendTelegramAnswer(telegramReplyId.state.toString, "Ok, lights are *off* now.") 
    }
    else
    {
        telegramAction.sendTelegramAnswer(telegramReplyId.state.toString, "Ok, I'll leave them *on*.")
    }
end