Summary
Highlights
The video starts by recalling the previous session about connecting n8n with Gmail. The goal is to set up an automated process to send emails. The presenter emphasizes that connecting n8n to Google's Gmail API requires understanding the authentication process.
The presenter explains that a Google account holds various services like Gmail, Google Drive, Contacts, and Photos. n8n specifically needs to access only Gmail for this application. To establish this connection, an API (Application Programming Interface) is used, which defines rules and protocols for communication between n8n and Gmail.
An analogy of a house with different doors (Gmail, Google Drive, Contacts, Photos) is used to illustrate how n8n needs to access only a specific 'door' (Gmail) within the Google account. This requires a specific 'key' and 'secret' to prevent unauthorized access to other parts of the account.
Google uses OAuth 2.0 (Authentication Server) for secure access. n8n introduces itself to this server using a 'Client ID' and a 'Client Secret'. These act as keys to grant n8n specific permissions, like sending emails via Gmail, without accessing other Google account data.
The video guides through setting up a Google Cloud project. This involves creating a new project, naming it, and enabling the Gmail API. This is the first step in generating the Client ID and Client Secret.
The next step is to configure the OAuth consent screen. This includes setting the application name (n8n), user support email, and selecting the user type (external) since it's not an internal organization application. This step ensures users are aware of what n8n is trying to access.
The presenter demonstrates creating the OAuth Client ID and Client Secret. This involves specifying the application type as 'Web application', naming it, and providing the redirect URI from n8n. The redirect URI is crucial for Google to verify requests from n8n.
Once the Client ID and Client Secret are generated, they are copied from Google Cloud and pasted into n8n's credentials section. It's important to save the Client Secret immediately as it won't be accessible again after closing the window.
A critical step is adding the email address that will be used for n8n in the 'Test Users' section of the Google Cloud console. This allows n8n to connect successfully. After this, signing in from n8n using that email will establish a successful connection.
The video then demonstrates how to send an email using the newly established connection. This involves selecting 'Send Message' on n8n's Gmail node, specifying the recipient email, subject, and the message content, which can be dynamically pulled from the n8n chat input.
A live demonstration shows sending a test message from n8n's chat. The message is successfully sent to the specified email address, verifying the integration works. The sent email in the recipient's inbox confirms the subject and content from n8n.
The presenter reviews the execution history in n8n, showing the details of successful email sends. It also briefly touches on how data is handled in n8n, such as input/output formats (schema, table, JSON) and how the trigger node only has output.
The video concludes by reiterating the simplicity of connecting n8n with Gmail using these steps and encourages viewers to try it, emphasizing the benefits of self-hosting n8n (free and unlimited executions). The next video will cover more advanced applications.