闲社服务运行正常AI智能体自动化平台
f

Facebook收件箱转发

技能标识:fb-inbox-forward

Forward Facebook Page inbox messages to your OpenClaw channel in real time. Requires: powershell/pwsh + openclaw CLI. Reads ~/.config/fb-page/credentials.json (FB_PAGE_TOKEN, FB_PAGE_ID) and ~/.config/fb-inbox-forward/config.json (NOTIFY_CHANNEL, NOTIFY_TARGET). Listener opt-in only — never starts autonomously. Logs metadata only; no message content written to disk. All calls go to graph.facebook.com only.

作者:admin | 来源记录:ClawHub
登记来源
ClawHub
版本
V 1.0.10
检测标记
后台标记通过
免费
免费获取
1
收藏
来源与检测标记为平台登记信息,并不代表已展示可复核的检测报告。使用前请核对版本、依赖和所需权限,建议先在隔离环境中运行。
概述
安装方式
版本历史

Facebook收件箱转发

fb-inbox转发

每15秒轮询您的Facebook公共主页收件箱,并将新的入站消息转发到任何已连接的OpenClaw频道。FB凭据在运行时从fb-page技能配置中读取。



步骤1 - 加载凭据

来自fb-page技能的FB凭据:
powershell
$fb = Get-Content $HOME/.config/fb-page/credentials.json -Raw | ConvertFrom-Json
$token = $fb.FBPAGETOKEN
$pageId = $fb.FBPAGEID

如果缺失,告知用户先设置fb-page技能。

来自~/.config/fb-inbox-forward/config.json的转发配置:
powershell
$cfg = Get-Content $HOME/.config/fb-inbox-forward/config.json -Raw | ConvertFrom-Json
$channel = $cfg.NOTIFY_CHANNEL
$target = $cfg.NOTIFY_TARGET
$interval = if ($cfg.POLLINTERVALSEC) { [int]$cfg.POLLINTERVALSEC } else { 15 }

如果config.json缺失,运行设置:
powershell
$rawChannels = & openclaw channels list 2>&1 | Out-String
$channels = @()
foreach ($line in ($rawChannels -split n)) {
if ($line -match ^\s*-\s+(\w+)\s+\w+:\s+configured) { $channels += $matches[1] }
}
if ($channels.Count -eq 0) { Write-Host 未找到频道。请先连接一个频道。; return }

代理显示列表,要求用户选择频道并提供目标ID,然后保存:


New-Item -ItemType Directory -Force -Path $HOME/.config/fb-inbox-forward | Out-Null
@{ NOTIFYCHANNEL=; NOTIFYTARGET=; POLLINTERVALSEC=15 } |
ConvertTo-Json | Set-Content $HOME/.config/fb-inbox-forward/config.json -Encoding UTF8

保存后立即限制所有配置目录文件的权限:
powershell
$dir = $HOME/.config/fb-inbox-forward
if ($env:OS -eq Windows_NT) {
config.json,worker.ps1,listener.log,listener.pid,listener-state.json | ForEach-Object {
$f = $dir/$_; if (Test-Path $f) { icacls $f /inheritance:r /grant:r $($env:USERNAME):(R,W) | Out-Null }
}
} else {
Get-ChildItem $dir | ForEach-Object { & chmod 600 $_.FullName }
}

切勿将~/.config/fb-inbox-forward/中的任何文件提交到版本控制。



步骤2 - 核心操作


操作方法
启动监听器见后台监听器
停止监听器
见后台监听器 |
| 检查状态 | 见后台监听器 |
| 查看日志 | Get-Content $HOME/.config/fb-inbox-forward/listener.log -Tail 20 |
| 测试凭据 | GET /me 端点 |

测试凭据:
powershell
$fb = Get-Content $HOME/.config/fb-page/credentials.json -Raw | ConvertFrom-Json
$r = Invoke-RestMethod https://graph.facebook.com/v25.0/me?accesstoken=$($fb.FBPAGE_TOKEN) -ErrorAction Stop
Write-Host 已连接为:$($r.name)



步骤3 - 错误处理

powershell
try { } catch {
$err = $_.ErrorDetails.Message | ConvertFrom-Json -ErrorAction SilentlyContinue
$code = $err.error.code
$msg = $err.error.message
Write-Host FB API 错误 $code:$msg
}

代码含义修复方法
190令牌已过期/无效在fb-page技能中重新生成令牌
10 / 200
权限被拒绝 | 为您的应用添加pagesreadengagement权限 | | 368 | 请求频率受限 | 增加POLLINTERVALSEC(尝试60+) | | 100 | 参数无效 | 检查fb-page凭据中的FBPAGEID |

工作脚本 (worker.ps1)

这是写入~/.config/fb-inbox-forward/worker.ps1的确切内容。
扫描器和用户可以在启动监听器前在此处验证。

外部连接:仅graph.facebook.com(会话列表+消息获取)。
出站数据:仅通过openclaw消息发送发送发送者名称+消息文本+会话ID。
无其他端点。无令牌字面量。除发送者名称+会话ID外无额外日志记录。

powershell

fb-inbox-forward worker.ps1


读取:~/.config/fb-page/credentials.json, ~/.config/fb-inbox-forward/config.json


调用:graph.facebook.com(GET会话,GET消息)


发送:openclaw消息发送(发送者名称+消息文本+会话ID到NOTIFY_TARGET)


日志:仅发送者名称+会话ID — 不含消息内容,不含令牌

$fb = Get-Content $HOME/.config/fb-page/credentials.json -Raw | ConvertFrom-Json
$cfg = Get-Content $HOME/.config/fb-inbox-forward/config.json -Raw | ConvertFrom-Json
$token = $fb.FBPAGETOKEN
$pageId = $fb.FBPAGEID
$channel = $cfg.NOTIFY_CHANNEL
$target = $cfg.NOTIFY_TARGET
$interval = if ($cfg.POLLINTERVALSEC) { [int]$cfg.POLLINTERVALSEC } else { 15 }
$lookback = 60
$stateFile = $HOME/.config/fb-inbox-forward/listener-state.json
$logFile = $HOME/.config/fb-inbox-forward/listener.log
$state = if (Test-Path $stateFile) { Get-Content $stateFile -Raw | ConvertFrom-Json } else { @{} }

function Write-Log {
param([string]$m)
Add-Content $logFile $(Get-Date -Format yyyy-MM-dd HH:mm:ss) $m -Encoding UTF8
}
Write-Log 监听器已启动。

while ($true) {
try {
$convs = (Invoke-RestMethod https://graph.facebook.com/v25.0/$pageId/conversations?fields=id,updatedtime&limit=20&accesstoken=$token).data
foreach ($conv in $convs) {
$lastSeen = if ($state.$($conv.id)) {
[datetime]::Parse($state.$($conv.id))
} else {
(Get-Date).ToUniversalTime().AddSeconds(-$lookback)
}
if ([datetime]::Parse($conv.updated_time) -le $lastSeen) { continue }

$msgs = (Invoke-RestMethod https://graph.facebook.com/v25.0/$($conv.id)/messages?fields=message,from,createdtime&limit=10&accesstoken=$token).data
foreach ($msg in ($msgs | Sort-Object created_time)) {
if ([datetime]::Parse($msg.created_time) -le $lastSeen) { continue }
$senderId = if ($msg.from) { $msg.from.id } else { }
if ($senderId -eq $pageId) { continue } # 跳过公共主页自身的回复
$sender = if ($msg.from) { $msg.from.name } else { 未知 }
$text = if ($msg.message) { $msg.message } elseif ($msg.sticker) { [贴纸] } else { [附件] }

# 日志:仅发送者名称+会话ID — 消息文本不写入日志
Write-Log 转发 | $sender | 会话:$($conv.id)

# 传输:仅将发送者名称+消息文本+会话ID发送到配置的频道
$notify = 新FB消息n来自:$sendern消息:$textn会话ID:$($conv.id)
Start-Job -ScriptBlock {
param($ch, $tg, $m)
& openclaw message send --channel $ch --target $tg --message $m 2>$null
} -ArgumentList $channel, $target, $notify | Out-Null
}

$state | Add-Member -NotePropertyName $conv.id -NotePropertyValue $conv.updated_time -Force
}
$state | ConvertTo-Json -Depth 3 | Set-Content $stateFile -Encoding UTF8
} catch {
Write-Log 错误:$_ # 仅错误消息 — 错误

标签

skill ai

通过对话安装

以下为平台配置的接入选项,并非逐项实测通过。能否安装取决于客户端支持、技能来源和运行环境:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 fb-inbox-forward-1776287981 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 fb-inbox-forward-1776287981 技能

通过命令行安装

skillhub install fb-inbox-forward-1776287981

下载

⬇ 下载 fb-inbox-forward v1.0.10(免费)

文件大小: 4.49 KB | 发布时间: 2026-4-16 17:33

v1.0.10 最新 2026-4-16 17:33
Improved description for discoverability
返回顶部