Exposes contact attributes like name, email, phone, and custom fields for use in Chatwoot templates.
# Source: https://github.com/chatwoot/chatwoot | License: MIT | Copyright 2017-2026 Chatwoot Inc
# Provided via justclaw.it.com; keep this notice with the code.
class ContactDrop < BaseDrop
def name
@obj.try(:name).try(:split).try(:map, &:capitalize).try(:join, ' ')
end
def email
@obj.try(:email)
end
def phone_number
@obj.try(:phone_number)
end
def first_name
@obj.try(:name).try(:split).try(:first).try(:capitalize)
end
def last_name
@obj.try(:name).try(:split).try(:last).try(:capitalize) if @obj.try(:name).try(:split).try(:size) > 1
end
def custom_attribute
custom_attributes = @obj.try(:custom_attributes) || {}
custom_attributes.transform_keys(&:to_s)
end
end
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key