Skip to main content

Hi All,

 

Please help me to create a Bot to log into a Gmail mailbox and delete all its messages using Gmail API.

 

Thanks,

Shivansh

@Shivansh15  How about posting what you have tried on your own? We’d then be happy to help.


That’s an interesting question, Shivansh15 !

I think the following community members may be able to help 

@ChanduMohammad 

@Zaid Chougle 

@Tamil Arasu10 

@Paul Hawkins 

@Padmakumar 


Hi ​@Shivansh15 ,

 

In a nutshell, the logic will be as shown below.

 

  1. Set up Google Cloud Project and Enable Gmail API:

    • Create a project in Google Cloud Console.
    • Enable the Gmail API for that project.
    • Create OAuth 2.0 credentials (Client ID and Client Secret) for a desktop or web application.
  2. Authenticate and Obtain Access Token:

    • Use OAuth 2.0 to authenticate the user and obtain an access token with Gmail scopes (

      https://www.googleapis.com/auth/gmail.modify

       or 

      https://www.googleapis.com/auth/gmail.delete

      ).
  3. Use Gmail API to List and Delete Messages:

    • Use the API endpoint 

      users.messages.list to get message IDs.

    • Use 

      users.messages.delete or 

      users.messages.batchDelete to delete messages.

  4. Automate this Using A360 Bot:

    • Use HTTP Request actions to call Gmail API endpoints.
    • Handle OAuth 2.0 authentication flow (can be complex; consider using a script or external tool to get tokens).
    • Loop through messages and delete them.

Reply