Skip to content

Adding a feedback form on reaction button click#5460

Merged
compulim merged 52 commits intomicrosoft:mainfrom
lexi-taylor:users/lexi-taylor/feedbackform
Apr 23, 2025
Merged

Adding a feedback form on reaction button click#5460
compulim merged 52 commits intomicrosoft:mainfrom
lexi-taylor:users/lexi-taylor/feedbackform

Conversation

@lexi-taylor
Copy link
Copy Markdown
Contributor

@lexi-taylor lexi-taylor commented Apr 9, 2025

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

  1. Created the new FeedbackForm under activity
  2. Created a new FeedbackFormTextArea which has specific formatting
  3. Added support for recognizing the feedbackLoop property
  4. Added support for sending the feedback to the bot when a user presses submit
  5. Added localization for title, description, and buttons
  6. Added the ability to customize the generic webchat feedback form

-

  • I have added tests and executed them locally
  • I have updated CHANGELOG.md
  • I have updated documentation

Review Checklist

This section is for contributors to review your work.

  • Accessibility reviewed (tab order, content readability, alt text, color contrast)
  • Browser and platform compatibilities reviewed
  • CSS styles reviewed (minimal rules, no z-index)
  • Documents reviewed (docs, samples, live demo)
  • Internationalization reviewed (strings, unit formatting)
  • package.json and package-lock.json reviewed
  • Security reviewed (no data URIs, check for nonce leak)
  • Tests reviewed (coverage, legitimacy)

@lexi-taylor lexi-taylor changed the title Users/lexi taylor/feedbackform Adding a feedback form on reaction button click Apr 15, 2025
@lexi-taylor lexi-taylor marked this pull request as ready for review April 15, 2025 20:59
Copy link
Copy Markdown
Contributor

@beyackle2 beyackle2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Collaborator

@OEvgeny OEvgeny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, just a few nits

@lexi-taylor lexi-taylor requested a review from OEvgeny April 22, 2025 17:57
OEvgeny
OEvgeny previously approved these changes Apr 22, 2025
const messageThing = useMemo(() => getOrgSchemaMessage(graph), [graph]);
const isFeedbackLoopSupported = hasFeedbackLoop(activity);

const { messageThing, graph } = useMemo(() => {
Copy link
Copy Markdown
Contributor

@compulim compulim Apr 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's do this in the chat adapter patches in MCS, will send things to you on Teams.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
  });
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lexi-taylor let's revert changes related to patch and move it to MCS side.


const { useUIState } = hooks;

const TextArea = forwardRef<
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@OEvgeny or @lexi-taylor could you refactor this in another PR so we don't have two copies of same UI?

@compulim compulim merged commit 8c9cf52 into microsoft:main Apr 23, 2025
25 checks passed
@compulim
Copy link
Copy Markdown
Contributor

compulim commented Apr 23, 2025

Follow-ups:

  • Remove activity patch code by fixing it properly in backend
  • Refactor Fluent.TextArea and FeedbackFormTextArea into a single component

@lexi-taylor lexi-taylor deleted the users/lexi-taylor/feedbackform branch April 25, 2025 15:50
@OEvgeny OEvgeny mentioned this pull request Jun 17, 2025
11 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants