Additional chat settings

A long article for code lovers

Chat settings changes via JavaScript

You can change your chat settings via Java Script. Let's look through some interesting cases. 

Important: 

  • Replace xxxxx in the code with your apiKey (you can find it in API keys tab in Settings)
  • The code should be placed instead of dashly.connect in code which you entered to your site. You can find it in Settings.

Multilingual chat

If your site supports several languages, you can customize your chat for each of them. Translate such phrases as "New message" or "enter your message and click Enter" to any language.

Important: offline messages text can be set in one language only. We are working on multilingual offline messages.

Here is a code for changing chat language. Replace phrases with your own:

var config = {
    "i18n": {
        "thanks": "Thank you",
        "dialogs_history": "Conversation history",
        "new_message": "New message",
        "enter_message": "Type your message and press Enter",
        "dialogs_zerodata": "There are no conversations yet.
We've never talked before",
        "enter_email": "Enter your email",
        "enter_phone": "Enter your phone number",
        "leave_email": "You can leave your email and we'll continue this conversation via email"
    },
        "settings": {
            "messenger_collapsed_text": "Ask me...",
            "messenger_offline_message": "No operators online now. Write your question and we will help you during the working time",
            "messenger_welcome_message": "Ask a question, we will answer.",
        }
}
dashly.connect('xxxxx',config);

Change operator's status

You can manually change operator's status on all or several pages of your site:

var config = {
    "settings": {
        "status_operators":  "online"
    }
}
dashly.connect('xxxxx',config);

Different chat colors on different pages

Make sure that the chat doesn't look strange on your website in terms of color. To change this, write argument messenger_collapsed_color for settings object.

var config = {
    "settings": {
            "messenger_collapsed_color": "178227"
    }
}
dashly.connect('xxxxx',config);

Different chat position on different pages

Сhat can be located in different places on each page. For example, chat can be at the bottom left corner on the main page, and at the bottom right corner on other pages. The messenger_position of the Settings object is responsible for the chat position.

var config = {
    "settings": {
        "messenger_position": "right_bottom"
    }
}
dashly.connect('xxxxx',config);

Full list of chat settings

"i18n" object arguments

thanks – The phrase that appears after one enters contact information in the chat

dialogs_history  – Title of "Conversation history" tab

new_message  – Text in a button that creates a new dialog in the "Conversations history" tab

enter_message  – Text in the input field

dialogs_zerodata  – Zero screen when there are no conversations

enter_email  – text in the field for entering email

enter_phone  – text in the field for entering phone number

page_title_new_message  - new conversation title

"Settings" object arguments

messenger_collapsed_color – Chat color

messenger_collapsed_text  – Inscription in the chat widget

messenger_collection_lead_type – What data to request from a user after their first chat message in case the user doesn't have their email added to their lead card

messenger_hide_collapsed  - Hide text in minimized mode. true or false 

messenger_mode  – the mode of the chat: visible , has_dialogs  (when there is a conversation), hidden 

messenger_name - default name (shown when none of operators responded yet)

messenger_online_message  – Lead will see this status message if they contact you when your chat is online

messenger_offline_message  - Lead will see this status message if they contact you when your chat is offline

messenger_show_offline_message  - Show message that all operators are offline. true /false 

messenger_position  – For the chat widget: left_top  (top left corner), left_bottom  (bottom left corner), right_top  (top right corner), right_bottom  (bottom right corner)

messenger_welcome_message - Inscription that appears in chat when one opens it

status_operators  – Status of your operators: online or offline 

messenger_collapsed_animations: {smile: true, winking_smile: true, vertical_funnel: true, horizontal_funnel: true} – Choose which widget animations to display and which not to display. true – animation is on, false – animation is off

messenger_theme: "default"  or "dark" chat widget theme

messenger_indent: {vertical: 25, horizontal: 25}  – Chat widget indent from the borders of the website window for desktop website version

messenger_mobile_indent: {vertical: 25, horizontal: 25}  – Chat widget indent from the borders of the website window for mobile website version

messenger_pattern: "pat-6"  – Chat background from the "Settings – Chat" section from "pat-1" to "pat-11"

messenger_show_kb_link_in_welcome_message  – Choose to show or hide link to your Dashly knowledge base in the welcome message. true or false 

messenger_icon_facebook_text: "dashly"  – URL to your Facebook page near the chat widget

messenger_icon_telegram_text: "dashly"  – URL to your Telegram page near the chat widget

messenger_icon_viber_text: "dashly" – URL to your Viber page near the chat widget

Conversations auto assignment

Conversations auto assignment can be set via our public API.

You need to create web-service which will realize operator's assignment logic.

This web-service should be called via Webhook. Learn about calling Webhook in Dashly in this article. Set "Lead initiated a conversation in chat" as a webhook trigger.

As soon as lead initiates a chat conversation, a webhook with all lead attributes and link to the page will be sent.

More information about webhooks can be found here.

Example:

1) Example of assigning operator Andrew (id 24574) to all open conversations (php): 

    // Your app Token https://dashly.io/developers/webapi/#_1
$token = 'xxx'; 
    // Event object https://dashly.io/developers/objects/event/
$event = json_decode($_POST['event']); 
    // ConversationId
$conversationId = $event->{'props'}->{'$conversation_id'}; 
    // Operator id. You can find it in Settins - admins
$operator = 24574; 
$url = 'https://api.dashly.io/v1/conversations/'.$conversationId.'/assign?auth_token='.$token;
    // Post request https://dashly.io/developers/endpoints/conversations/assign/
$result = file_get_contents($url, false, stream_context_create(array( 
	'http' => array(
		'method'  => 'POST',
		'header'  => 'Content-type: application/json',
		'content' => '{"admin": "'.$operator.'"}'
	)
    )));

2) Example of assigning operator Andrew (id 24574) to all conversations from pages containing " /portfolio/”:

  // Your app Token https://dashly.io/developers/webapi/#_1
$token = 'app.7.4b3448df1b622483e88f53eec35cf9aca7d6ce0973ea2209'; 
    // Event object https://dashly.io/developers/objects/event/
$event = json_decode($_POST['event']); 
    // User objest https://dashly.io/developers/objects/user/
$user = json_decode($_POST['user']); 
    // ConversationId
$conversationId = $event->{'props'}->{'$conversation_id'}; 
    // Operator id. You can find it in Settins - admins
$operator = 24574; 
$url = 'https://api.dashly.io/v1/conversations/'.$conversationId.'/assign?auth_token='.$token;
    // Post request https://dashly.io/developers/endpoints/conversations/assign/
if (stristr($user->{'presence_details'}->{'url'},'/portfolio/')) { 
    $result = file_get_contents($url, false, stream_context_create(array( 
        'http' => array(
            'method'  => 'POST',
            'header'  => 'Content-type: application/json',
            'content' => '{"admin": "'.$operator.'"}'
        )
             ))); 
        }
Powered by