botpress/botpress

List of conversations API does not show complete conversations

jonra1993 opened this issue · 7 comments

Hello, I have been testing the conversation API, but I have noticed that the API does not retrieve the full conversations and it just includes webchat integration despite having other integrations like telegram. I am sure I have messages and conversations on August but the APIs just show me September ones and it does not allow pagination

*Screenshot
image

This is my API results and meta does not show nextToken.

{
    "conversations": [
        {
            "id": "712af378-8621-4948-885e-51660424c04a",
            "createdAt": "2023-09-14T19:39:26.764Z",
            "updatedAt": "2023-09-14T19:39:26.764Z",
            "channel": "channel",
            "integration": "webchat",
            "tags": {
                "webchat:id": "51f433df-52c8-4595-9e64-7a44bef1b5be"
            }
        },
        {
            "id": "3d365687-cbce-44a3-9592-5e48f0175e6f",
            "createdAt": "2023-09-08T22:04:22.640Z",
            "updatedAt": "2023-09-08T22:04:22.640Z",
            "channel": "channel",
            "integration": "webchat",
            "tags": {
                "webchat:id": "f7b20ffd-16e4-4eec-bce9-77fdb0428b5d"
            }
        },
        {
            "id": "ce44ae00-b1f2-4b2b-ba17-be9dea0d53dd",
            "createdAt": "2023-09-08T15:46:31.001Z",
            "updatedAt": "2023-09-08T15:46:31.001Z",
            "channel": "channel",
            "integration": "webchat",
            "tags": {
                "webchat:id": "32e5bc58-4f47-4677-9b8e-ca7d11fade6a"
            }
        },
        {
            "id": "913cbceb-c7db-4658-9c76-945643101693",
            "createdAt": "2023-09-08T15:39:17.668Z",
            "updatedAt": "2023-09-08T15:39:17.668Z",
            "channel": "channel",
            "integration": "webchat",
            "tags": {
                "webchat:id": "2d82f63c-c639-4d7b-8e13-ddcb31369f68"
            }
        },
        {
            "id": "423a6223-a55d-4ab9-9843-1ac304f6982b",
            "createdAt": "2023-09-08T15:04:27.760Z",
            "updatedAt": "2023-09-08T15:04:27.760Z",
            "channel": "channel",
            "integration": "webchat",
            "tags": {
                "webchat:id": "a185437b-4bed-4058-88d4-594fe6579572"
            }
        },
        {
            "id": "ff384141-8f40-4e08-8e9b-a13ba7010e0f",
            "createdAt": "2023-09-08T15:00:33.598Z",
            "updatedAt": "2023-09-08T15:00:33.598Z",
            "channel": "channel",
            "integration": "webchat",
            "tags": {
                "webchat:id": "0a361b06-1285-496b-afde-78e4c4a8830e"
            }
        },
        {
            "id": "8ad2fdf7-fe68-4231-8d2a-83131c8fba0d",
            "createdAt": "2023-09-08T14:54:22.090Z",
            "updatedAt": "2023-09-08T14:54:22.090Z",
            "channel": "channel",
            "integration": "webchat",
            "tags": {
                "webchat:id": "d30408cf-8565-4000-89bd-6443e3de1aff"
            }
        },
        {
            "id": "9251cc98-0ab3-4636-bb41-9d4c6b7fe3b0",
            "createdAt": "2023-09-08T14:50:44.023Z",
            "updatedAt": "2023-09-08T14:50:44.023Z",
            "channel": "channel",
            "integration": "webchat",
            "tags": {
                "webchat:id": "6d2094d2-6795-406c-ac78-f3a4bd68b539"
            }
        },
        {
            "id": "1dfd56a5-6e9f-4ef9-a081-7915f0592b93",
            "createdAt": "2023-09-08T14:08:16.638Z",
            "updatedAt": "2023-09-08T14:08:16.638Z",
            "channel": "channel",
            "integration": "webchat",
            "tags": {
                "webchat:id": "5c6a0257-0906-4337-ae5c-82e71cd403aa"
            }
        },
        {
            "id": "fa2e8687-9cd5-47ce-9b9c-625adebb7f55",
            "createdAt": "2023-09-08T00:52:35.547Z",
            "updatedAt": "2023-09-08T00:52:35.547Z",
            "channel": "channel",
            "integration": "webchat",
            "tags": {
                "webchat:id": "2a2948db-c705-4314-9237-685dec9fda54"
            }
        },
        {
            "id": "48d335cc-d242-4849-8620-ed1b64304cdb",
            "createdAt": "2023-09-08T00:14:04.875Z",
            "updatedAt": "2023-09-08T00:14:04.875Z",
            "channel": "channel",
            "integration": "webchat",
            "tags": {
                "webchat:id": "58bbfded-241f-402d-b3b8-a85b6cef342f"
            }
        }
    ],
    "meta": {}
}
image

I have another question. Is there any way to filter the conversation list by dates?

Hi @jonra1993 ,

Can you show me your request code ? Do you use the official client, curl, something else ?

Hey @jonra1993,

Are you still trying to list conversations ? Let me know,

Frank

Hello @franklevasseur I am sorry for my late response. I just use postman.
image

I think this is the problem:

For your first query, the nextToken value should be undefined. After that, user the next token provided in the previous response.

This should fix paging and you'll see all your conversations.

something like:

const allConversations: Conversation[] = []
let nextToken: string | undefined = undefined // initial value for nextToken

do {
  const resp = await client.listConversations({ nextToken })
  allConversations.push(...resp.conversations)
  nextToken = resp.meta.nextToken
} while (nextToken)

console.log(allConversations)

@jonra1993 closing the issue, open a new one if needed.