Webhooks

Using a webhook is a simple way to take the content of a Frescochat chat transcript and process it for use on your own server. For example, you could add it to your own custom CRM, push it into your marketing automation platform or even perform additional analytics on every conversation.

Events To subscribe

  • End Chat
  • Offline Message



Create a webhook endpoint. A webhook endpoint is a URL on your server that will receive each transcript when a conversation completes, e.g:

http://www.yourhost.com/frescochat_endpoint.php

On FrescoChat Control Panel, select Account Settings





Enter your target URL and select the web hooks to subscribe




Your webhook needs to return a 200 OK to FrescoChat. 


Webhook format

Each webhook is a HTTP POST request made to the URL that you provide in the web app. The request's POST body contains webhook information in JSON format.

The Json you get will have 2 properties:

  • event_type : Describes the event that produced the request. Possible values: end_chat and offline_message
  • body: Describes the full object representing the event

Example of a CHAT_END Json format


{
   "event_type": "end_chat",
   "body": {
      "start_time": "2016-07-09T14:15:24.9300677Z",
      "end_time": "2016-07-09T14:15:28.105898Z",
      "visitor_name": "Edward",
      "ip": "190.18.130.106",
      "trigger": null,
      "messages": [
         {
            "message": "I need help",
            "from": "Edward"
         },
         {
            "message": "Hello Edward, my name is Seb. I'll be with you just in a moment",
            "from": "Seb"
         }
      ],
      "operator_name": "Seb",
      "country": "United States",
      "country_iso": "US",
      "city": "New York",
      "url": "https://www.frescochat.com/",
      "visitor_email": "edward@hishost.com",
      "department": "Sales",
      "selected_agent": 0,
      "fields": [
         {
            "name": "Name",
            "value": "Edward"
         },
         {
            "name": "Email",
            "value": "edward@hishost.com"
         },
         {
            "name": "Message",
            "value": "Please help me signing up"
         },
         {
            "name": "accountid",
            "value": null
         },
         {
            "name": "website",
            "value": null
         }
      ]
   }
}
Example of an Offline Message json format

{
   "event_type": "offline_message",
   "body": {
      "url": "https://www.frescochat.com/",
      "department_name": "Support",
      "fields": [
         {
            "name": "Name",
            "value": "Edward"
         },
         {
            "name": "Email",
            "value": "edward@myhost.com"
         },
         {
            "name": "Message",
            "value": "Hello, I need help installing frescochat on my website."
         },
         {
            "name": "accountid",
            "value": "3cdd5026-4a61-8e8b-1a01cd83a6c3"
         },
         {
            "name": "website",
            "value": "myhost.com"
         }
      ],
      "country": "United States",
      "city": "New York",
      "selected_agent": null,
      "send_to": "support@frescochat.com"
   }
}

Retry Policy


If your server cannot process the request and does not return a 200 OK to FrescoChat, our servers will retry to send you the webhook for 24 hours every 10 minutes. If it keep failing, the webhook will be deactivated.
If you fail to send a 200 OK to our servers, there's  risk that your queue overflows and all subsequent webhooks will not be sent.




Feedback and Knowledge Base