|
| 1 | +--- |
| 2 | +sidebar_label: Get chat history from a specific bot |
| 3 | +title: Get chat history from a specific bot |
| 4 | +description: This workflow sample demonstrates how to get the historical chat messages from a specific bot. |
| 5 | +--- |
| 6 | + |
| 7 | +<Available since="Strategy ONE (March 2025)" /> |
| 8 | + |
| 9 | +This API is used to get the historical questions from a specific bot for the current user, which can be used as the `history` parameter in the `Ask a question to a specific bot` API. |
| 10 | + |
| 11 | +:::info |
| 12 | + |
| 13 | +Obtain the authorization token needed to execute the request using [POST /api/auth/login](https://demo.microstrategy.com/MicroStrategyLibrary/api-docs/index.html#/Authentication/postLogin). |
| 14 | + |
| 15 | +::: |
| 16 | + |
| 17 | +## Get Questions by Bot |
| 18 | + |
| 19 | +Endpoint: [GET /api/questions/](https://demo.microstrategy.com/MicroStrategyLibrary/api-docs/index.html#/Next-Gen%20AI/getChats_1) |
| 20 | + |
| 21 | +Sample Request Headers: |
| 22 | + |
| 23 | +| Header | Required | Description | Sample Value | |
| 24 | +| ---------------- | -------- | -------------------------- | -------------------------------- | |
| 25 | +| X-MSTR-AuthToken | Yes | Authorization Token | t40ltbk411923ipk85r8r0tace | |
| 26 | +| X-MSTR-ProjectID | Yes | Project ID | B7CA92F04B9FAE8D941C3E9B7E0CD754 | |
| 27 | +| Content-Type | Yes | Type of content being sent | application/json | |
| 28 | + |
| 29 | +Sample Request Query Strings: |
| 30 | + |
| 31 | +| Query String | Required | Description | Sample Value | |
| 32 | +| ------------ | -------- | ---------------------------------------------------------- | -------------------------------- | |
| 33 | +| botId | Yes | The ID of the bot whose chat history you want to retrieve. | 065B007500614D158B41B0D020C96966 | |
| 34 | + |
| 35 | +Sample Curl: |
| 36 | + |
| 37 | +```bash |
| 38 | +curl 'https://demo.microstrategy.com/MicroStrategyLibrary/api/questions?botId=065B007500614D158B41B0D020C96966' \ |
| 39 | +-H 'accept: */*' \ |
| 40 | +-H 'X-MSTR-AuthToken: evvk84kcucn8abon6c1qfbud7' \ |
| 41 | +-H 'X-MSTR-ProjectID: B7CA92F04B9FAE8D941C3E9B7E0CD754' \ |
| 42 | +``` |
| 43 | + |
| 44 | +Sample Response Code: |
| 45 | + |
| 46 | +| Response Code | Status | |
| 47 | +| ------------- | ------------------------------------------------ | |
| 48 | +| 200 | Successfully returned the questions from the bot | |
| 49 | +| 400 | Error in getting the questions from the bot | |
| 50 | +| 401 | Authorization failed | |
| 51 | +| 404 | Bot does not exist | |
| 52 | + |
| 53 | +## Response Body on Success |
| 54 | + |
| 55 | +The response is a list of questions and answers from the specific bot. |
| 56 | + |
| 57 | +### Sample Response |
| 58 | + |
| 59 | +```json |
| 60 | +{ |
| 61 | + "questions": [ |
| 62 | + { |
| 63 | + "id": "B7CA92F04B9FAE8D941C3E9B7E0CD754:065B007500614D158B41B0D020C96966:1BA14D43628D40ABA5DF6616843C611F", |
| 64 | + "text": "Show the revenue in euros per month of the highest-grossing branch in Germany in 2024 in a gid.", |
| 65 | + "answers": [ |
| 66 | + { |
| 67 | + "bot": { |
| 68 | + "id": "065B007500614D158B41B0D020C96966", |
| 69 | + "projectId": "B7CA92F04B9FAE8D941C3E9B7E0CD754" |
| 70 | + }, |
| 71 | + "text": "The highest-grossing branch in Germany in 2024 generated the following revenue in euros per month:\n- August: €11,327,719\n- September: €10,847,290\n- October: €12,609,864\n- November: €13,793,524\n- December: €12,002,767", |
| 72 | + "route": "sql" |
| 73 | + } |
| 74 | + ], |
| 75 | + "creationDate": "2025-03-06T06:07:47.272+0000", |
| 76 | + "snapshot": false, |
| 77 | + "type": "snapshots" |
| 78 | + }, |
| 79 | + { |
| 80 | + "id": "B7CA92F04B9FAE8D941C3E9B7E0CD754:065B007500614D158B41B0D020C96966:75262B7346CC469EA7B874E49888040E", |
| 81 | + "text": "What was the Umsatz in Euro in Kristallhöhle during 2024/10 Okt?", |
| 82 | + "answers": [ |
| 83 | + { |
| 84 | + "bot": { |
| 85 | + "id": "065B007500614D158B41B0D020C96966", |
| 86 | + "projectId": "B7CA92F04B9FAE8D941C3E9B7E0CD754" |
| 87 | + }, |
| 88 | + "text": "Der Gesamtumsatz in Euro (Umsatz in Euro) für die Region 'kristallhöhle' im Oktober 2024 betrug €92.541.045.", |
| 89 | + "route": "sql" |
| 90 | + } |
| 91 | + ], |
| 92 | + "creationDate": "2025-03-07T02:56:53.708+0000", |
| 93 | + "snapshot": false, |
| 94 | + "type": "history" |
| 95 | + } |
| 96 | + ] |
| 97 | +} |
| 98 | +``` |
| 99 | + |
| 100 | +:::note |
| 101 | +Questions with `type` as `snapshots` should not be used as history in the `Ask a Specific Bot a Question` API. |
| 102 | +::: |
0 commit comments