Create a ICalendar .ics file with Method = cancel to remove event from calendar

Hello everyone,
Trying to manage events on user´s calendar by sending an email with .ics file. The problem I faced was creating a file to cancel the event. to do that the parameters from .ics file “Method” must be “cancel” and “status” must be “cancelled” (as far as i understood). Got it by creating a code node (javascript):

// Read the binary iCalendar file and convert it to text
let binaryDataBufferItem = await this.helpers.getBinaryDataBuffer(0, "data");

let icalData = binaryDataBufferItem.toString('utf8');

// Find and replace the "METHOD" property
let updatedIcalData = icalData.replace(/METHOD:PUBLISH/g, 'METHOD:CANCEL');

// Convert the modified iCalendar data back to binary format
let updatedBinaryData = Buffer.from(updatedIcalData, 'utf8');

const binaryData = await this.helpers.prepareBinaryData(updatedBinaryData, "event.ics", 'text/calendar');

let returnData=[{
					json: {},
					binary: {
						["data"]: binaryData,
					pairedItem: {
						item: 0,

return returnData

Now the problem is that google calendar creates another UID for the event when the user accepts. So the event won´t get canceled since the UID is the key.

Anyone with another solution?
Thanks in advance!

1 Like

Hi @sroques :wave: I’m going to be honest and say that I don’t entirely have a hunch here, but I’m also not sure exactly how n8n comes into play for you with this. The code node also wouldn’t be able to control Google behaviour, and this may be expected :see_no_evil: Could you share your workflow with us?

This information would also be helpful:

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:
1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.