Events

Listen to webhook events from the m-chat platform.

Enabling the events, will give you access to define your webhook endpoint which would receive all the subscribed events.

List of events

Conversation Creation

When a new conversation is created.

{"events": [{"event": {"type": "conversation_create", "payload": {"assigned_to_user": {"email": "[email protected]", "id": "8181", "type": "bot"}, "created_at": "2023-08-29 04:27:48.236411", "title": "Visitor - A27187", "bot_id": 8861, "channel": {"name": 1, "provider": 0}, "is_new_visitor": false, "is_closed": 0, "external_key": "7f984da9a15b4bceb512ecad8ca461051693283267", "browser": "Chrome 116 (116.0.0.0)", "variables": [{"type": "text", "name": "bot_name", "value": "All Dialogs"}, {"type": "text", "name": "referrer_url", "value": ""}, {"type": "text", "name": "timezone", "value": "Asia/Calcutta"}, {"type": "text", "name": "os", "value": "Mac OS X 10_15_7"}, {"type": "text", "name": "browser_language", "value": "en-GB"}, {"type": "text", "name": "browser", "value": "Chrome 116 (116.0.0.0)"}, {"type": "text", "name": "ip_address", "value": "49.249.141.54"}, {"type": "text", "name": "global_channel_name", "value": "WEB"}, {"type": "date", "name": "conversation_created_at", "value": "2023-08-29T04:27:48.183000+00:00"}, {"type": "text", "name": "conversation_url", "value": "https://app.dev.m-chat.ai/account/476/live-chat/bot/8861/conversations/unassigned/7f984da9a15b4bceb512ecad8ca461051693283267"}, {"type": "text", "name": "source_url", "value": "https://app.dev.m-chat.ai/bot-preview/8Dc98btp4CPu0959442660854eRb8N5u"}, {"type": "text", "name": "contact_id", "value": "a569015fa03d41a283ed4c66c4601966"}, {"type": "text", "name": "visitor_contact_created_by", "value": "m-chat.ai Development"}, {"type": "text", "name": "visitor_age", "value": "abc"}, {"type": "text", "name": "visitor_js1", "value": "hj"}, {"type": "text", "name": "visitor_name", "value": "nik"}]}}, "conversation": {"key": "42bb83f00d8240e5bb41290a12eb44401693552452", "id": 7525695}, "account": {"key": "VGYh5KEUxnaS043726528180Llb9R8pe", "id": 476, "bot": {"id": 8861}}, "visitor": {"key": "a569015fa03d41a283ed4c66c4601966", "id": 826373}, "timestamp": "2023-09-01 14:13:32.141788"}]}

Message exchange

When exchange of messages are made between bots/agents and visitors.

// TEXT
{"events": [{"event": {"type": "message", "payload": {"message_by": {"email": null, "id": null, "type": "visitor"}, "message": {"type": "text", "text": "Hiiiii"}}}, "conversation": {"key": "42bb83f00d8240e5bb41290a12eb44401693552452", "id": 7525695}, "account": {"key": "VGYh5KEUxnaS043726528180Llb9R8pe", "id": 476, "bot": {"id": 8861}}, "visitor": {"key": "a569015fa03d41a283ed4c66c4601966", "id": 826373}, "timestamp": "2023-09-01 14:13:45.503552"}]}

//IMAGE
{"events": [{"event": {"type": "message", "payload": {"message_by": {"email": "[email protected]", "id": "8292", "type": "user"}, "message": {"type": "image", "payload": {"link": "https://m-chat-conversation-attachment-dev.storage.googleapis.com/8861/Visitor%20-%20A27187-355aaabc63aa46aaa31b4a6ab1a89dd01693458824/30cb79cc-47bd-11ee-8b81-a241eeeaf60f_sample-clouds-400x300.jpg", "mime_type": "image/jpeg", "file_name": "photo-1579353977828-2a4eab540b9a.jpeg"}}}}, "conversation": {"key": "42bb83f00d8240e5bb41290a12eb44401693552452", "id": 7525695}, "account": {"key": "VGYh5KEUxnaS043726528180Llb9R8pe", "id": 476, "bot": {"id": 8861}}, "visitor": {"key": "a569015fa03d41a283ed4c66c4601966", "id": 826373}, "timestamp": "2023-09-01 14:13:32.141788"}]}

//FORM
{"events": [{"event": {"type": "message", "payload": {"message_by": {"email": "[email protected]", "id": "8292", "type": "user"}, "message": {"type": "form", "payload": {"message": "Please fill in the following details", "fields": [{"label": "Name", "type": "text", "variable": "\u00bf\u00b7$user.info.age\u00b7?", "is_optional": false}, {"label": "Email", "type": "email", "variable": "\u00bf\u00b7$user.info.email\u00b7?", "is_optional": false}, {"label": "Phone", "type": "phone", "variable": "\u00bf\u00b7$user.info.phone\u00b7?", "is_optional": false}]}}}}, "conversation": {"key": "42bb83f00d8240e5bb41290a12eb44401693552452", "id": 7525695}, "account": {"key": "VGYh5KEUxnaS043726528180Llb9R8pe", "id": 476, "bot": {"id": 8861}}, "visitor": {"key": "a569015fa03d41a283ed4c66c4601966", "id": 826373}, "timestamp": "2023-09-01 14:13:32.141788"}]}

//FILE UPLOAD
{"events": [{"event": {"type": "message", "payload": {"message_by": {"email": "[email protected]", "id": "8292", "type": "user"}, "message": {"type": "file_upload", "payload": {"title": "Can you please upload your file?", "allow_extensions": [".jpg", ".png", ".pdf", ".jpeg"], "max_file_size_in_kb": "Can you please upload your file?", "upload_file_limit": 1, "error_message": {"file_size": "Please upload a file below 10 MB", "file_extensions": "Please upload a valid file format", "file_not_found": "Invalid! Please upload a valid file"}}}}}, "conversation": {"key": "42bb83f00d8240e5bb41290a12eb44401693552452", "id": 7525695}, "account": {"key": "VGYh5KEUxnaS043726528180Llb9R8pe", "id": 476, "bot": {"id": 8861}}, "visitor": {"key": "a569015fa03d41a283ed4c66c4601966", "id": 826373}, "timestamp": "2023-09-01 14:13:32.141788"}]}

//CALENDAR
{"events": [{"event": {"type": "message", "payload": {"message_by": {"email": "[email protected]", "id": "8292", "type": "user"}, "message": {"type": "calendar", "payload": {"auto_open": true, "title": "What is your preferred date?", "validation": {"datepicker_type": "single", "start": "", "end": "", "formatter": "MM/DD/YYYY", "exclude_days": [], "include": [], "selected": "", "skip": []}}}}}, "conversation": {"key": "42bb83f00d8240e5bb41290a12eb44401693552452", "id": 7525695}, "account": {"key": "VGYh5KEUxnaS043726528180Llb9R8pe", "id": 476, "bot": {"id": 8861}}, "visitor": {"key": "a569015fa03d41a283ed4c66c4601966", "id": 826373}, "timestamp": "2023-09-01 14:13:32.141788"}]}

//AUDIO
{"events": [{"event": {"type": "message", "payload": {"message_by": {"email": "[email protected]", "id": "8292", "type": "user"}, "message": {"type": "audio", "payload": {"link": "https://bucket-dev.storage.googleapis.com/8791_8292_sWhsBMDwGdJf101716174591uHnJXdSB_attachment.mp3", "mime_type": "audio/mpeg", "file_name": "file_example_MP3_700KB.mp3"}}}}, "conversation": {"key": "42bb83f00d8240e5bb41290a12eb44401693552452", "id": 7525695}, "account": {"key": "VGYh5KEUxnaS043726528180Llb9R8pe", "id": 476, "bot": {"id": 8861}}, "visitor": {"key": "a569015fa03d41a283ed4c66c4601966", "id": 826373}, "timestamp": "2023-09-01 14:13:32.141788"}]}

//CALENDLY
{"events": [{"event": {"type": "message", "payload": {"message_by": {"email": null, "id": null, "type": "visitor"}, "message": {"type": "calendly.response", "payload": {"variables": {"\u00bf\u00b7is_calendly_event_scheduled\u00b7?": true, "\u00bf\u00b7calendly_event\u00b7?": "https://api.calendly.com/scheduled_events/bddb81e6-36d4-4950-963d-1c436b9f9696", "\u00bf\u00b7calendly_invitee\u00b7?": "https://api.calendly.com/scheduled_events/bddb81e6-36d4-4950-963d-1c436b9f9696/invitees/84a6fc15-eee8-4e37-b976-0c77e3d70083"}}}}}, "conversation": {"key": "42bb83f00d8240e5bb41290a12eb44401693552452", "id": 7525695}, "account": {"key": "VGYh5KEUxnaS043726528180Llb9R8pe", "id": 476, "bot": {"id": 8861}}, "visitor": {"key": "a569015fa03d41a283ed4c66c4601966", "id": 826373}, "timestamp": "2023-09-01 14:13:45.503552"}]}

//VIDEO
{"events": [{"event": {"type": "message", "payload": {"message_by": {"email": "[email protected]", "id": "8292", "type": "user"}, "message": {"type": "video", "payload": {"link": "https://bucket-dev.storage.googleapis.com/8791_8292_2PoWjoofeMhP101802210051O8eGJvkH_attachment.mp4", "mime_type": "video/mp4", "file_name": "file_example_MP4_480_1_5MG.mp4"}}}}, "conversation": {"key": "42bb83f00d8240e5bb41290a12eb44401693552452", "id": 7525695}, "account": {"key": "VGYh5KEUxnaS043726528180Llb9R8pe", "id": 476, "bot": {"id": 8861}}, "visitor": {"key": "a569015fa03d41a283ed4c66c4601966", "id": 826373}, "timestamp": "2023-09-01 14:13:32.141788"}]}

//LIST (WHATSAPP)
{"events": [{"event": {"type": "message", "payload": {"message_by": {"email": "[email protected]", "id": "8292", "type": "user"}, "message": {"type": "list", "payload": {"header": {"type": "text", "text": "Hello"}, "footer": "", "title": "What would you like to choose?", "list": {"title": "b-1", "sections": [{"title": "c-1", "items": [{"title": "Item 1", "description": "Item-1", "next_dialog": "2"}]}, {"title": "c-2", "items": [{"title": "Item 2", "description": "Item-2", "next_dialog": "2"}]}]}}}}}, "conversation": {"key": "8e6884db0c7a480e90b2118f6daae12c1693797745", "id": 7525719}, "account": {"key": "VGYh5KEUxnaS043726528180Llb9R8pe", "id": 476, "bot": {"id": 4395}}, "visitor": {"key": "8eef41bf4d4248dd82d6a57c5b42fca9", "id": 826389}, "timestamp": "2023-09-04 03:41:27.335786"}]}

//JAVASCRIPT
{"events": [{"event": {"type": "message", "payload": {"message_by": {"email": "[email protected]", "id": "8292", "type": "user"}, "message": {"type": "javascript", "payload": {"script": "wn.setContactVariables({\"JS1\": \"hj\"});\nwn.setConversationVariables({\"JS2\": \"Mtech\"});\nwindow.alert(5 + 6);\nconsole.log(\"Hello World!\");", "execute_at": "client"}}}}, "conversation": {"key": "42bb83f00d8240e5bb41290a12eb44401693552452", "id": 7525695}, "account": {"key": "VGYh5KEUxnaS043726528180Llb9R8pe", "id": 476, "bot": {"id": 8861}}, "visitor": {"key": "a569015fa03d41a283ed4c66c4601966", "id": 826373}, "timestamp": "2023-09-01 14:13:32.141788"}]}

//BUTTON
{"events": [{"event": {"type": "message", "payload": {"message_by": {"email": "[email protected]", "id": "8292", "type": "user"}, "message": {"type": "button", "payload": {"search_enabled": false, "multi_select_enabled": false, "buttons_layout": "horizontal", "buttons_order": "as defined", "buttons": [{"title": "Button 1", "type": "branch", "callback": "", "next_dialog": "6"}, {"title": "Button 2", "type": "web_url", "callback": "{\"web_url\": \"https://www.google.com\", \"browser_window\": \"new\"}", "next_dialog": "5"}, {"title": "Button 3", "type": "branch", "callback": "", "next_dialog": "14"}], "title": "What would you like to choose?"}}}}, "conversation": {"key": "42bb83f00d8240e5bb41290a12eb44401693552452", "id": 7525695}, "account": {"key": "VGYh5KEUxnaS043726528180Llb9R8pe", "id": 476, "bot": {"id": 8861}}, "visitor": {"key": "a569015fa03d41a283ed4c66c4601966", "id": 826373}, "timestamp": "2023-09-01 14:13:32.141788"}]}

//DOCUMENT
{"events": [{"event": {"type": "message", "payload": {"message_by": {"email": "[email protected]", "id": "8292", "type": "user"}, "message": {"type": "document", "payload": {"link": "https://bucket-dev.storage.googleapis.com/8791_8292_B9DwdqiUy5Ea101257098374GOoPO0Mc_attachment.pdf", "mime_type": "application/pdf", "file_name": "TICKETS.pdf"}}}}, "conversation": {"key": "42bb83f00d8240e5bb41290a12eb44401693552452", "id": 7525695}, "account": {"key": "VGYh5KEUxnaS043726528180Llb9R8pe", "id": 476, "bot": {"id": 8861}}, "visitor": {"key": "a569015fa03d41a283ed4c66c4601966", "id": 826373}, "timestamp": "2023-09-01 14:13:32.141788"}]}

//CAROUSEL
{"events": [{"event": {"type": "message", "payload": {"message_by": {"email": "[email protected]", "id": "8292", "type": "user"}, "message": {"type": "carousel", "payload": {"title": "Image Carousel 1", "items": [{"image": "https://m-chat-conversation-attachment-dev.storage.googleapis.com/8861_8292_2uMHreVKUmDc100237912704NbQFNlWF_attachment.jpg", "action": ""}]}}}}, "conversation": {"key": "42bb83f00d8240e5bb41290a12eb44401693552452", "id": 7525695}, "account": {"key": "VGYh5KEUxnaS043726528180Llb9R8pe", "id": 476, "bot": {"id": 8861}}, "visitor": {"key": "a569015fa03d41a283ed4c66c4601966", "id": 826373}, "timestamp": "2023-09-01 14:13:32.141788"}]}

//JAVASCRIPT RESPONSE
{"events": [{"event": {"type": "message", "payload": {"message_by": {"email": null, "id": null, "type": "visitor"}, "message": {"type": "javascript.response", "payload": {"variables": {"\u00bf\u00b7$user.info.JS1\u00b7?": "hj", "\u00bf\u00b7JS2\u00b7?": "Mtech"}}}}}, "conversation": {"key": "42bb83f00d8240e5bb41290a12eb44401693552452", "id": 7525695}, "account": {"key": "VGYh5KEUxnaS043726528180Llb9R8pe", "id": 476, "bot": {"id": 8861}}, "visitor": {"key": "a569015fa03d41a283ed4c66c4601966", "id": 826373}, "timestamp": "2023-09-01 14:13:45.503552"}]}

//SLIDER RESPONSE
{"events": [{"event": {"type": "message", "payload": {"message_by": {"email": null, "id": null, "type": "visitor"}, "message": {"type": "slider.response", "payload": {"value": 30, "text": "30"}}}}, "conversation": {"key": "42bb83f00d8240e5bb41290a12eb44401693552452", "id": 7525695}, "account": {"key": "VGYh5KEUxnaS043726528180Llb9R8pe", "id": 476, "bot": {"id": 8861}}, "visitor": {"key": "a569015fa03d41a283ed4c66c4601966", "id": 826373}, "timestamp": "2023-09-01 14:13:45.503552"}]}

//SLIDER
{"events": [{"event": {"type": "message", "payload": {"message_by": {"email": "[email protected]", "id": "8292", "type": "user"}, "message": {"type": "slider", "payload": {"title": "What is your preferred value?", "min": 10, "max": 50, "step": "None", "unit": {"label": "", "value": "", "formatter": ""}}}}}, "conversation": {"key": "42bb83f00d8240e5bb41290a12eb44401693552452", "id": 7525695}, "account": {"key": "VGYh5KEUxnaS043726528180Llb9R8pe", "id": 476, "bot": {"id": 8861}}, "visitor": {"key": "a569015fa03d41a283ed4c66c4601966", "id": 826373}, "timestamp": "2023-09-01 14:13:32.141788"}]}

//APPOINTMENT BOOKING RESPONSE
{"events": [{"event": {"type": "message", "payload": {"message_by": {"email": null, "id": null, "type": "visitor"}, "message": {"type": "appointment_booking.response", "payload": {"event_id": 622, "is_booking_confirmed": true, "is_booking_failed": false, "event_name": "fsefgr", "visitor_timezone": "(GMT+05:30) Asia/Calcutta", "variables": [{"type": "text", "name": "visitor_name", "value": "nik1"}, {"type": "text", "name": "param__gcal_selected_slot_time", "value": "10:00"}, {"type": "text", "name": "param__gcal_selected_slot_date", "value": "01/09/2023"}, {"type": "text", "name": "param__gcal_selected_slot_day", "value": "Friday"}]}}}}, "conversation": {"key": "42bb83f00d8240e5bb41290a12eb44401693552452", "id": 7525695}, "account": {"key": "VGYh5KEUxnaS043726528180Llb9R8pe", "id": 476, "bot": {"id": 8861}}, "visitor": {"key": "a569015fa03d41a283ed4c66c4601966", "id": 826373}, "timestamp": "2023-09-01 14:13:45.503552"}]}

//BUTTON RESPONSE
{"events": [{"event": {"type": "message", "payload": {"message_by": {"email": null, "id": null, "type": "visitor"}, "message": {"type": "button.response", "payload": {"body": "Button 1", "callback": {}}}}}, "conversation": {"key": "42bb83f00d8240e5bb41290a12eb44401693552452", "id": 7525695}, "account": {"key": "VGYh5KEUxnaS043726528180Llb9R8pe", "id": 476, "bot": {"id": 8861}}, "visitor": {"key": "a569015fa03d41a283ed4c66c4601966", "id": 826373}, "timestamp": "2023-09-01 14:13:45.503552"}]}

//FORM RESPONSE
{"events": [{"event": {"type": "message", "payload": {"message_by": {"email": null, "id": null, "type": "visitor"}, "message": {"type": "form.response", "payload": {"fields": [{"label": "Name", "variable": "\u00bf\u00b7$user.info.age\u00b7?", "type": "text", "value": "abc", "extra": "None"}, {"label": "Email", "variable": "\u00bf\u00b7$user.info.email\u00b7?", "type": "email", "value": "[email protected]", "extra": "None"}, {"label": "Phone", "variable": "\u00bf\u00b7$user.info.phone\u00b7?", "type": "phone", "value": "+916767667676", "extra": {"country_code": "91"}}]}}}}, "conversation": {"key": "42bb83f00d8240e5bb41290a12eb44401693552452", "id": 7525695}, "account": {"key": "VGYh5KEUxnaS043726528180Llb9R8pe", "id": 476, "bot": {"id": 8861}}, "visitor": {"key": "a569015fa03d41a283ed4c66c4601966", "id": 826373}, "timestamp": "2023-09-01 14:13:45.503552"}]}

//FILE UPLOAD RESPONSE
{"events": [{"event": {"type": "message", "payload": {"message_by": {"email": null, "id": null, "type": "visitor"}, "message": {"type": "file_upload.response", "payload": {"type": "image", "payload": {"mime_type": "image/jpeg", "link": "https://m-chat-conversation-attachment-dev.storage.googleapis.com/8861/Visitor%20-%20A27187-355aaabc63aa46aaa31b4a6ab1a89dd01693458824/30cb79cc-47bd-11ee-8b81-a241eeeaf60f_sample-clouds-400x300.jpg", "file_name": "sample-clouds-400x300.jpg"}}}}}, "conversation": {"key": "42bb83f00d8240e5bb41290a12eb44401693552452", "id": 7525695}, "account": {"key": "VGYh5KEUxnaS043726528180Llb9R8pe", "id": 476, "bot": {"id": 8861}}, "visitor": {"key": "a569015fa03d41a283ed4c66c4601966", "id": 826373}, "timestamp": "2023-09-01 14:13:45.503552"}]}

//APPOINTMENT BOOKING
{"events": [{"event": {"type": "message", "payload": {"message_by": {"email": "[email protected]", "id": "8292", "type": "user"}, "message": {"type": "appointment_booking", "payload": {"event_id": 622, "duration": {"label": "minutes", "value": 30}, "title": "fsefgr"}}}}, "conversation": {"key": "42bb83f00d8240e5bb41290a12eb44401693552452", "id": 7525695}, "account": {"key": "VGYh5KEUxnaS043726528180Llb9R8pe", "id": 476, "bot": {"id": 8861}}, "visitor": {"key": "a569015fa03d41a283ed4c66c4601966", "id": 826373}, "timestamp": "2023-09-01 14:13:32.141788"}]}

Status change

When the conversation status changes i.e. chat changes to open or closed.

Assignee exchange

When the assignee of the chat changes from bot to agent or amongst agents.

Variable

Creation or updation of the value stored in the variable.

Label

Creation or attachment of a label to a chat.

Note

When a note has been added to a chat

Subscribing to events

To subscribe to events, follow the below steps:

Step 1: Enable the events feature

Turn on the feature, and enter your webhook endpoint and a token that would be passed when the event is published.

Step 2: Select events

Select the events that you want to listen to and save.

Refer to the payload as shown in the above events.

Step 3: Test the webhook

Upon saving, we'll send a HTTP POST request to the provided endpoint along with the token. We will expect the same token provided as response with 200 OK.

Last updated