Skip to content

Instantly share code, notes, and snippets.

View sorinpantis's full-sized avatar
🏡
Working Remotely

Sorin Pantis sorinpantis

🏡
Working Remotely
View GitHub Profile
Delivered-To: sorinemail@gmail.com
Received: by 2002:aa7:c81a:0:0:0:0:0 with SMTP id a26csp34672edt;
Mon, 8 Jun 2020 14:02:18 -0700 (PDT)
X-Google-Smtp-Source: ABdhPJxv9W1dxD/THRt7P/LqyHPP2NiD/OJt11J+MaDqLR3DsyxmqVEg5iob7tBgntvkVcbtrZu1
X-Received: by 2002:a05:6830:617:: with SMTP id w23mr19606783oti.0.1591650138114;
Mon, 08 Jun 2020 14:02:18 -0700 (PDT)
ARC-Seal: i=1; a=rsa-sha256; t=1591650138; cv=none;
d=google.com; s=arc-20160816;
b=b585xVKfxihgXm0zKr0SLsBYwqe/rhxOcyNvVZdoYIWyXwuAkDuvPol7Mm4Z+/8ZU8
vCu+Hi/m1NM1Fqp9JO7wO8dC3Kaa6twiG/88RpvA4ik1FUrgAehVYLXZ6mkP+pl3eq9O
require 'sinatra'
require 'json'
post '/conversation' do
payload_body = request.body.read
puts "payload_body >> #{payload_body.inspect}"
end
intercom.conversations.reply(id: conversation_id, type: 'admin', admin_id: admin_id, message_type: type, body: message)
payload = JSON.parse(payload_body)
user_id = payload["data"]["item"]["user"]["user_id"]
intercom = Intercom::Client.new(token: <ACCESS_TOKEN>)
intercom.conversations.find_all(user_id: user_id, type: 'user')
conversations.first(5).each do |convo|
if (convo.updated_at > time_threshold)
convos_updated.push({:id => convo.id, :updated_at => convo.updated_at})
else
# If the current checked conversation is not updated in the time threshold, we're not checking the next one
break
end
end
if updated_convos.count.between?(1, 4)
message += " 😎 <b>Vigilante</b> - Possible duplicate conversation! <br>"
message += "<br>This user has <b>#{updated_convos.count} other conversations</b> updated in the last #{HOURS} hours:"
updated_convos.each do |convo|
message += "<br> <a href='https://app.intercom.com/a/apps/#{APP_ID}/respond/inbox/conversation/#{convo[:id]}'>#{convo[:id]}</a> - #{convo[:updated_at]}"
end
elsif updated_convos.count > 4
message += " 😎 <b>Vigilante</b> - Possible duplicate conversation! <br>"
@sorinpantis
sorinpantis / intercom.js
Last active January 5, 2017 14:30
Get the UTM parameters form the URL as custom attributes in Intercom
// Get UTM Params
var querystring = document.location.search; // Get the string after the domain
querystring = querystring.substring(1); // Remove the leading "?"
querystring = querystring.split('&'); // Split the string in utm variables
var utms = {};
for (var i = 0; i < querystring.length; i++) {
sudo gem install sass
brew install ruby-build
brew install ruby
sudo brew update