Check for conditions to proceed
This trigger allows to have custom conditions to be checked before rest of the triggers can be processed.
One of the few possible scenarios can be
- Collecting multiple fields before next trigger can be executed
- Comparing user message with internal chat variable. E.g you set chat variable and later you want that visitor entered correct text.
- https://www.youtube.com/watch?v=6pYWAqDrqts how to use this element in a start chat form.
- https://youtu.be/AL7RVRcvOas how to use this element and show custom content if there is no operators available.
Attribute supported placeholders
Attribute
supports these placeholders
lhc.<main chat attribute>
E.glhc.email
,lhc.nick
,lhc.phone
etc. See swagger for all attributes.<identifier>
- this can be either custom attributeField identifier
or just array key fromchat_variables
<chat_variable>
- identical to{args.chat.chat_variables_array.<variable_key>}
It can be set usingUpdate current chat response
response type
So if you set variablebot_touched
in attribute field you can use eitherbot_touched
or{args.chat.chat_variables_array.bot_touched}
{args.chat.<main chat attr>}
or{args.msg.msg}
you can use text matching for visitor message.online_department
use as attribute to check is department online (respects department online hours and operators online statuses). In value field 1 means online, 0 - means offlineonline_op_department
use as attribute to check is department online (ignores department online hours) and checks only for operators. In value field 1 means online, 0 - means offlineonline_department_hours
use as attribute to check is department online by online hours settings (ignores ignores operators statuses). In value field 1 means online, 0 - means offlinesiteaccess
you can use this attribute to check whatsiteaccess
visitor is on and execute appropriate trigger. E.g if you want different response by language.eng
,lit
list of default siteacesschat_files
check does chat has fileschat_files
>
0
- chat has fileschat_files
contains
pdf,jpg
- chat has pdf or jpg
operator_files
same checks aschat_files
except only for operator filesuser_files
same checks aschat_files
except only for visitor files{validation_event__<event_name>}
E.g{validation_event__my_event_validator}
event withmy_event_validator
will be dispatched and result afterwards compared with expected output.my_event_validator
=
1
{{args.chat.online_user.previous_chat.id}} > 0
and use that condition to check did visitor had chat before with you.
If you do not enter Value
means it's empty.
E.g
- so
lhc.email != <empty>
as in screenshot. Means I'm checking that e-mail would not be an empty string. {args.msg.msg}
I'm expecting message to contain one of the wordsdispute, chargeback, refund{2}, money back, contact bank
.Refund
word can have two typos.
How to validate {validation_event__<event_name>}
class erLhcoreClassExtensionValidateevent
{
public $configData = false;
public function __construct()
{
}
public function run()
{
$dispatcher = erLhcoreClassChatEventDispatcher::getInstance();
$dispatcher->listen('chat.genericbot_event_handler', 'erLhcoreClassExtensionValidateevent::genericEventHandler');
}
public static function genericEventHandler($params)
{
if ($params['render'] == 'my_event_validator') {
return array(
'status' => erLhcoreClassChatEventDispatcher::STOP_WORKFLOW,
'validation_result' => 1
);
}
}
}
Value supported placeholders
Value supports only {args.
type placeholders. E.g {args.msg.msg}
or {args.chat.chat_variables_array.<variable>}
How do I check visitor message with internally stored chat variable?
Example condition can look like
How do I execute triggers based on visitor priority
Let say we want to transfer players with player class VIP to operator and others keep with a bot.
We have defined custom chat variables
if (typeof lhc_var === 'undefined') { // This variable has to be defined before Live Helper Chat embed script.
window.lhc_var = {}; // Window is required to define variable in global scope
};
lhc_var.playerClass = 'VIP';
Next we have default
trigger with this check
It means if player is VIP
class trigger VIP
will be executed, if not NonVIP
trigger will be executed.
Collect all information and write information was collected.
Main trigger can look like this.
And each collecting information step can look like this
Allow to execute rest of the triggers only if e-mail is not empty
In this example we forward to e-mail collecting workflow if visitor e-mail is empty.
How to add custom icon if visitor writes some message containing specific text?
For that we will need
- Webhooks
- Trigger setup
Trigger setup can look like
Webhook setup can look like
How to execute bottom triggers if conditions is matched
There is two scenarios
If you are using If conditions are met execute this trigger
{args.chat.dep_id} = 31
We want to execute only if department id is31
.- check
If conditions are matched continue executing responses.
This is required if you are usingIf conditions are met execute this trigger
If you are not using If conditions are met execute this trigger
- Condition changes to
{args.chat.dep_id} != 31
We want to execute only if department id is31
. This time it's reverse
How do I check if I had a chat with this user and skip bot in that scenario?
We will have three triggers
Default
Remember VIP
will be triggered onremember
keywordWelcome back VIP
will send a message if we had a chat with this visitor before.
Default
trigger content
Conditions content
{args.chat.online_user.previous_chat.chat_variables_array.vip} = 1
Remember VIP
trigger content
Trigger is triggered on remember
keyword