Firebase Functions Help

So, I have a chat app. In that chat app, I am starting to use firebase functions with it.

I would like guidance on how would I trigger a firebase function when a document updates.

What I eventually want to do is in that update function, to create a document in notifications, and then send notifications using firebase-messaging.

Thanks!