You need to enable JavaScript to run this app. 如何使用Intercom ruby gem按自定义属性ein搜索公司记录
优惠活动
大模型
产品
解决方案
定价
更多

如何使用Intercom ruby gem按自定义属性ein搜索公司记录

实现方案

完全可以实现,Intercom Ruby SDK 原生支持按自定义属性搜索公司资源。

核心规则

搜索自定义属性时,需要在属性名前拼接 custom_attributes. 前缀,搭配 SDK 提供的 search 方法执行查询即可。

注意:原有的 intercom.companies.find 方法仅支持按 company_id、name 等内置基础字段查询,自定义属性查询必须使用 search 方法。

单条件查询示例

# 按自定义属性 ein 匹配指定值搜索
matched_companies = intercom.companies.search(
  query: {
    field: "custom_attributes.ein",
    operator: "=",
    value: "xyz123"
  }
)

# 遍历读取结果
matched_companies.each do |company|
  puts "公司ID:#{company.company_id}"
  puts "EIN值:#{company.custom_attributes['ein']}"
end

多条件组合查询示例

如果需要同时匹配多个规则,可通过逻辑运算符组合:

matched_companies = intercom.companies.search(
  query: {
    operator: "and",
    value: [
      { field: "custom_attributes.ein", operator: "=", value: "xyz123" },
      { field: "custom_attributes.contacts", operator: ">", value: 0 }
    ]
  }
)

常用可选运算符

  • 精确匹配:=、!=
  • 数值比较:>、<、>=、<=
  • 字符串模糊匹配:contains、starts_with、ends_with

内容的提问来源于stack exchange,提问作者farha

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.15 13:54:00