N8N Google Calendar AI Bot

Im working in an Telegram Bot to work as an Calendar Assistant and Im trying to use Google Freebusy API to obtain currently busy times to propose available slots for the meeting. My problem is that API return the time in Greenwich time zone and I need to convert it to São Paulo time zone. The http response is a string even when I try to force it to json. I asked IA to convert from Greenwich to São Paulo but it do not work as well.

What is the error message (if any)?

Please share your workflow

Share the output returned by the last node

[\n {\n “kind”: “calendar#freeBusy”,\n “timeMin”: “2024-11-22T03:00:00.000Z”,\n “timeMax”: “2024-11-23T03:00:00.000Z”,\n “calendars”: {\n “primary”: {\n “busy”: [\n {\n “start”: “2024-11-22T12:30:00Z”,\n “end”: “2024-11-22T15:00:00Z”\n },\n {\n “start”: “2024-11-22T17:00:00Z”,\n “end”: “2024-11-22T19:30:00Z”\n },\n {\n “start”: “2024-11-22T20:30:00Z”,\n “end”: “2024-11-22T21:30:00Z”\n }\n ]\n }\n }\n }\n]

Information on your n8n setup

  • n8n version: 1.67.1
  • Database (default: SQLite): Poistgress
  • n8n EXECUTIONS_PROCESS setting (default: own, main): own
  • Running n8n via (Docker, npm, n8n cloud, desktop app): Docker
  • Operating system: Debian 12

Hey @Victor_Halla!

You could use the code node and use one of the date/time JavaScript functions to convert it. Something like this?

const dateString = "2024-12-02T12:00:00Z"; // Input date in GMT
const dateInGMT = new Date(dateString);

// Format date in São Paulo timezone - decide what's needed
const options = {
  timeZone: "America/Sao_Paulo",
  year: "numeric",
  month: "2-digit",
  day: "2-digit",
  hour: "2-digit",
  minute: "2-digit",
  second: "2-digit",
  hour12: false,
};

const formatter = new Intl.DateTimeFormat("en-US", options);

// ISO 8601 date in São Paulo time
return new Date(formatter.format(dateInGMT));