Adding a feedback form on reaction button click#5460
Adding a feedback form on reaction button click#5460compulim merged 52 commits intomicrosoft:mainfrom
Conversation
beyackle2
left a comment
There was a problem hiding this comment.
Nothing stands out to me as wrong enough to block this going through, but I'll defer to William to make the actual call here. I left a few comments that should be treated as suggestions.
packages/fluent-theme/src/components/activity/FeedbackForm.module.css
Outdated
Show resolved
Hide resolved
OEvgeny
left a comment
There was a problem hiding this comment.
Looks great, just a few nits
| const messageThing = useMemo(() => getOrgSchemaMessage(graph), [graph]); | ||
| const isFeedbackLoopSupported = hasFeedbackLoop(activity); | ||
|
|
||
| const { messageThing, graph } = useMemo(() => { |
There was a problem hiding this comment.
Why, when the activity does not support feedback loop, we still inject something to pretend the activity support feedback loop?
Will it accidentally overwrite the Message entity if the bot send us one?
There was a problem hiding this comment.
The logic after the if statement is the same as before. It will use the entities on the activity, if no entities are present then no buttons show. If the entities don’t have the feedback actions then they also won’t show.
There was a problem hiding this comment.
Ahhh... if the activity has feedback loop, the activity payload may not look as good as we want, so we need to hack the traffic to add LikeAction/DislikeAction.
There was a problem hiding this comment.
Let's do this in the chat adapter patches in MCS, will send things to you on Teams.
There was a problem hiding this comment.
Notes to myself, the patch code looks something like this.
function getMessageEntity(activity): Entity | undefined {
return activity.entities.find(entity =>
entity['@context'] === 'https://schema.org' &&
entity['@id'] === '' &&
entity['@type'] === 'Message'
);
}
if (hasFeedbackLoop(activity)) {
const messageEntity = getMessageEntity(activity);
const patchedMessageEntity = Object.freeze({
'@context': 'https://schema.org',
'@id': '',
'@type': 'Message',
type: 'https://schema.org/Message',
...messageEntity, // Could be undefined
potentialAction: [...messageEntity.potentialAction || []] // Clone before modify
});
patchedMessageEntity.potentialAction.find(action => action['@type'] === 'LikeAction') ||
patchedMessageEntity.push({
'@type': 'LikeAction',
actionStatus: 'PotentialActionStatus'
});
patchedMessageEntity.potentialAction.find(action => action['@type'] === 'DislikeAction') ||
patchedMessageEntity.push({
'@type': 'DislikeAction',
actionStatus: 'PotentialActionStatus'
});
Object.freeze(patchedMessageEntity.potentialAction);
return Object.freeze({
...activity,
entities: activity.entities.map(
entity => entity === messageEntity ? patchedMessageEntity : entity)
});
}There was a problem hiding this comment.
@lexi-taylor let's revert changes related to patch and move it to MCS side.
|
|
||
| const { useUIState } = hooks; | ||
|
|
||
| const TextArea = forwardRef< |
There was a problem hiding this comment.
@OEvgeny or @lexi-taylor could you refactor this in another PR so we don't have two copies of same UI?
|
Follow-ups:
|
Description
This adds the ability for end users to submit feedback to the bot utilizing a generic feedback form. The form will only show up if the feedbackLoop property is present and if the feedback buttons are placed in the activity actions section. On click of a feedback button, it will render the form. Feedback will not be submitted unless a user actually submits the form.
Specific Changes
-
CHANGELOG.mdReview Checklist
Browser and platform compatibilities reviewedz-index)Documents reviewed (docs, samples, live demo)Internationalization reviewed (strings, unit formatting)package.jsonandpackage-lock.jsonreviewedSecurity reviewed (no data URIs, check for nonce leak)