Skip to main content

12.01.5 Using AI to Draft Responses to User Emails

As an example of using AI nodes, let's create a scenario that triggers upon receiving a new Gmail message. The result will be a draft reply email with text generated by AI. During the scenario execution, we'll use AI to classify the text to determine if it contains a question. Based on the classification results, the instructions for drafting the reply will differ.

Since any AI model requires instructions that may vary, we'll define several variables in the scenario:

  • Response format
  • Response length
  • Role of the responder

We'll use the AI Anthropic Claude 3 node from the AI ChatGPT Alternatives group to generate the text.

To successfully execute the scenario, we'll need to add several nodes and conditions in the routes:

  • (1) New Email node to trigger the scenario upon receiving a new email and to obtain its information. The output data will include the email content. Authorization is required to use this node.
  • (2) SetVariables node to create the necessary text variables:

Length of the response - Length

Role of the responding user - Role

Format of the response - Format

  • (3) interrogative route to branch the scenario if the email is interrogative in nature. To configure this route, set the condition {{askAI("\rIf the text \"" + $1.data.decodedContent + "\" contains the character \"?\" or is interrogative in nature return true, otherwise false") = "True"}}
  • (4) AI Anthropic Claude 3 interrogative node to generate a response to the interrogative email based on the given instructions. Configure this node by filling in the Model and User Prompt fields. The User Prompt field can be filled using the variables created in the SetVariables node, for example:

Generate a reply letter to the question {{$1.data.decodedContent}}. In your reply, indicate that the question has been accepted and an answer will be generated soon. Recipient of the response {{$1.data.from}}. Role of the responder {{_.Role}}. Format of the response is {{_.Format}}, and size of the response is {{_.Length}}.

  • (5) Create Draft Reply interrogative node to create a Gmail draft with the text generated by the AI Anthropic Claude 3 interrogative node. To configure this node, authorize access and select the parameters from the previous nodes.
  • (6) narrative route to branch the scenario if the email is not interrogative, i.e., the interrogative route condition is not met. To configure this route, set the condition: {{askAI("\rIf the text \"" + $1.data.decodedContent + "\" contains the character \"?\" or is interrogative in nature return true, otherwise false") != "True"}}
  • (7) AI Anthropic Claude 3 narrative node to generate a response to the non-interrogative email based on the given instructions. Configure this node by filling in the Model and User Prompt fields. The User Prompt field can be filled using the variables created in the SetVariables node, for example:

Generate a draft response to a letter with the text {{$1.data.decodedContent}}. Recipient of the response {{$1.data.from}}. Role of the responder {{_.Role}}. Format of the response is {{_.Format}}, and size of the response is {{_.Length}}.

  • (8) Create Draft Reply narrative node to create a Gmail draft with the text generated by the AI Anthropic Claude 3 narrative node. To configure this node, authorize access and select the parameters from the previous nodes.

The result of the scenario execution is a draft reply email with content generated by AI.

Example 1

Incoming Email:

Generated Draft:

Example 2

Incoming Email:

Generated Draft:

Example 3

Incoming Email:

Generated Draft:

Example 4

Incoming Email:

Generated Draft: