I develop a behavioural New Keynesian macroeconomic model in which agents have cognitive limitations preventing them from having rational expectations. Instead they use simple forecasting rules and switch to the one that performs best. This model creates endogenous movements in optimism and pessimism (animal spirits). I use this model to analyse the optimal level of inflation targeting when there is a ZLB on the nominal interest rate. I extend the model to a two-country setup and I study the international propagation of animal spirits.