Looking for documentation on retrieving a Chat transcript

I have a requirement to create a Chat Action for our Agents to create a Case in our CRM with the contents of the Chat.
Since I cannot change the payload on the Chat Action I wanted to use the chat_id provided to access the Chat’s transcript via the LiveChat APIs but I can’t seem to find the right documentation to get me on the right track.

Can anyone point me in the right direction please?

thank you,
FrancescaS

Hey Francesca,
To get the contents of the chat, you can use the method described here https://developers.livechatinc.com/docs/messaging/agent-chat-api/#get-archives.
Here is an example of the request that will give you chat contents.

url -X POST
https://api.livechatinc.com/v3.1/agent/action/get_archives
-H ‘Authorization: Basic x’
-H ‘Content-Type: application/json’
-d ‘{
“filters”: {
“thread_ids”: [“Q1RBPGHO2Z”]
}
}’

1 Like

Background:
My idea is to run call our API from the Chat Action, and in my API use the thread_id to get the necessary information for our Case creation, I would then redirect the user to the Case Create page pre-populated with the necessary data from the chat.

The problem:
To get the thread with the POST call you suggested I need an OAuth access token, but I don’t think I’m understanding how to retrieve it as the Agent’s access token is not included in the parameters sent by the Chat Action.
I tried the instructions here to no avail:

I am sorry that I’m asking all these step by step clarifications, but I’m struggling to follow the documentation.

How do I get an Access Token using my ClientID?

To get the code that you can exchange for tokens you have to redirect your user to our OAuth server. Process is described here

But to simplify your code you can generate PAT (Personal Access Token) which behaves like api key. These can be used with Agent Chat API, Configuration API, and Reports API.

Personally I think that for your task PAT will be better. If you really need to go through whole process I can record a short screencast for you showing how to do this.

I may have misunderstood PAT, I thought PAT was a per-agent access token, which means I would have to generate an access token for each agent, track those access tokens somewhere in my system, and use the one applicable for that agent for each call made by my api.

I can get an access token if I use the onIdentityFetched with the client ID on the Agent Chat Details Widget, and I can get the thread_id if I use the Agent Chat Actions. But for the life of me, I can’t seem to get both the token AND the thread id in one place (either the Agent Chat Actions or the Agent Chat Details Widget).

At this point I would settle for either one, but I need both pieces of information!

In the Details Widget I get ALL threads for that chat_id, and I can’t see a way to figure out the current one I’m on.

In the Agent Chat Action you are passing the current thread_id but I can’t get the token…

Sorry, but this is getting very frustrating.

Hey,

To send information from LiveChat to an external system I would do the following:

  • create an application in developers console with the scopes that will allow you to reach the information you want

  • in said application loaded in (for example), Chat Details use accounts SDK - it will allow you to get the token that you need

  • to get the thread id you have to use agent app sdk to get data from the ‘customer_profile’ event it will look like this:

    {
    “id”:“1053af04-e6dc-459a-5373-4e0032fac3e7”,
    “chat”:{
    “id”:“Q1593FSYIF”,
    “groupID”:0,
    “preChatSurvey”:[
    {
    “question”:“Question”,
    “answer”:""
    },
    {
    “question”:“Name”,
    “answer”:""
    },
    {
    “question”:“E-mail”,
    “answer”:""
    }
    ],
    “chat_id”:“Q1593FSYHF”,
    “thread_id”:“Q1593FSYIF”
    },
    “geolocation”:{
    “city”:“Wroclaw”,
    “country”:“Poland”,
    “country_code”:“PL”,
    “latitude”:null,
    “longitude”:null,
    “region”:“Dolnoslaskie”,
    “timezone”:“Europe/Warsaw”
    },
    “name”:“John Doe”,
    “source”:“archives”
    }

As you can see it contains thread_id that you need.

Now you just have to send live chat token with thread id to your backend that will make a request to our API.

1 Like

Thank you! I couldn’t see the forest for the trees!
The thread_id was right there, I just couldn’t see it.

Feeling pretty silly right now.

Dziękujębardzo,
Francesca

1 Like

Glad I could help :slight_smile: Happy coding!