{"info":{"_postman_id":"c58dbb6b-e280-46e9-b266-974c2c284b68","name":"Modal Support APIs","schema":"https://schema.getpostman.com/json/collection/v2.0.0/collection.json","toc":[],"description":"<html><head></head><body></body></html>","owner":"35171341","collectionId":"c58dbb6b-e280-46e9-b266-974c2c284b68","publishedId":"2sA3dvjXRn","public":true,"customColor":{"top-bar":"FFFFFF","right-sidebar":"303030","highlight":"FF6C37"},"publishDate":"2024-07-10T13:39:29.000Z"},"item":[{"name":"Receive data from Modal Support Automation","id":"900701ba-6a8d-46e7-9117-9c0f17f09f90","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"POST","header":[],"body":{"mode":"raw","raw":"{\r\n    \"conversation_details\":\r\n        {\r\n            \"conversation_ref\":3536184702,\r\n            \"library_id\":\"2hMmOggdTiP2K5ggqzPm\",\r\n            \"visitor_name\":\"Visitor Name\",\r\n            \"visitor_email\":\"visitor@example.com\",\r\n            \"visitor_ref\":3536182256,\r\n            \"visitor_timezone\":\"America/Los_Angeles\",\r\n            \"visitor_question\":\"How many trees on the earth?\",\r\n            \"start_time\":\"2024-07-01T11:26:45.000Z\",\r\n            \"is_ai_chat\": 1\r\n        },\r\n    \"messages_list\":\r\n        [\r\n            {\r\n                \"message_time\":\"2024-07-01T11:26:45.000Z\",\r\n                \"message_sender_role\":\"visitor\",\r\n                \"message_body\":\"How many trees on the earth?\"\r\n            },\r\n            {\r\n                \"message_time\":\"2024-07-01T11:21:12.000Z\",\r\n                \"message_sender_role\":\"bot\",\r\n                \"message_body\":\"It is estimated that there are over 3 trillion trees on Earth.\"\r\n            },\r\n            {\r\n                \"message_time\":\"2024-07-01T11:27:53.000Z\",\r\n                \"message_sender_role\":\"visitor\",\r\n                \"message_body\":\"Some more questions\"\r\n            },\r\n            {\r\n                \"message_time\":\"2024-07-01T11:28:06.000Z\",\r\n                \"message_sender_role\":\"bot\",\r\n                \"message_body\":\"Of course! Feel free to ask any more questions you have.\"\r\n            },\r\n            {\r\n                \"message_time\":\"2024-07-01T12:00:53.000Z\",\r\n                \"message_sender_role\":\"visitor\",\r\n                \"message_body\":\"Still there?\"\r\n            },\r\n            {\r\n                \"message_time\":\"2024-07-01T11:28:06.000Z\",\r\n                \"message_sender_role\":\"bot\",\r\n                \"message_body\":\"Yes, I'm here! How can I help you today?\"\r\n            }\r\n        ]\r\n}","options":{"raw":{"language":"json"}}},"url":"URL Defined in Automation","description":"<p>First we create an automation with New Message trigger, selecting chat for channel and inbound for message type, along with the webhook URL where modal support automation will POST the conversation data.</p>\n<img src=\"https://content.pstmn.io/9b79c130-efd6-4850-a9b4-673eb8808ef1/aW1hZ2UucG5n\" width=\"704\" height=\"748\" />\n\n<p>After that in the integrations tab, we go to Modal Chat, enable that if not already enabled. Switch widget type to AI Widget, select the automation that you just created from the Automation dropdown and submit, to enable AI chat.</p>\n<p>Below is an example of data that is sent to the webhook URL that is submitted in the Automation. This is a JSON payload with the following structure:</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-json\">{\n  \"conversation_details\": {\n    \"conversation_ref\": 0,\n    \"library_id\": \"\",\n    \"visitor_name\": \"\",\n    \"visitor_email\": \"\",\n    \"visitor_ref\": 0,\n    \"visitor_timezone\": \"\",\n    \"visitor_question\": \"\",\n    \"start_time\": \"\",\n    \"is_ai_chat\": 1\n  },\n  \"messages_list\": [\n    {\n      \"message_time\": \"\",\n      \"message_sender_role\": \"\",\n      \"message_body\": \"\"\n    }\n  ]\n}\n\n</code></pre>\n<p>The <code>conversation_details</code> object contains information about the conversation, including the reference, library ID, visitor details, start time and is_ai_chat. The <code>messages_list</code> array includes details of the messages sent in the conversation, such as the message time, sender role, and message body.</p>\n<p>The value of is_ai_chat should be equal to 1 for an AI conversation. If it is 0 ( Zero ), it means the conversation is being managed manually by Agents.</p>\n","urlObject":{"host":["URL Defined in Automation"],"query":[],"variable":[]}},"response":[],"_postman_id":"900701ba-6a8d-46e7-9117-9c0f17f09f90"},{"name":"Send data to Customer Widget via Modal Support","id":"7a775a74-edd9-4bcc-bfc6-8e1ed854753d","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"auth":{"type":"bearer","bearer":{"token":"<token>"},"isInherited":false},"method":"POST","header":[],"body":{"mode":"raw","raw":"{\r\n    \"conversation_ref\":3536184721,\r\n    \"message_body\":\"This is the reply from the AI bot\"\r\n}","options":{"raw":{"language":"json"}}},"url":"https://api.modalsupport.com/messages/receive","description":"<p>An API key is required in order to POST data to this endpoint. An API key can be retrieved from the Modal Chat integration in the integrations tab</p>\n","urlObject":{"protocol":"https","path":["messages","receive"],"host":["api","modalsupport","com"],"query":[],"variable":[]}},"response":[],"_postman_id":"7a775a74-edd9-4bcc-bfc6-8e1ed854753d"}]}