Where to do pre processing on text

I am developing a bot,i am able to run a bot with rest and socket. i just wants to do some preprocessing by spacy or nltk on text before passing it to nlu and core component. where can i write this code.

In a custom component.