# Messaging

Besides the data capabilities that actions offer, it is also possible to add messaging capabilities to your app.
This provides a way to interact with third party messaging channels that are not supported natively by Chatlayer.

To add basic messaging support, at least `performReceive` and `performSend` should be implemented.

| Property | Description | Value Type | Documentation |
|  --- | --- | --- | --- |
| `performReceive` | Triggered when a message is received | [function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions) | [Documentation](/docs/chatlayer/messaging/receiving) |
| `performSend` | Triggered when Chatlayer wants to send a message through the app integration | [function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions) | [Documentation](/docs/chatlayer/messaging/sending) |
| `performSubscribe` | Triggered when a channel is created and a subscription needs to be made | [function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions) | [Documentation](/docs/chatlayer/messaging/subscribing) |
| `performUnsubscribe` | Triggered when a channel is deleted and the registered webhook needs to be deleted | [function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions) | [Documentation](/docs/chatlayer/messaging/subscribing) |
| `performOffload` | Triggered when a conversation is offloaded to an external service | [function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions) | [Documentation](/docs/chatlayer/messaging/offloading) |


## Example

```javascript
module.exports = {
    type: "hook",
    handoverFields: [],
    subscriptionFields: [],
    operation: {
        performOffload: async (sdk, bundle) => {
            // TODO: Write your code to offload to your offloading provider
        },
        performSubscribe: async (sdk, bundle) => {
            // TODO: Write your code to subscribe to your subscription provider
        },
        performSend: async (sdk, bundle) => {
            // TODO: Write your code to send message to your messaging provider
        },
        performReceive: async (sdk, bundle) => {
            // TODO: Write your code to receive message from your messaging provider
        },
        performUnsubscribe: async (sdk, bundle) => {
            // TODO: Write your code to unsubscribe from your subscription provider
        },
    },
};
```

```javascript
const messaging = require("./src/messaging");

module.exports = {
    ...,
    messaging,
};
```