"Unveiling the Wonders of Coda, One Day at a Time" |
|
|
Happy Wednesday!
Us old-timers remember the days of movie rental stores.
When you wanted to watch something, you had to plunk out money and you had 24-48 hours to watch.
It could add up quickly if you were a movie buff.
Then came Netflix, which solved all of our problems by giving us a flat fee for movie rentals.
Then came Hulu, Disney+, Paramount+, Peacock . . . and now we're back in the same boat again.
AI is following the same track. We pay a "small" usage fee to use AI, but as we are dumping more and more context into our prompts, bills will be dramatically increasing.
For our Gmail AI Labeler, we could send the rules EVERY single time with EVERY single email, but that would potentially be a costly tool.
Automation should be about cost savings, not just time.
Instead of sending the email rules every time, we're going to set up an OpenAI Assistant.
OpenAI Assistants are basically chatbots with all of the context and instructions pre-loaded.
You pay for your tokens, but the cost for the OpenAI Assistant is only $.03/session.
Here are our OpenAI Assistant instructions:
Prompt:
Analyze the following email and determine if it matches any specified labeling rules. The email content is enclosed between EMAIL START and EMAIL END. Individual rules are enclosed in RULE START and RULE END.
Each rule contains:
PROMPT START and PROMPT END: Specific instructions for matching the rule.
FROM START and FROM END: Keywords or phrases expected in the sender's name or email.
TO START and TO END (optional): Keywords or phrases expected in the recipient’s email.
SUBJECT START and SUBJECT END (optional): Keywords or phrases that should appear in the email subject.
CONTENT START and CONTENT END (optional): Keywords, phrases, or topics expected in the email body.
LABELS START and LABELS END: Labels to apply if the email matches all specified criteria.
Instructions:
For each RULE START/RULE END block, follow the specific instructions between PROMPT START and PROMPT END.
Review the criteria for sender, recipient, subject, and content as specified within each rule.
If all criteria in a rule are met, return the labels listed in LABELS START/LABELS END for that rule in the output JSON.
If no rule matches, return "labels": ["No match"].
Email Details:
{
"from": "[Sender's email/name]",
"to": "[Recipient's email]",
"subject": "[Email subject]",
"content": "[Email body/content]"
}
Output Format: If a rule matches, output:
{
"labels": ["label1", "label2"]
}
If no rule matches, output:
{
"labels": ["No match"]
}
This structure ensures that each rule is evaluated according to the specific instructions in PROMPT START and PROMPT END, while matching the email details against criteria in each rule to determine the appropriate labels.
RULES
Wait a minute, do we have to go into OpenAI to update the assistant every time we change rules?
I thought we're storing the rules in Coda to make this easier.
No, we don't have to go into OpenAI . . . n8n is going to do this for us!
Here's the n8n workflow so far:
- We're going to get all of the rules from Coda
- Aggregate all the rules together
- And then we update the OpenAI assistant with the latest version of the instructions and rules
This ensures that we have the latest and greatest from Coda!
Here's how we update the assistant in n8n . . . notice that there is NO CODE!
We're ALMOST done . . . tomorrow we'll generate the labels using our assistant and some sample emails!
See you then!
|
|
Troy Larson
CODA MAGIC™️ , CEO | SOFTWARE DEVELOPER | CODA MAKER
|