# Extract conversation transcript

To do this, you'll need to use the GraphQL resource "conversation". You'll first need to authenticate yourself by [retrieving a GraphQL token.](/technologies/graphql-api/authentication.md)

You must then retrieve the identifier of the conversation for which you wish to retrieve the messages. For example, you can retrieve all the identifiers of closed conversations over a given period via the "closedconversations" resource.

Once you've retrieved your GraphQL token and conversation identifier, here's an example of the code you'll need to implement to retrieve the messages exchanged during the conversation:

```javascript
const APIToken = "xxxxxxxx";
const convID = "xxxxxxxx";


const options = {
  "method": "POST",
  "headers": {
    "Authorization": `Bearer ${APIToken}`,
    "Content-Type": "application/json"
  },
  "body": JSON.stringify({
    query: `query MyQuery($conversationId: UUID!) {
      conversation(id: $conversationId) {
        messages {
          edges {
            node {
              __typename
              ... on ParticipantConversationMessage {
                text
                createdAt
                author {
                  __typename
                }
              }
            }
          }
        }
      }
    }`,
    variables: {
    conversationId: convID
    }
  })
};
fetch("https://api.iadvize.com/graphql", options).then(async (response) => {
 
  let json = await response.json();
 
  let messages = json.data.conversation.messages.edges
    .filter(edge => edge.node.__typename === 'ParticipantConversationMessage')
    .map(edge => ({
    author: edge.node.author.__typename,
    text: edge.node.text,
    sentDate: edge.node.createdAt
  }));
 
  // Do what you want / need
  console.log(messages);

});

```

\\


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.iadvize.dev/use-cases/data-and-analytics/retrieve-messages-exchanged-within-a-conversation.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
