Skip to content
NEWMarketplace and your team: sell what you build, and get plans and changes that are tested before you see them. See what is new

Library / Email Automation

Email Automation

Answer currency rate questions from Gmail and chat with Gemini and Frankfurter API

When a chat message arrives, it handles email with Google Gemini using Chat, Data Table, Gmail.

What it does

## Answer currency rate questions from Gmail and chat with a cached AI agent Who's it for Anyone who wants a reusable pattern for an AI agent that serves several channels and avoids paying for the same model call twice. Exchange rates are only the example: swap the tool for any read-only API. How it works 1. Chat and Gmail messages are normalized to the same fields and processed one at a time. 2. The workflow detects two ISO currency codes (for example "USD to EUR") and looks for a fresh cached answer for that pair and date. 3. On a cache hit the model is not called. On a miss, a Gemini agent queries the free Frankfurter API and the answer is cached. 4. Every query is logged (channel, cache hit, latency) so you can measure the savings. The reply goes back through the channel it came from. How to set up - Create the Data Table Currency cache with columns cache_key (string), pair (string), response (string), cached_at (number). - Create the Data Table Query log with columns logged_at (string), source (string), pair (string), cache_hit (boolean), latency_ms (number). - Select the tables in the 3 Data Table nodes and add your Gemini and Gmail credentials. - Review the Set configurable variables node and the filter in Receive email from Gmail. Requirements Google Gemini API key, Gmail account, n8n with Data Tables. Frankfurter needs no API key. How to customize Replace the Get Exchange Rate tool and the agent prompt, and adapt Build cache key so that equivalent questions produce the same key.

The steps

  1. Receive chat message
  2. Receive email from Gmail
  3. Normalize chat message
  4. Normalize email message
  5. Loop over messages
  6. Set configurable variables
  7. Build cache key
  8. Lookup cached answer
  9. Cached answer still fresh?
  10. Use cached answer
  11. Ask currency AI agent
  12. Gemini Chat Model
  13. Conversation memory
  14. Get Exchange Rate

24 steps in total.

Similar automations