The Message Filter Plugin will allow you to receive any message in your own javascript handler before execution of the typical message delivery flow. This interception point allows you to accomplish things like language translation ( through your own implementation ), add upsell flow for users of different classifications on incoming our outgoing messages and ultimately control the delivery of the message and its content. While the depth of uses and an implementation can be very complex getting started is incredibly simple:
Add the plugin by letting the Userplane API know you require the plugin:
onReady = function () {
up.api.require("MessageFilter", {sentHandler:onSentMessage,receivedHandler:onGetMessage});
}
up.api.addEventListener(up.api.events.READY,onReady);
You must pass the plugin a config which contains both a sentHandler and a receivedHandler which are javascript functions which will be sent a MessageSentEvent and MessageReceivedEvent respectively.
| Parameter | Optional/Required | Default | Description |
|---|---|---|---|
| sentHandler | required | Handler function to receive all MessageSentEvents generated by the SDK. This handler will have priority receiving the event before any other widget or service so you can manipulate the events before they propagate. | |
| receivedHandler | required | Handler function to receive all MessageReceivedEvents generated by the SDK. This handler will have priority receiving the event before any other widget or service so you can manipulate the events before they propagate. |