亚马逊卖家邮箱邮件自动化助手
把买家邮件分类、草拟回复、跟进差评的动作交给 AI,附可直接用的提示词。
一、准备内容
开始前准备:
- 一个 Gmail 账号;
- 一个可用的 DeepSeek API Key;
- 一个飞书群和群内自定义机器人;
- 一个 Google Apps Script 项目。
邮件正文会发送给 DeepSeek 生成摘要。涉及合同、个人信息、财务或其他高敏感内容时,应先确认这种数据处理方式符合你的要求。
二、创建 Apps Script 项目
- 打开 https://script.google.com/。
- 点击“新建项目”。
- 将项目命名为“Gmail 摘要推送飞书”。
- 删除编辑器中默认的
myFunction。 - 打开 GitHub 项目中的 Code.gs 复制完整代码,也可以直接复制下方“精简可运行版”代码,然后粘贴到 Apps Script 编辑器。
- 点击保存。
正式长期使用优先选择 GitHub 完整版。下方版本便于快速配置,保留 Gmail 只读、DeepSeek 摘要、飞书签名、去重和分批处理等核心能力。
'use strict';
const C = {
model: 'deepseek-v4-pro',
batch: 30,
maxPages: 10,
bodyChars: 2500,
keepIds: 300,
};
function runGmailDigestToFeishu() {
const lock = LockService.getScriptLock();
if (!lock.tryLock(1000)) return;
try {
const props = PropertiesService.getScriptProperties();
const apiKey = required_(props, 'DEEPSEEK_API_KEY');
const webhook = required_(props, 'FEISHU_WEBHOOK_URL');
const secret = String(props.getProperty('FEISHU_SIGNING_SECRET') || '').trim();
const now = Date.now();
const last = Number(props.getProperty('LAST_SUCCESS_AT')) || 0;
const since = last ? last - 60 * 60 * 1000 : now - 24 * 60 * 60 * 1000;
const done = new Set(readIds_(props.getProperty('PROCESSED_IDS')));
const listed = listIds_('in:inbox after:' + Math.floor(since / 1000), done);
const mails = listed.ids.map(readMail_);
const summary = mails.length ? summarize_(apiKey, mails) : [
'## 概览', '- 暂无新增未处理邮件。', '',
'## 分类', '- 无', '',
'## 摘要', '- 无需处理。',
].join('\n');
sendFeishu_(webhook, secret, mails.length, summary);
listed.ids.forEach(function (id) { done.add(id); });
const state = {
PROCESSED_IDS: JSON.stringify(Array.from(done).slice(-C.keepIds)),
};
if (!listed.more) state.LAST_SUCCESS_AT = String(now);
props.setProperties(state, false);
} finally {
lock.releaseLock();
}
}
function required_(props, key) {
const value = String(props.getProperty(key) || '').trim();
if (!value) throw new Error('缺少脚本属性:' + key);
return value;
}
function readIds_(raw) {
try {
const value = JSON.parse(raw || '[]');
return Array.isArray(value) ? value : [];
} catch (error) {
return [];