> ## Knowledge Base Index
> Fetch the complete knowledge base index at: https://help.cooby.co/sitemap.xml
> Use this file to discover available pages before exploring further.
> Pure-Markdown content can be obtained by appending a '.md' suffix to the content URLs listed in the sitemap (without the trailing slash).

# Custom Webhook integration guide

|| Only **Custom plan** users can integrate with Webhook. If you are interested in Webhook Integration, please contact the Cooby Sales Team.

In this guide, you'll connect WhatsApp to your destination using Cooby custom Webhooks.

You can use the same Webhook for the 2 different event triggers, or set up separate Webhooks for each event trigger.

### Set up guide

|| This guide uses [webhook.site](https://webhook.site) as an example

1. Go to your workspace [integration center](https://app.cooby.co/integrations)
2. Find **Custom Webhook** and click on **Integration Guide**.

![](https://storage.crisp.chat/users/helpdesk/website/-/a/7/7/6/a776868fb0318800/2_1ubhsho.png =370x650)
3. Create a Webhook endpoint in your desired destination.
* Remember to mark **CORS Headers** as checked

![](https://storage.crisp.chat/users/helpdesk/website/-/a/7/7/6/a776868fb0318800/3_4stcpg.png =850x315)

4. Paste the Webhook URL into the **Trigger actions when receiving WhatsApp messages** field in the Cooby integration guide, then click **Save**.
* If you would like to trigger an action when sending a WhatsApp message, paste your Webhook URL in **Trigger actions when send WhatsApp messages**.

![](https://storage.crisp.chat/users/helpdesk/website/-/a/7/7/6/a776868fb0318800/4_1a3bmpl.png =850x255)
5. Ensure that you see the Webhook URL saved, indicating a successful save.

![](https://storage.crisp.chat/users/helpdesk/website/-/a/7/7/6/a776868fb0318800/5_vy1c9n.png =850x472)
Click to the previous page and click on **Manage Permissions** for the **Custom Webhook** field.

![](https://storage.crisp.chat/users/helpdesk/website/-/a/7/7/6/a776868fb0318800/6_1grbxh0.png =383x650)

7. Turn ON the Custom Webhook permission for those who will trigger Webhook events when they receive WhatsApp messages.

![](https://storage.crisp.chat/users/helpdesk/website/-/a/7/7/6/a776868fb0318800/7_cyh7fk.png =850x186)
8. To ensure that the Webhook integration is set up properly, remember to **refresh** both your WhatsApp Web and the WhatsApp Web of your team members after making any changes to the settings.
* All users in the team who have integration permission will see the **Grant Access to Cooby** popup the next time they open or refresh WAW.
![](https://storage.crisp.chat/users/helpdesk/website/-/a/7/7/6/a776868fb0318800/8_tibdhc.png =850x495)

9. Once you have received the payload, you can use it to set up various actions.

### Payload Format

```
{
  chat_id: string;
  chat_type: "group" | "individual";
  chat_title: string;
  user_phone: string;
  user_email: string;
  direction: "sent" | "received";
  message: {
    id: string;
    type: "call_log" | "chat" | "location" | "payment" | "vcard" | "ciphertext" | "multi_vcard" | "revoked" | "oversized" |   "groups_v4_invite" | "template_button_reply" | "debug" | "image" | "video" | "audio" | "sticker" | "status_v3" | "document" | "product" | "order" | "list" | "interactive" | "interactive_response" | "list_response" | "buttons_response" | "reaction" | "reaction_enc" | "poll_creation" | "request_phone_number" | "poll_update" | "native_flow" | "biz-cover-photo" | "keep_in_chat" | "pin_message" | "unknown";
    text: string;
    file_name: string | null;
    file_url: string| null;
    caption: string | null;
    is_error: boolean;
    error_code: string | null;
    error_message: string | null;
  };
  timestamp: string;
  participants: {
    phone: string;
    wa_name: string;
  }[];
  sender: {
    phone: string;
    wa_name: string;
  };
}
```


### Example payload

```
{
  chat_id: "447441369136_447441368384@c.us";
  chat_type: "individual";
  chat_title: "Sarah Brown";
  user_phone: "447441368384";
  user_email: "support@cooby.co";
  direction: "sent";
  message: {
    id: "3EB093D273669B3BE3D2";
    type: "chat";
    text: "Hi, welcome to Cooby!";
    file_name: "Cooby Image 2023-07-12 at 11.13.32 AM";
    file_url: "https://api.cooby.co/v2/files/xxxxx";
    caption: "Hi, welcome to Cooby!";
    is_error: false;
    error_code: null;
    error_message: null;
  };
  timestamp: "1628843453";
  participants: [
   {
    phone: "447441369136";
    wa_name: "Sarah Brown";
   },
   { 
    phone: "447441368384", 
    wa_name: "Cooby" 
   } 
  ],
  sender: {
    phone: "447441368384";
    wa_name: "Cooby";
  };
}
```


[Learn more about each column's definition](https://help.cooby.co/en/article/webhook-column-definitions-1kbciq1/)

[Learn more about Webhook Integration synchronization frequency](https://help.cooby.co/en/article/webhook-integration-synchronization-frequency-59o16d/)

[Learn more about Webhook integration syncing mechanism](https://help.cooby.co/en/article/webhook-integration-syncing-mechanism-7sv2jx/)

[Learn more about syncing historical messages in webhook integration](https://help.cooby.co/en/article/syncing-historical-messages-in-webhook-integration-4jiwjk/)

We hope this document helps you better understand how Cooby works. For any concerns or questions regarding your Custom Webhook integration, kindly email us at [support@cooby.co](mailto:support@cooby.co) 💜


