/checker jane.doe@stripe.com 等斜杠命令可以在 Slack 中运行 Tomba 查询。这些命令由您自己的 tomba serve 实例提供服务:您使用本页中的清单创建一个 Slack 应用,并将其命令指向您的服务器。
工作原理
有人运行命令时,Slack 会将命令后面的文本发送到该命令的请求 URL。如果 URL 中带有 ?slack=true,tomba serve 会将该文本作为输入,使用 CLI 当前登录的账户调用 Tomba API,并以 Slack 消息作出回复。Slack 只向运行该命令的人显示回复。
每条命令都是一次 Tomba API 请求,按积分消耗中的说明向该账户计费。服务器不会验证 Slack 的请求签名,因此任何知道该 URL 的人都可以用您的积分运行查询。
前提条件
- 一台已安装 CLI 并已登录的服务器。
tomba login --api-key 适合在服务器上使用;请参阅 CLI 认证。
- 该服务器的公共 HTTPS URL,并带有有效的证书。Slack 只会将斜杠命令发送到 HTTPS URL。
- 在您的 Slack 工作区中创建应用的权限。
暴露服务器
tomba serve 没有任何认证,并且会暴露返回您的 API Secret 和管理您的密钥的路由,因此不要公开其端口。请将它运行在反向代理之后,由该代理终止 HTTPS 并只转发命令所用的路由,同时在防火墙上屏蔽 3000 端口。
实现上述配置的 nginx server 块:
server {
listen 443 ssl;
server_name tomba-slack.example.com;
ssl_certificate /etc/ssl/certs/tomba-slack.example.com.pem;
ssl_certificate_key /etc/ssl/private/tomba-slack.example.com.key;
location ~ ^/(search|verify|enrich|author|linkedin)$ {
limit_except POST { deny all; }
proxy_pass http://127.0.0.1:3000;
}
location / {
return 404;
}
}
然后在同一主机上启动服务器:
创建 Slack 应用
- 将下方清单中的
https://tomba-slack.example.com 替换为您服务器的 URL。
- 打开 api.slack.com/apps,选择 Create New App,然后选择 From a manifest,选择您的工作区,并粘贴清单。
- 将应用安装到您的工作区。
{
"display_information": {
"name": "Tomba",
"description": "Find and verify email addresses with Tomba."
},
"features": {
"bot_user": {
"display_name": "tomba",
"always_online": false
},
"slash_commands": [
{
"command": "/domain",
"url": "https://tomba-slack.example.com/search?slack=true",
"description": "Find email addresses at a domain.",
"usage_hint": "stripe.com",
"should_escape": false
},
{
"command": "/checker",
"url": "https://tomba-slack.example.com/verify?slack=true",
"description": "Verify an email address.",
"usage_hint": "jane.doe@stripe.com",
"should_escape": false
},
{
"command": "/enrich",
"url": "https://tomba-slack.example.com/enrich?slack=true",
"description": "Look up the person behind an email address.",
"usage_hint": "jane.doe@stripe.com",
"should_escape": false
},
{
"command": "/author",
"url": "https://tomba-slack.example.com/author?slack=true",
"description": "Find the email address of an article's author.",
"usage_hint": "https://stripe.com/blog/example-article",
"should_escape": false
},
{
"command": "/linkedin",
"url": "https://tomba-slack.example.com/linkedin?slack=true",
"description": "Find the email address for a LinkedIn profile.",
"usage_hint": "https://www.linkedin.com/in/jane-doe-example",
"should_escape": false
}
]
},
"oauth_config": {
"scopes": {
"bot": ["commands"]
}
},
"settings": {
"org_deploy_enabled": false,
"socket_mode_enabled": false,
"token_rotation_enabled": false
}
}
命令
| 命令 | 路由 | 输入 | 回复 |
|---|
/domain | /search | 域名 | 找到的邮箱地址,以及姓名、职位、所在地和个人资料 |
/checker | /verify | 邮箱地址 | 格式、邮件服务器和可送达状态,以及 WHOIS 详情 |
/enrich | /enrich | 邮箱地址 | 此人的姓名、职位、公司、所在地、个人资料和来源 |
/author | /author | 文章 URL | 作者的邮箱地址和个人资料 |
/linkedin | /linkedin | LinkedIn 个人资料 URL | 此人的邮箱地址和个人资料 |
例如:
/domain stripe.com
/checker jane.doe@stripe.com
故障排除
| 问题 | 原因和解决方法 |
|---|
| Slack 报告命令失败 | 服务器返回了错误状态:查询未找到任何结果、输入无效,或 API 调用失败(例如触发了速率限制)。Slack 不会显示原因。请检查服务器日志,并使用 CLI 运行相同的查询(例如 tomba verify --target jane.doe@stripe.com)来查看 API 的状态。 |
| Slack 报告超时 | Slack 等待回复的时间为 3 秒,而有些查询耗时更长。查询仍会运行,并照常消耗积分。 |
/checker 对 Gmail 或其他网页邮箱地址执行失败 | 对于网页邮箱和一次性邮箱域名的地址,服务器会在验证完成后返回错误。 |