# Webhook

In this documentation, we will explain how to use webhook in OneTalk.

Head to "Integration" and click "Webhooks" and you can start setup a webhook by clicking "Set" on the top right corner.

<figure><img src="https://4266585843-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LfVupFSqh_qZAY9OiCO%2Fuploads%2FMpPpBryHHhGx6bQAOxQA%2Fimage.png?alt=media&#x26;token=7e0f967c-72ee-480e-bffa-906d99fb7b10" alt=""><figcaption></figcaption></figure>

Enable the webhook and input "Webhook URL" field

<figure><img src="https://4266585843-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LfVupFSqh_qZAY9OiCO%2Fuploads%2FsNU7asbRlS0RUtdhwwdl%2Fimage.png?alt=media&#x26;token=eb176d1e-6513-404a-b42b-bd4cf95a1710" alt=""><figcaption></figcaption></figure>

Next, you will have to choose a minimum of 1 event on "Subscribed Events" and click "Save Changes" to finalize your webhook.

## Webhook Events

### Integration Message Status

this webhook event updates your system about the change in status of messages sent via [Integration API](https://docs.taptalk.io/~/changes/FMvVnz8ZkLFBmR0Wx2wq/onetalk-omnichannel-documentation/onetalk-integration-api/inbox-api).

Request payload example:

<table><thead><tr><th width="245">Field</th><th width="119">Type</th><th>Description</th></tr></thead><tbody><tr><td>type</td><td>string</td><td>Type of webhook event</td></tr><tr><td>integrationMessageStatus</td><td>object</td><td>Contains data of webhook event</td></tr><tr><td>          channelID</td><td>string</td><td>Channel ID</td></tr><tr><td>          channelType</td><td>string</td><td>Channel type</td></tr><tr><td>          contactPhone</td><td>string</td><td>Recipient's phone number</td></tr><tr><td>          reason</td><td>string</td><td>Failed reason</td></tr><tr><td>          status</td><td>string</td><td>Status update on the message</td></tr><tr><td>          timestamp</td><td>timestamp</td><td>Timestamp on the status update</td></tr><tr><td>          trxID</td><td>string</td><td>Transaction ID</td></tr><tr><td>organizationID</td><td>int</td><td>Organization ID</td></tr></tbody></table>

```
{
  "type": "integration_message_status",
  "integrationMessageStatus": { 
    "channelID": "0123456",
    "channelType": "whatsapp|whatsappba",
    "contactPhone": "628123456789",
    "reason": "...",
    "status": "acknowledge|delivered|read|failed",
    "timestamp": 1587352926788,
    "trxID": "000000-0000-0000-0000-000000"
  },
  "organizationID": 1111
}
```

Status 'acknowledge' is updated when WhatsApp has received OneTalk's request to send the message.

Status 'delivered' is updated when WhatsApp recipient has received the message.

Status 'read' is upated when WhatsApp recipient has read the message.

Status 'failed' is updated when there's an error either from TapTalk.io's system or WhatsApp's system.

### Case Resolved

this webhook event updates your system about the changed in case status to "Resolved" in your organization.

Request payload example:

<table><thead><tr><th width="318">Field</th><th width="117">Type</th><th>Description</th></tr></thead><tbody><tr><td>organizationID</td><td>int</td><td>Organization ID</td></tr><tr><td>type</td><td>string</td><td>Type of webhook event</td></tr><tr><td>caseResolved</td><td>object</td><td>Contains data of webhook event</td></tr><tr><td>          caseID</td><td>string</td><td>Case ID</td></tr><tr><td>          channelType</td><td>string</td><td>Channel type</td></tr><tr><td>          channelID</td><td>string</td><td>Channel ID</td></tr><tr><td>          topicID</td><td>string</td><td>Topic ID</td></tr><tr><td>          topicName</td><td>string</td><td>Topic Name</td></tr><tr><td>          assigneeType</td><td>string</td><td>Type of case last assigned to</td></tr><tr><td>          chatbotID</td><td>string</td><td>Chatbot ID if assigned to bot</td></tr><tr><td>          chatbotName</td><td>string</td><td>Chatbot name id assigned to bot</td></tr><tr><td>          agentEmail</td><td>string</td><td>Agent's email if assigned to agent</td></tr><tr><td>          agentFullName</td><td>string</td><td>Agent's name if assigned to agent</td></tr><tr><td>          isJunk</td><td>boolean</td><td>Junk status</td></tr><tr><td>          agentRemark</td><td>string</td><td>Agent's remark on the case</td></tr><tr><td>          createdTime</td><td>timestamp</td><td>Created time</td></tr><tr><td>          counterStartTime</td><td>timestamp</td><td>The time to start counting duration from, in Unix milliseconds.</td></tr><tr><td>          firstResponseTime</td><td>timestamp</td><td>First response time by agent</td></tr><tr><td>          resolvedTime</td><td>timestamp</td><td>Case resolved time</td></tr><tr><td>          isResolvedByAgent</td><td>boolean</td><td>If case resolved by an agent</td></tr><tr><td>          isResolvedByChatbot</td><td>boolean</td><td>If case resolved by a bot</td></tr><tr><td>          isResolvedByContact</td><td>boolean</td><td>If case resolved by contact</td></tr><tr><td>          isResolvedBySystem</td><td>boolean</td><td>If case resolved by system</td></tr><tr><td>          labels</td><td>array</td><td>Array of labels tagged on the case</td></tr><tr><td>          contact</td><td>object</td><td>Contains data of contact</td></tr><tr><td>                    id</td><td>string</td><td>Contact ID</td></tr><tr><td>                    fullName</td><td>string</td><td>Contact's full name</td></tr><tr><td>                    alias</td><td>string</td><td>Contact's alias</td></tr><tr><td>                    email</td><td>string</td><td>Contact's email</td></tr><tr><td>                    phone</td><td>string</td><td>Contact's phone number</td></tr><tr><td>                    customerUserID</td><td>string</td><td>the userID from customer's server</td></tr><tr><td>                    companyName</td><td>string</td><td>Contact's company name</td></tr><tr><td>                    jobTitle</td><td>string</td><td>Contact's job title</td></tr><tr><td>                    agentRemark</td><td>string</td><td>Agent's remark on the contact</td></tr><tr><td>                    customField</td><td>object</td><td>Contains objects of custom field if  there's one or more custom field in the organization</td></tr><tr><td>                         *Field Code*</td><td>object</td><td>Custom field's field code</td></tr><tr><td>                              fieldType</td><td>string</td><td>Custom field's type</td></tr><tr><td>                              value</td><td>string</td><td>Custom field's value</td></tr></tbody></table>

```
{
    "organizationID": 1,
    "type": "case_resolved",
    "caseResolved": {
      "caseID": "958CCF3BB6",
      "channelType": "whatsapp",
      "channelID": "166090",
      "topicID": 1,
      "topicName": "Finance",
      "assigneeType": "agent",
      "chatbotID": "",
      "chatbotName": "",
      "agentEmail": "john@example.com",
      "agentFullName": "John",
      "isJunk": false,
      "agentRemark": "Hello world 3",
      "createdTime": 1589354307263,
      "counterStartTime": 1589354307263,
      "firstResponseTime": 1589355184000,
      "resolvedTime": 1615305000400,
      "isResolvedByAgent": true,
      "isResolvedByChatbot": false,
      "isResolvedByContact": false,
      "isResolvedBySystem": false,
      "labels": [
        "follow up",
        "hello world"
      ],
      "contact": {
        "id": "e148aa04-3e8f-4dd9-82c1-e53c1a93eac1",
        "fullName": "John Doe",
        "alias": "John",
        "email": "",
        "phone": "6281234567890",
        "customerUserID": "johndoe",
        "companyName": "",
        "jobTitle": "",
        "agentRemark": "",
        "customFields": {
          "customer_id": {
            "fieldType": "single_line",
            "value": ""
          },
          "deal_amount": {
            "fieldType": "number",
            "value": ""
          },
          "salutation": {
            "fieldType": "dropdown",
            "value": ""
          }
        }
      }
    }
  }
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.taptalk.io/onetalk-omnichannel-documentation/webhook.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
