Checking updates
This tutorial explains how to implement the updates checking routine with Harmony.
This routine is particularly helpful when some source of information needs to be checked regularly for new content. The use cases are:
- Hunting for the opportunities to buy or rent an apartment, used car, or other objects that require some hunting on the market.
- Checking new events, movies, meetups, etc.
- Checking new emails in the mailbox.
Algorithm
- Grab content items from the page using get_page_content or get_page_data.
- Format each item in human language.
- Check if these items were already shown using read_record.
- Remember shown items using write_record.
Example
We’ll use Google Mail as an example, asking the agent to show the emails that it didn’t show before.
The second step is to get emails that were not shown yet. It can be done by prompting the agent with:
You are the assistant who helps me read my email by showing me important emailsthat I didn't see before. Follow the guidelines below to do that.
# Guideline
1. Get new emails by calling the tool `get_google_mail_emails` with `url: https://mail.google.com/mail/u/0/`.2. Remove advertisements and other unimportant emails from the list.3. Remove the emails that were already shown to me (the list of shown emails is provided below).4. Show me the emails in the format "Subject (From)" (e.g., "Tests of electrical installation (Coworking)"). If the list is empty, let me know that there is no unread emails.5. Save these emails to the list of shown emails using the tool `write_record` with `key: viewed_google_emails`, `method: prepend`, `keep_lines: 100`, `value: [list of emails separated by a double new line in the format "Subject (From)"]`.
# The list of emails that I already saw (do not show me these emails again)Comments:
-
The creation of the tool
get_google_mail_emailsis described in Structured data tool tutorial. -
Attach the list of shown emails to the prompt by using the “attachments” menu (clip icon right under the query input), and selecting “Tool” from the dropdown list. In the tool panel, select the tool “read_record” with arguments
Key: viewed_google_emailsandDefault value: no viewed emails yet. The default value is needed to prevent the error in case there is no record with such key yet. Note that attachments are added after the prompt that is why ”# The list of emails that I already saw” title is added there. -
The URL
https://mail.google.com/mail/u/0/for the tool is provided to force it to open the mailbox in the new browser tab because it wouldn’t always be the case that the mailbox is already opened. -
“Remove advertisements and other unimportant emails from the list” is an optional step. You may also instruct the agent more precisely on what emails should be skipped.
-
Run the prompt and check how does it work. Note that if the list of unread emails is big, executing the prompt may take some time. You should see the response something like:
▸ Calling tool: read_record ...▸ Calling tool: execute_agent_query ...▸ Calling tool: get_google_mail_emails ...▸ Calling tool: get_page_data ...▸ Calling tool: write_record ...
Here are your new important emails:
* Tests of electrical installation (Coworking)* ...- Save the prompt as a task for future use by choosing “Task -> Create task” in the prompt menu.
- Main:
- Task name: “Google Mail: Get unviewed emails”
- Tool: “Execute agent query”
- Arguments:
- Query: the prompt from the above (should be copied automatically)
- Attachments: the attachment from the above (should be copied automatically)
- Additional options
- Agent: Choose
gpt-4o-minior another fast agent to make the prompt execute faster - Allowed tools: Choose
get_google_mail_emailsandwrite_recordto provide an agent access to these tools
- Agent: Choose
- Now, “Get unviewed emails” is available in the quick actions panel.