Skip to content
Last updated

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.

PropertyDescriptionValue TypeDocumentation
performReceiveTriggered when a message is receivedfunctionDocumentation
performSendTriggered when Chatlayer wants to send a message through the app integrationfunctionDocumentation
performSubscribeTriggered when a channel is created and a subscription needs to be madefunctionDocumentation
performUnsubscribeTriggered when a channel is deleted and the registered webhook needs to be deletedfunctionDocumentation
performOffloadTriggered when a conversation is offloaded to an external servicefunctionDocumentation

Example

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
        },
    },
};
const messaging = require("./src/messaging");

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