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 | Documentation |
performSend | Triggered when Chatlayer wants to send a message through the app integration | function | Documentation |
performSubscribe | Triggered when a channel is created and a subscription needs to be made | function | Documentation |
performUnsubscribe | Triggered when a channel is deleted and the registered webhook needs to be deleted | function | Documentation |
performOffload | Triggered when a conversation is offloaded to an external service | function | Documentation |
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,
};