Skip to content

Instantly share code, notes, and snippets.

@stympy
Last active June 28, 2023 16:44
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save stympy/e125f072379c30204a31 to your computer and use it in GitHub Desktop.
Save stympy/e125f072379c30204a31 to your computer and use it in GitHub Desktop.
Script to export helpscout data
#!/usr/bin/env ruby
require 'helpscout'
require 'fileutils'
api_key = ARGV[0]
helpscout = HelpScout::Client.new(api_key)
helpscout.mailboxes.each do |box|
FileUtils.mkdir(box.name) unless File.exists?(box.name)
puts "Fetching #{helpscout.conversation_count(box.id, 'all', nil)} conversations for #{box.name}"
helpscout.conversations(box.id, "all", nil).each do |c|
next if File.exists?(path = "#{box.name}/#{c.id}.yaml")
File.open(path, "w") {|f| f.puts helpscout.conversation(c.id).to_yaml; putc "."; sleep 0.5 }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment