Skip to content

Instantly share code, notes, and snippets.

@maccman
Created December 26, 2016 23:37
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maccman/5f3871c0c66d6f1385c5e1721f0cc9e0 to your computer and use it in GitHub Desktop.
Save maccman/5f3871c0c66d6f1385c5e1721f0cc9e0 to your computer and use it in GitHub Desktop.
Clearbit Reveal/Drift integration
drift.on('ready',function(api, payload) {
api.showWelcomeOrAwayMessage(<%== @options.to_json %>);
});
get '/drift.js' do
reveal = Clearbit::Reveal.find(ip: request.ip)
content_type 'application/javascript'
qualified =
reveal &&
reveal.company.metrics.employees.to_i >= 30 &&
%{private public}.include?(reveal.company.type)
if qualified
unless reveal.fuzzy
name = reveal.company.name.gsub(/\W/, '')
message = %{We ♥ #{name}. Have any questions?}
end
@options = {
showAvatar: true,
slide: true,
message: message,
}
erb :'site/drift/show'
else
200
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment