Module: Livechat

Defined in:
lib/livechat.rb,
lib/livechat/engine.rb,
lib/livechat/widget.rb,
lib/livechat/version.rb,
lib/livechat/configuration.rb,
lib/livechat/notifications.rb,
app/mailers/livechat/mailer.rb,
app/models/livechat/message.rb,
app/models/livechat/conversation.rb,
app/helpers/livechat/inbox_helper.rb,
app/helpers/livechat/widget_helper.rb,
app/models/livechat/application_record.rb,
app/controllers/livechat/visitor_controller.rb,
app/controllers/livechat/widgets_controller.rb,
app/controllers/livechat/messages_controller.rb,
app/controllers/livechat/application_controller.rb,
app/controllers/livechat/conversations_controller.rb,
lib/generators/livechat/install/install_generator.rb

Overview

Live chat for Rails. A floating widget lets visitors — signed-in or anonymous — message your team; your team answers from a built-in inbox at the mount path, every reply signed with its author. Conversations live in your own database. When nobody is around, visitors leave an email and the thread continues there. No third-party script, no separate service.

Defined Under Namespace

Modules: Generators, InboxHelper, Notifications, Widget, WidgetHelper Classes: ApplicationController, ApplicationRecord, Configuration, Conversation, ConversationsController, Engine, Mailer, Message, MessagesController, VisitorController, WidgetsController

Constant Summary collapse

VERSION =
'0.3.2'

Class Method Summary collapse

Class Method Details

.agent?(request) ⇒ Boolean

Can this request work the inbox? Checked by every inbox action.

Returns:

  • (Boolean)


31
32
33
# File 'lib/livechat.rb', line 31

def agent?(request)
  !!config.authorize_agent.call(request)
end

.app_nameObject



35
36
37
# File 'lib/livechat.rb', line 35

def app_name
  config.app_name.presence || rails_app_name
end

.configObject



16
17
18
# File 'lib/livechat.rb', line 16

def config
  @config ||= Configuration.new
end

.configure {|config| ... } ⇒ Object

Yields:



20
21
22
# File 'lib/livechat.rb', line 20

def configure
  yield config
end

.display_name_for(agent_label) ⇒ Object

The public face of an agent message. Blank display names fall back to a localized "Support", so visitors always see a sender.



41
42
43
44
# File 'lib/livechat.rb', line 41

def display_name_for(agent_label)
  name = config.agent_display_name.call(agent_label).presence
  name || I18n.t(:team, scope: :livechat, default: 'Support')
end

.enabled?(request) ⇒ Boolean

Can this request see the widget and write messages? Checked on the server for every widget endpoint and by the helper before rendering.

Returns:

  • (Boolean)


26
27
28
# File 'lib/livechat.rb', line 26

def enabled?(request)
  !!config.enabled.call(request)
end