1
0
mirror of https://github.com/Bayselonarrend/OpenIntegrations.git synced 2025-11-27 22:18:36 +02:00
Files
OpenIntegrations/docs/en/md/GreenAPI/Message-logs/Get-chat-history.mdx

224 lines
6.3 KiB
Plaintext
Raw Normal View History

2025-03-14 23:45:12 +03:00
---
sidebar_position: 1
2025-10-26 19:20:16 +03:00
description: Get chat history and other functions to work with GreenAPI in the Open Integration Package, a free open-source integration library for 1C:Enterprise 8, OneScript and CLI
keywords: [1C, 1С, 1С:Enterprise, 1С:Enterprise 8.3, API, Integration, Services, Exchange, OneScript, CLI, GreenAPI]
2025-03-14 23:45:12 +03:00
---
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
# Get chat history
Retrieves the chat message history
`Function GetChatHistory(Val AccessParameters, Val ChatID, Val Count = 100) Export`
| Parameter | CLI option | Type | Required | Description |
|-|-|-|-|-|
| AccessParameters | --access | Structure Of KeyAndValue | ✔ | Access parameters. See FormAccessParameters |
| ChatID | --chat | String | ✔ | Chat identifier |
| Count | --count | Number | ✖ | Number of messages to receive |
Returns: Map Of KeyAndValue - serialized JSON response from Green API
<br/>
:::tip
Method at API documentation: [GetChatHistory](https://green-api.com/docs/api/journals/GetChatHistory/)
:::
<br/>
```bsl title="1C:Enterprise/OneScript code example"
2025-10-21 11:36:43 +03:00
ApiUrl = "https://7105.api.greenapi.com";
MediaUrl = "https://7105.media.greenapi.com";
IdInstance = "71051...";
ApiTokenInstance = "425010d90e114aa6b78f0969e...";
2025-03-14 23:45:12 +03:00
2025-10-21 11:36:43 +03:00
ChatID = "120363410406221140@g.us";
2025-03-14 23:45:12 +03:00
AccessParameters = OPI_GreenAPI.FormAccessParameters(ApiUrl, MediaUrl, IdInstance, ApiTokenInstance);
Result = OPI_GreenAPI.GetChatHistory(AccessParameters, ChatID);
```
2025-03-18 11:35:12 +03:00
<Tabs>
<TabItem value="bash" label="Bash" default>
```bash
2025-10-07 19:27:04 +03:00
# JSON data can also be passed as a path to a .json file
2025-03-18 11:35:12 +03:00
oint greenapi GetChatHistory \
2025-07-05 18:56:59 +03:00
--access "{'apiUrl':'***','mediaUrl':'https://7105.media.greenapi.com','idInstance':'7105187566','apiTokenInstance':'***'}" \
2025-03-18 11:35:12 +03:00
--chat "120363410406221140@g.us"
```
</TabItem>
<TabItem value="bat" label="CMD/Bat" default>
```batch
2025-10-07 19:27:04 +03:00
:: JSON data can also be passed as a path to a .json file
2025-03-18 11:35:12 +03:00
oint greenapi GetChatHistory ^
2025-07-05 18:56:59 +03:00
--access "{'apiUrl':'***','mediaUrl':'https://7105.media.greenapi.com','idInstance':'7105187566','apiTokenInstance':'***'}" ^
2025-03-18 11:35:12 +03:00
--chat "120363410406221140@g.us"
```
</TabItem>
</Tabs>
2025-03-14 23:45:12 +03:00
2025-03-18 10:00:47 +03:00
```json title="Result"
[
{
"type": "outgoing",
2025-10-27 16:23:35 +03:00
"idMessage": "BAE5F0BC904F4998",
"timestamp": 1761560393,
2025-10-15 14:32:00 +03:00
"typeMessage": "extendedTextMessage",
2025-03-18 10:00:47 +03:00
"chatId": "120363410406221140@g.us",
2025-10-27 16:23:35 +03:00
"textMessage": "New message",
2025-10-15 14:32:00 +03:00
"extendedTextMessage": {
2025-10-27 16:23:35 +03:00
"text": "New message",
2025-10-15 14:32:00 +03:00
"description": "",
"title": "",
"previewType": "None",
"jpegThumbnail": "",
"forwardingScore": 1,
"isForwarded": true
2025-10-10 09:59:43 +03:00
},
"statusMessage": "sent",
"sendByApi": true,
"deletedMessageId": "",
"editedMessageId": "",
"isEdited": false,
"isDeleted": false
},
{
"type": "outgoing",
2025-10-27 16:23:35 +03:00
"idMessage": "BAE5EFF9FFBB851C",
"timestamp": 1761560392,
2025-10-15 14:32:00 +03:00
"typeMessage": "contactMessage",
2025-10-10 09:59:43 +03:00
"chatId": "120363410406221140@g.us",
2025-10-15 14:32:00 +03:00
"contact": {
2025-10-27 16:23:35 +03:00
"displayName": "Bicycle",
"vcard": "BEGIN:VCARD\nVERSION:3.0\nN:;;;\nFN:Bicycle\nORG:Bicycle\nTEL;type=CELL;type=VOICE;waid=79001234568:+79001234568\nEND:VCARD",
2025-09-16 09:07:33 +03:00
"forwardingScore": 0,
2025-10-10 09:59:43 +03:00
"isForwarded": false
},
"quotedMessage": {
2025-10-27 16:23:35 +03:00
"stanzaId": "BAE5F4CCAAE34098",
2025-10-10 09:59:43 +03:00
"participant": "1234567890@c.us",
2025-10-15 14:32:00 +03:00
"typeMessage": "contactMessage",
"contact": {
2025-10-27 16:23:35 +03:00
"displayName": "Artem Evpatoriysky Petrovich",
"vcard": "BEGIN:VCARD\nVERSION:3.0\nN:Petrovich;Artem;Evpatoriysky;\nFN:Artem Evpatoriysky Petrovich\nORG:Bicycle\nTEL;type=CELL;type=VOICE;waid=79001234568:+79001234568\nEND:VCARD",
2025-10-10 09:59:43 +03:00
"forwardingScore": 0,
"isForwarded": false
},
2025-09-16 09:07:33 +03:00
"deletedMessageId": "",
2025-10-10 09:59:43 +03:00
"editedMessageId": "",
2025-09-15 13:14:53 +03:00
"isEdited": false,
"isDeleted": false
2025-09-14 15:36:38 +03:00
},
2025-09-12 20:23:31 +03:00
"statusMessage": "sent",
2025-03-18 10:00:47 +03:00
"sendByApi": true,
2025-09-16 09:07:33 +03:00
"deletedMessageId": "",
2025-10-10 09:59:43 +03:00
"editedMessageId": "",
2025-03-18 10:00:47 +03:00
"isEdited": false,
"isDeleted": false
},
{
"type": "outgoing",
2025-10-27 16:23:35 +03:00
"idMessage": "BAE5F4CCAAE34098",
"timestamp": 1761560391,
2025-10-15 14:32:00 +03:00
"typeMessage": "contactMessage",
2025-03-18 10:00:47 +03:00
"chatId": "120363410406221140@g.us",
2025-10-15 14:32:00 +03:00
"contact": {
2025-10-27 16:23:35 +03:00
"displayName": "Artem Evpatoriysky Petrovich",
"vcard": "BEGIN:VCARD\nVERSION:3.0\nN:Petrovich;Artem;Evpatoriysky;\nFN:Artem Evpatoriysky Petrovich\nORG:Bicycle\nTEL;type=CELL;type=VOICE;waid=79001234568:+79001234568\nEND:VCARD",
2025-10-10 09:59:43 +03:00
"forwardingScore": 0,
"isForwarded": false
},
2025-09-12 20:23:31 +03:00
"statusMessage": "sent",
2025-03-18 10:00:47 +03:00
"sendByApi": true,
2025-09-16 09:07:33 +03:00
"deletedMessageId": "",
2025-10-10 09:59:43 +03:00
"editedMessageId": "",
2025-03-18 10:00:47 +03:00
"isEdited": false,
"isDeleted": false
},
{
"type": "outgoing",
2025-10-27 16:23:35 +03:00
"idMessage": "BAE5CF10CB48B9F3",
"timestamp": 1761560390,
2025-10-15 14:32:00 +03:00
"typeMessage": "locationMessage",
2025-03-18 10:00:47 +03:00
"chatId": "120363410406221140@g.us",
2025-10-15 14:32:00 +03:00
"location": {
"nameLocation": "",
"address": "",
"jpegThumbnail": "",
"latitude": 53.908522,
"longitude": 27.574821,
"forwardingScore": 0,
"isForwarded": false
2025-10-10 09:59:43 +03:00
},
2025-09-16 09:07:33 +03:00
"quotedMessage": {
2025-10-27 16:23:35 +03:00
"stanzaId": "BAE58EAA1E95D444",
2025-09-16 09:07:33 +03:00
"participant": "1234567890@c.us",
2025-10-15 14:32:00 +03:00
"typeMessage": "locationMessage",
"location": {
2025-10-27 16:23:35 +03:00
"nameLocation": "Victory Square, Minsk",
"address": "Victory sq.",
2025-10-15 14:32:00 +03:00
"jpegThumbnail": "",
"latitude": 53.908522,
"longitude": 27.574821,
"forwardingScore": 0,
"isForwarded": false
},
2025-09-16 09:07:33 +03:00
"deletedMessageId": "",
2025-10-10 09:59:43 +03:00
"editedMessageId": "",
2025-09-16 09:07:33 +03:00
"isEdited": false,
"isDeleted": false
},
2025-09-12 20:23:31 +03:00
"statusMessage": "sent",
2025-03-18 10:00:47 +03:00
"sendByApi": true,
2025-09-15 13:14:53 +03:00
"deletedMessageId": "",
2025-10-10 09:59:43 +03:00
"editedMessageId": "",
2025-03-18 10:00:47 +03:00
"isEdited": false,
"isDeleted": false
},
{
"type": "outgoing",
2025-10-27 16:23:35 +03:00
"idMessage": "BAE58EAA1E95D444",
"timestamp": 1761560389,
2025-10-15 14:32:00 +03:00
"typeMessage": "locationMessage",
2025-03-18 10:00:47 +03:00
"chatId": "120363410406221140@g.us",
2025-10-15 14:32:00 +03:00
"location": {
2025-10-27 16:23:35 +03:00
"nameLocation": "Victory Square, Minsk",
"address": "Victory sq.",
2025-10-15 14:32:00 +03:00
"jpegThumbnail": "",
"latitude": 53.908522,
"longitude": 27.574821,
"forwardingScore": 0,
"isForwarded": false
2025-10-10 09:59:43 +03:00
},
2025-09-12 20:23:31 +03:00
"statusMessage": "sent",
2025-03-18 10:00:47 +03:00
"sendByApi": true,
2025-09-15 13:14:53 +03:00
"deletedMessageId": "",
2025-10-10 09:59:43 +03:00
"editedMessageId": "",
2025-03-18 10:00:47 +03:00
"isEdited": false,
"isDeleted": false
},
{
"type": "outgoing",
2025-10-27 16:23:35 +03:00
"idMessage": "BAE5172A668D9D8D",
"timestamp": 1761560388,
2025-10-15 14:32:00 +03:00
"typeMessage": "pollMessage",
"chatId": "120363410406221140@g.us",
"pollMessageData": {
2025-10-27 16:23:35 +03:00
"name": "What's your favorite color?",
2025-10-15 14:32:00 +03:00
"options": [
{
2025-10-27 16:23:35 +03:00
"optionName": "Red"
2025-03-18 10:00:47 +03:00
...
```