'Python get messages received on Gmail at time

I'm trying to create a simple bot that whenever I get a message on Gmail, it write the content on a file, for now I only have a cron scheduler that get the messages within a interval of 2 minutes, but the best choice would be to get the message as I said, when I receive them in real time.

I didn't find much on the googleapis for gmail tho. For what I know I should create a websocket and then after that, how could I have the messages I just received



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source