Stop replying to email manually! Customer Support AI Assistant on Latenode

No-code Expert, Latenode Ambassador
January 31, 2024
A low-code platform blending no-code simplicity with full-code power
Get started free
Table of contents

Say no to chaotic work. Automate your tasks now.

Hey! Daniel from Latenode is here! Email customer support is a very effective way of communicating with users, and it could be much more efficient with a little help from AI!

So, in this article, I’ll show you how to create an AI  Assistant that will answer the customer's questions via email, referring to attached files (product documentation in this case)with a detailed step-by-step instruction. All you need is ChatGPT Assistant API and Latenode- low-code automation platform.

By the way, I’ll leave a ready-to-go template of Latenode’s scenario in the end of this article, you’re welcome!

Let’s start!

Step 1: Creating Assistant & API key

That is simple. Log into your OpenAI account, then go to assistants, and click the “create” button in the upper right corner. You’ll see the assistant's settings panel.

Here you need to:

  1. Give your assistant a name
  2. Give it instructions on how you want it to answer, and some context. We recommend you to ask it to use attached files, ‘cause otherwise, it can forget to do it.
  3. Choose a model
  4. Select available tools and add files that the assistant can use. Don’t forget to turn retrieval on to make file adding possible.

The text file we’ve added contains the first chapter of Latenode documentation. We simply converted it from HTML to text, no editing. AI doesn’t need it, so do we then. Copy the assistant’s ID (you see it under the Name column), then go to API keys, create one and save it.

Now it’s time for some automations!

Step 2: Creating scenario

Now we switch to Here, we have to create this scenario: (You don't need to create it from scratch, just copy the template at the end of the article)

It looks for unread emails, sends their content to Assistant, and then sends generated answers to the users via Gmail. Lets’s break it down step-by-step to make things clearer.

Scenario breakdown:

  1. Schedule trigger: Activates the scenario at any period of time set.
  2. HTTP-request: Get list messages. This HTTP-request node gets the list of unread messages from our mailbox using a GET request from Google Workspace.
  3. Iterator: Allows to process every element in the array.
  4. HTTP-request: Get messages. Now we use HTTP-request node to get the data from every unread message.
  5. JavaScript node: Creates variables for senders emails and email bodies.
  6. Create Message: Generates a message for the assistant using created variables.
  7. Create Run: Sends this message to bot, generates the answer.
  8. Gmail node: Sends this answer to the user via Gmail.
  9. HTTP-request: Modify message. Marks messages as read.
  10. Create a Thread. 

As you can see, it is separated from the main scenario. That’s ‘cause we’ll execute this action only once. Yes, OpenAI recommends creating a new thread for every new conversation, but if you have a great number of requests, it is just cheaper to do it once. If you want, you can just put this node between JavaScript and Create Message node.

Webhook triggers are optional - you can add it if you want to activate the scenario out of schedule.

And now let’s see how to make it step-by-step:

Authorization token

Before creating a new scenario on, we need to go to Authorizations, and create a new one. Search for “google” here, and then choose Gmail. Then pass the registration using the email address where your users will send their questions to. You’ll get an access token that we’ll use in our HTTP-request.

Then go to scenarios and create a new one. Right after that, you’ll have to click “add node” and add the first node. That will be “create Thread”.

Creating a Thread

Let’s start building this scenario by adding a “create Thread” node and activate it using the “run once” button inside of this node. Click “add node”, then choose ChatGPT, there will be a list of available actions, “create thread” is what we’re searching for. All you have to do inside of this node is to insert  your OpenAI API key in the authorization column, and click run once after that. That will save the changes and generate a thread ID. You’ll see it in the output of this node.

Schedule trigger

Click ‘add node’, go to tools and choose schedule in the trigger section. In node’s settings, set the period of time your scenario will be activated at, choose the timezone and save the changes.

Get list messages

Now, it’s time for some HTTP-request.

Again, click add node, search for HTTP and choose it. Here we need to take the URL from Google Workspace and put it in the URL field of the node. 

Put the needed email address instead of {userId}, and add ?q=is:unread in the end, so you’ll get a list of unread messages only. 

Set get as a method. 

Then, add entry in headers, with “Authorization” as a key, and “Bearer” as value. 

Then click on the Value field and add the authorization token you’ve created. You’ll see it in the pop-up window if you click on the authorizations tab in it, and choose “google”. 

Finally, click run once. That will save the changes, test the node, and send data through it. You’ll see 


To add an iterator, click add node, then go to tools and choose the iterator in the action section.

It has only one field in settings, here you have to put messages array from the previous node.

Click on this field and choose the “messages” object in the helper widget. Don’t forget to click ‘run once’ after that!

Get messages

Add HTTP-request once more. This time, we can just copy the previous HTTP-request node (right-click on the node, copy. Then right click on empty space and paste) and change it a bit.

Again, use Google Workspace to fill out the URL field. Here you also have to replace {userId} with your email address. Put an ID object from the Iterator right after “messages”. You’ll see it in the Helper widget. At the end, the URL should look like this:[email protected]/messages/{{$}}

In addition to the first key-value pair, add the second one, with Content-Type as a value and application/JSON as a key. And of course, click “run once”.

JavaScript node

Traditionally, click “Add node”, go to “Code” and choose JavaScript. Here’s the code that you can put here:

export default async function run({ execution_id, input, data }) {
  let headers = JSON.parse(data["{{6.`body`.`payload`.`headers`}}"]); // Corrected the data path
  // from
  const email_from = headers.find((item) => === "From");
  const email_from_value = email_from.value.match(/<([^>]+)>/)[1]; // Use regex to extract email

  // snippet (content)
  const email_content = data["{{6.`body`.`snippet`}}"]; // Corrected the data path

  return {
    "email_from": email_from_value,
    "email_content": email_content

Reminder: It’s ready to use, you only have to change the number of previous node there.

But for the future, you  can use an AI assistant in this node that can help you with coding. Here’s a short article about it to set your AI Copilot using skills to a new level! After the code is ready, click “run once”.

Create message

Search for ChatGPT after you click on “add node”, and you see it. To set up this node, insert your OpenAI API key in the authorization field, Thread ID from “create Thread” node’s output. Put the email body object from the iterator into the message content field. After that, click “run once”.

Create Run

In this node you also have to Insert OpenAI API key and Thread ID, but also your Assistant ID, choose the model version, and select “true” in the Retrieval field. And click “run once”.

Gmail node

Select Gmail “send message” node in the app list. To set it up, you need to select your connection token for the needed email address. Then, put email_from variable from the JS node in the “To” field. Email Body field should be filled with text value from the Create Run node. Also, you can add here fixed text. Check the other fields for further customization. We’re almost finished!

Modify messages

Put this request from Google Workspace  in the URL field. Again, should be your email address, - valueID from Iterator. Method is POST here. Create the same key-value pair like in the previous node. Choose raw format of the body and insert this:

  "removeLabelIds": ["UNREAD"]

That’s it!

Save the scenario, deploy it, and here you are! You have an AI assistant which can answer customer emails for you!


Now you know how to create your own personal assistant who will answer user questions. Just as I said, this scenario is available as a template in Latenode’s template library, so, check this out!

If you have any questions, or facing troubles during your automation journey, I’m happy to let you know that Latenode has its Discord Channel, where you always can get some help from our team and growing community of low-code and automation enthusiasts.

Related articles:

Related Blogs