Introduction
Managing tasks and cards manually can be time-consuming. By automating card creation in Nextcloud Deck from incoming emails using n8n, you streamline workflow and save valuable time. This tutorial explains how to set up a seamless process that reads emails, strips HTML content, and posts it as a card to your Nextcloud Deck board.
Workflow Overview
The automation consists of three main nodes in n8n:
- IMAP Email: Reads incoming emails from your mailbox.
- Function: Cleans the email content by removing HTML tags, line breaks, and unwanted characters.
- HTTP Request: Posts the cleaned information as a new card in a designated Nextcloud Deck board and stack.
Step 1: IMAP Email Node
Configure this node to connect with your email server using the IMAP protocol.
- Provide your email credentials.
- Define the mailbox and search criteria (e.g., unread emails).
- This node fetches emails regularly for processing.
Step 2: Function Node – Strip HTML Code
This node processes the email content to convert HTML emails into plain text for better readability and card formatting.
// Loop over all incoming emails
for (item of items) {
if (item.json.textHtml) {
// Replace <br> tags with newline, remove HTML tags, and unnecessary characters
item.json.body = item.json.textHtml.replace(/<br(\\s*?\\/?)>/g, "\n").replace(/(<([^>]+)>)/g, "").replace(/\"/g, "");
} else {
// If no HTML, just clean up the plain text
item.json.body = item.json.textPlain.replace(/\"/g, "").replace(/\n/g, "\n").replace(/\r/g, "");
}
}
return items;
Step 3: HTTP Request Node – Add Card to Nextcloud Deck
This node requires your Nextcloud instance URL and credentials.
- Set the request method to
POST. - Use the API endpoint:
/index.php/apps/deck/api/v1.0/boards/YOUR-BOARD-ID/stacks/YOUR-STACK-ID/cards - Set headers:
OCS-APIRequest: trueContent-Type: application/json- Send the JSON body with the card title and description mapped from your email subject and cleaned body.
Final Notes
This automated flow enables your Nextcloud Deck board to always be updated with new cards derived directly from your emails, making project and task management more efficient. Remember to replace placeholder IDs and credentials with your actual Nextcloud board and stack details.
Call to Action
Ready to automate your workflow? Set up this n8n automation today and supercharge your productivity with Nextcloud Deck!
