<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Ann Chisom Sokwueaku </title>
    <description>The latest articles on DEV Community by Ann Chisom Sokwueaku  (@sonwa).</description>
    <link>https://dev.to/sonwa</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3242859%2Fafdb2aba-0027-4643-bc00-72f9426814d9.png</url>
      <title>DEV Community: Ann Chisom Sokwueaku </title>
      <link>https://dev.to/sonwa</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/sonwa"/>
    <language>en</language>
    <item>
      <title>How I Built a Timezone-Aware Email Automation Using n8n + OpenAI</title>
      <dc:creator>Ann Chisom Sokwueaku </dc:creator>
      <pubDate>Tue, 24 Jun 2025 11:32:20 +0000</pubDate>
      <link>https://dev.to/sonwa/how-i-built-a-timezone-aware-email-automation-using-n8n-openai-2ij0</link>
      <guid>https://dev.to/sonwa/how-i-built-a-timezone-aware-email-automation-using-n8n-openai-2ij0</guid>
      <description>&lt;p&gt;I recently built an automated email outreach system using &lt;a href="https://n8n.io" rel="noopener noreferrer"&gt;n8n&lt;/a&gt; + OpenAI, and it only sends emails during the &lt;em&gt;lead's local business hours&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Here’s what the flow looks like:&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F845sfh21v5yulnijaj3j.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F845sfh21v5yulnijaj3j.png" alt="Image description" width="800" height="186"&gt;&lt;/a&gt;&lt;br&gt;
This is the code used to check for the&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;return items.map(item =&amp;gt; {
  // Use timezone from assistant's response (e.g. item.json.message.content)
  const timezone = item.json.message?.content || "UTC";

  try {
    const now = new Date();
    const formatter = new Intl.DateTimeFormat('en-US', {
      timeZone: timezone,
      hour: 'numeric',
      hour12: false,
    });

    const parts = formatter.formatToParts(now);
    const hour = parseInt(parts.find(p =&amp;gt; p.type === 'hour')?.value || "0", 10);

    return {
      json: {
        ...item.json,
        currentHour: hour,
        isWithinBusinessHours: hour &amp;gt;= 8 &amp;amp;&amp;amp; hour &amp;lt; 18,
        timezoneChecked: timezone
      }
    };
  } catch (err) {
    return {
      json: {
        ...item.json,
        error: `Invalid timezone: ${timezone}`,
        currentHour: null,
        isWithinBusinessHours: false,
        timezoneChecked: timezone
      }
    };
  }
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;current time `&lt;/p&gt;

&lt;p&gt;Why I Built This&lt;/p&gt;

&lt;p&gt;Sending cold emails at 3 AM in the recipient's timezone? Bad idea.&lt;/p&gt;

&lt;p&gt;This automation ensures:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Higher open rates&lt;/li&gt;
&lt;li&gt;Professional timing&lt;/li&gt;
&lt;li&gt;Less chance of being marked as spam&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Tools Used&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;n8n – Automation logic and orchestration&lt;/li&gt;
&lt;li&gt;Google Sheets – Where I store leads&lt;/li&gt;
&lt;li&gt;OpenAI GPT – Detect timezone + generate emails&lt;/li&gt;
&lt;li&gt;Custom Delay Logic – Wait until local business hours&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Workflow Steps&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Read leads from Google Sheets&lt;/li&gt;
&lt;li&gt;Check status (if they’ve already been emailed)&lt;/li&gt;
&lt;li&gt;Use OpenAI to infer the timezone (from country or city)&lt;/li&gt;
&lt;li&gt;Check the current hour in their timezone&lt;/li&gt;
&lt;li&gt;If too early/late, wait for 3 hours&lt;/li&gt;
&lt;li&gt;Once it’s a good time, generate a personalized email&lt;/li&gt;
&lt;li&gt;Send it, log it, and notify me of errors&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Output&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Emails only go out between 9 AM–5 PM local time&lt;/li&gt;
&lt;li&gt;Each one is AI-personalized&lt;/li&gt;
&lt;li&gt;Everything is logged in Sheets&lt;/li&gt;
&lt;li&gt;I get notified once there is an error&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Feedback?&lt;br&gt;
I would love to hear:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;How do you scale or modularize this&lt;/li&gt;
&lt;li&gt;How to make it more robust for thousands of leads&lt;/li&gt;
&lt;li&gt;If there's a better approach for timezone detection&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let’s connect!&lt;br&gt;
Thanks for reading&lt;/p&gt;

</description>
      <category>ai</category>
      <category>productivity</category>
      <category>automation</category>
      <category>n8n</category>
    </item>
  </channel>
</rss>
