Created
April 23, 2020 21:28
-
-
Save stympy/d1a0663f93bace233cf877cb2e5b36ee to your computer and use it in GitHub Desktop.
Export data from Intercom
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
root = "/tmp/intercom" | |
IntercomClient.conversations.all.each do |c| | |
puts c.id | |
FileUtils.mkdir_p(path = "#{root}/conversations/#{c.id.to_s.first(4)}") | |
File.open("#{path}/#{c.id}.json", "w") { |f| f.puts IntercomClient.conversations.find(id: c.id).to_json } | |
end | |
IntercomClient.users.scroll.each do |user| | |
puts user.id | |
FileUtils.mkdir_p(path = "#{root}/users/#{user.id.first(4)}") | |
File.open("#{path}/#{user.id}.json", "w") { |f| f.puts user.to_json } | |
end | |
IntercomClient.admins.all.each do |admin| | |
puts admin.id | |
File.open("#{root}/admins/#{admin.id}.json", "w") { |f| f.puts admin.to_json } | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment