post by Frank Nimphius, May 2020

 

The current version of Oracle Web SDK (oda-native-client-sdk-js-20.5.1) introduced an important forward-looking change in the structure of the message object passed to the delegate object that developers can optionally implement to intercept and modify  user- and  bot messages. The change is minor and is explained in the Oracle Web SDK release notes as follows: 

———- start release note ————

Delegate API – The callback parameter for delegate API has been modified to pass the entire message instead of message.messagePayload object. The return value from the delegate callback also expects message. The change has been done to have consistency with the values passed in Bots.on() message events. This is a breaking change in the API and requires update in the existing implementations. 

For example, the code to set the orientation of cards:

const delegate = {
    beforeDisplay: (messagePayload) => {
        if (messagePayload.type === 'card') {
            messagePayload.layout = 'horizontal';
        }
        return messagePayload;
    }
}
Bots.setDelegate(delegate);
                            
should be changed to:
const delegate = {
    beforeDisplay: (message) => {
        if (message && message.messagePayload && messagePayload.type === 'card') {
            message.messagePayload.layout = 'horizontal';
        }
        return message;
    }
}
Bots.setDelegate(delegate);

———- end release note ————

Note: All TechExchange articles that were impacted by this change have been updated and also been flagged as updated. 

Related Content:

TechExchange Quick-Tip: Extending the Oracle Web SDK Delegate Feature To Execute Code Asynchronously

TechExchange Quick-Tip: How To Use Custom Channel Properties With Oracle Web SDK Messenger To Add Custom Metadata To Bot Responses

 

 

Author