Intention recognition has significant applications in ambient intelligence, for example in assisted living and care of the elderly, in games and in intrusion and other crime detection. In this paper we propose an intention recognition system based on the event calculus. The system, called WIREC, exploits profiles, contextual information, heuristics and any available integrity constraints together with plan libraries and a basic theory of actions, causality and ramifications. Whenever the profile and context suggest there is a usual pattern of behaviour on the part of the actor the search for intention can be focused on existing plan libraries. On the other hand, when no such information is available or if the behaviour of the actor deviates from the usual pattern the search for intention can revert to the basic theory of actions, in effect dynamically constructing partial plans corresponding to the actions executed by the actor.