Skip to content

Commit 4243c3a

Browse files
author
skamieniarz
committed
API-10478: Add webhooks parser usage example
1 parent a9adbf0 commit 4243c3a

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

examples/webhooks_example.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
''' Webhooks parser usage example. '''
2+
3+
from livechat.webhooks.parser import parse_webhook
4+
5+
webhook_example = {
6+
'webhook_id': '166c029b-a2c6-4010-aa0c-5a984353a7dd',
7+
'secret_key': 'top_secret_value',
8+
'action': 'chat_deactivated',
9+
'organization_id': 'f9c7cc55-b35a-4e76-b0d5-ae9fce362314',
10+
'payload': {
11+
'chat_id': 'PJ0MRSHTDG',
12+
'thread_id': 'K600PKZON8'
13+
},
14+
'additional_data': {}
15+
}
16+
17+
parsed_wh = parse_webhook(webhook_example)
18+
print(f'Webhook action: {parsed_wh.action}')
19+
print(f'Chat ID from the webhook\'s payload: {parsed_wh.payload.chat_id}')

0 commit comments

Comments
 (0)