We use the livechatinc.com extension on our website and are looking to send the chat transcript automatically to the agent, after each chat ends.
You see there is an example on their website which we have implemented:
https://www.livechatinc.com/help/how-to-get-chat-transcripts/
This works however only with the email address hard coded.
We need the email to be sent to the email address of the agent which is key [agent_id] and value email@email.bhma.co.uk in this instance, in the JSON received from API.
We have tried the following
$agent = $data->chat->messages[0]->agent_id;
$agent = $data->chat->messages->agent_id;
And then
mail($agent, 'Chat transcript', print_r($chat));
However there is an issue with trying to access agent_id.
It seems only up until $data->chat we can get some data, then it is not possible?
stdClass Object
(
[event_type] => chat_ended
[event_unique_id] => 123
[token] => 123
[license_id] => 123
[lc_version] => 1
[chat] => stdClass Object
(
[id] => PVDXP0E1Q9
[started_timestamp] => 1565262189
[ended_timestamp] => 1565262198
[url] => https://www..co.uk/
[referer] =>
[messages] => Array
(
[0] => stdClass Object
(
[user_type] => agent
[author_name] => Bob
[agent_id] => email@email.co.uk
[text] => Hello . How may I help you?
[json] =>
[timestamp] => 1565262189
)
)
[attachments] => Array
(
)
[events] => Array
(
[0] => stdClass Object
(
[user_type] =>
[text] => archived the chat
[timestamp] => 1565262198
[type] =>
)
)
[agents] => Array
(
[0] => stdClass Object
(
[name] => Bob
[login] => email@email.co.uk
)
)
[tags] => Array
(
)
[groups] => Array
(
[0] => 0
)
)
)
So we need to access the [agent_id] value which will then be assigned to a variable that will be used to send an email to.