Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

React component not forwarding all activities to the activityMiddleware #1547

Closed
DavidBurela opened this issue Dec 31, 2018 · 3 comments · Fixed by #1569
Closed

React component not forwarding all activities to the activityMiddleware #1547

DavidBurela opened this issue Dec 31, 2018 · 3 comments · Fixed by #1569
Assignees
Labels
front-burner p1 Painful if we don't fix, won't block releasing size-l 4-8 days

Comments

@DavidBurela
Copy link
Member

The React component seems to only forward activities that are typing or message to the activityMiddleware. This means I can't write client side code to react to bot events.

Using bot v4, if I send an activity like this

await step.context.sendActivities([
    { type: 'typing' },
    { type: 'event' },
    { type: 'event', value: "my event args" },
    { type: 'customEvent' },
    { type: 'customEvent', value: "cool stuff" },
    { type: 'message', text: 'My message' }
    ]);

and in the client side, I hook in an activityMiddleware

activityMiddleware = () => next => card => {
    console.log(card.activity.type);
};

render() {
    return (
        <ReactWebChat activityMiddleware={this.activityMiddleware} directLine={this.directLine} userID="xxxx" />
    );
}

when I check the browser console, only the typing and message activities are sent through to the middleware. No other activities show up.

@corinagum
Copy link
Contributor

Thanks for reporting this issue -- I am able to repro, and this will need to be fixed.

Notes to fixer:
createCoreMiddleware.js on line 28 simply returns the next activity if it's not of type message or typing. @cwhitten @compulim Do we want Web Chat to display anything when special activities are sent? Or can we just make sure that the middleware passes all activities on and leave it at that?

@corinagum corinagum added 4.3 p1 Painful if we don't fix, won't block releasing and removed Pending labels Jan 2, 2019
@compulim
Copy link
Contributor

compulim commented Jan 2, 2019

createCoreMiddleware.js:28 is saying to use next middleware when they are not message or typing.

In BasicTranscript.js:30, we are filtering what to show on the screen. We need to change the filter, there are multiple ways to do that (i.e. need discussion):

  • Un-filter everything in BasicTranscript.js:30
    • Then, use createCoreMiddleware.js to filter out postBack, event, and other activities that was originally filtered
  • Un-filter only certain types of activities, for example, un-filter event activity
    • Use createCoreMiddleware.js to filter them out again

Personally, I lean toward un-filtering all

Either case, we also need to modify shouldShowTimestamp(), because it is relying on shouldShowActivity() right now. If we move the filter to middleware, it might broke timestamp grouping.

We might be able to fix timestamp grouping by looking at the last outcome of middleware (return false means it is hidden), so we can kind of redo the logic without shouldShowTimestamp.

@corinagum corinagum added the size-l 4-8 days label Jan 2, 2019
@cwhitten
Copy link
Member

cwhitten commented Jan 4, 2019

I agree that WebChat should have as little of opinion as reasonable on what activities get filtered.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
front-burner p1 Painful if we don't fix, won't block releasing size-l 4-8 days
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants