Skip to content

Instantly share code, notes, and snippets.

@stympy
Created April 23, 2020 21:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stympy/d1a0663f93bace233cf877cb2e5b36ee to your computer and use it in GitHub Desktop.
Save stympy/d1a0663f93bace233cf877cb2e5b36ee to your computer and use it in GitHub Desktop.
Export data from Intercom
#!/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