OnBeforeMessageSend
After opening an object, such as a service request, an agent will be able to open a Compose Message smart action.
A compose message panel is opened where the agent can send messages. This event is launched before firing the API request to send a message for a particular record. The user should be able to do asynchronous operations in the callback of this event, and resolve or cancel this event. This event will wait for an asynchronous operation to be completed. With this event the user can control the message send flow that happens in VB by either approving or canceling the operation.
In the event request, the user must pass the message type which they intend to subscribe this event for.
Here are the Compose Message smart actions types which must be passed while subscribing this event:
- Compose Internal note (Message type: ORA_SVC_INTERNAL_NOTE)
- Compose Email (Message type: ORA_SVC_EMAIL )
- Compose Web Message (Message type: ORA_SVC_WEB)
- Capture Customer Message(Message type: ORA_SVC_CUSTOMER_ENTRY)
- Compose Message (Super set of all the previous. Message type: ANY)Note:
OnBeforeMessageSend
is an event listenable fromRecordContext
.
Here's a Typescript example:
/// <reference path="uiEventsFramework.d.ts"/>
const frameworkProvider: IUiEventsFrameworkProvider = await CX_SVC_UI_EVENTS_FRAMEWORK.uiEventsFramework.initialize('MyFirstExtensionID');
const tabContext = await frameworkProvider.getTabContext();
const recordContext = await tabContext.getActiveRecord();
const requestObject: IComposeMessageEventRequest = frameworkProvider.requestHelper.createSubscriptionRequest('cxEventBusOnBeforeMessageSendEvent') as IComposeMessageEventRequest;
requestObject.setMessageType('ORA_SVC_WEB');
recordContext.subscribe(requestObject, (message: IEventResponse) => {
const response: IComposeMessageEventResponse = message as IComposeMessageEventResponse;
const messageType: string = response.getResponseData().getMessageType(); return new Promise((resolve, reject) => {
return new Promise((resolve, reject) => {
// custom logic to resolve or reject the message send flow.
});
});
Here's a JavaScript example:
const frameworkProvider = await CX_SVC_UI_EVENTS_FRAMEWORK.uiEventsFramework.initialize('MyFirstExtensionID');
const tabContext = await frameworkProvider.getTabContext();
const recordContext = await tabContext.getActiveRecord();
requestObject.setMessageType('ORA_SVC_WEB');
const requestObject = frameworkProvider.requestHelper.createSubscriptionRequest('cxEventBusOnBeforeMessageSendEvent');
recordContext.subscribe(requestObject, (response) => {
const messageType = response.getResponseData().getMessageType();
return new Promise((resolve, reject) => {
// custom logic to resolve or reject the message send flow.
});
});