like nitrogen acts as a EWG and increase the positive charge on the conjugate acid which makes imidazole more basic since the pyrolle nitrogen is further away than pyrazole, it's a good explanation of the bascicity but im not convinced as to why it is an EWG as you seem to agree with...
Indeed, most of those molecules were bicyclic analogues of melatonin, in which the indole scaffold was replaced by almost any of the possible cycles organic chemistry can offer: naphthalene, chromane, quinoline, furopyridine, coumarine, benzothiophene, or more complex moieties such as phenalene, ...