I will preface this question by mentioning that I am new to both React and Redux...
I am working with example #14 from the BotFramework-WebChat samples.
In addition, to piping the Redux action activities to change the UI, I would also like to include middleware that listens for 'DIRECT_LINE/CONNECT_FULFILLED' and then dispatches 'WEB_CHAT/SEND_EVENT' with the 'webchat/join' payload so that I can display a welcome message.
I tried just modifying dispatchIncomingActivityMiddleware.js to look like the following:
export default function (dispatch) {
return () => next => action => {
if (action.type === 'DIRECT_LINE/INCOMING_ACTIVITY') {
const { activity } = action.payload;
if (
activity.type === 'event'
&& activity.from.role === 'bot'
&& activity.name === 'redux action'
) {
dispatch(activity.value);
}
} else if (action.type === 'DIRECT_LINE/CONNECT_FULFILLED') {
dispatch({
type: 'WEB_CHAT/SEND_EVENT',
payload: {
name: 'webchat/join',
value: {
language: window.navigator.language
}
}
});
}
return next(action);
};
}
Needless to say, it doesn't work. I think this is because now all of the actions are being dispatched to the second app Redux store and not the Web Chat Redux store. My question is, how do I make it do both? Is there a way to dispatch certain actions to the app Redux store and other actions to the Web Chat store? Is there another way to achieve this?