# How to add feedback to an app with sign-in

In an app where people sign in, the feedback dialog belongs in the account menu, and each note should be stored with the name and email of its sender so you can write back.

1. Tell the backend who is signed in and who sent a note. The `actor_hook` returns the user's id, and the `sender_hook` returns `"Name <email>"`:

    ```python
    def actor(request):
        uid = request.state.get("user_id")   # set by your auth code
        return f"user:{uid}" if uid else None

    def sender(request):
        user = current_user(request)         # your app's own sign-in
        return f"{user.name} <{user.email}>" if user else None

    tt.actor_hook = actor
    tt.sender_hook = sender
    ```

    The sender replaces anything typed in the dialog's contact box.

2. Send feedback with your app's sign-in. Give the browser package the fetch function your app uses for authenticated calls:

    ```js
    import { configure } from './vendor/telltale/telltale-web.js'

    configure({ authFetch: myAuthedFetch })
    ```

3. Open the dialog from your menu, with the floating button hidden:

    ```jsx
    const [open, setOpen] = useState(false)

    <MenuItem onClick={() => setOpen(true)}>Send feedback</MenuItem>
    <FeedbackButton open={open} onOpenChange={setOpen} hideTrigger
                    signedInAs={user?.name} showContact={false} />
    ```

    `signedInAs` shows "Sending as ..." in the dialog. If the menu sits inside a header with its own stacking context, render `FeedbackButton` through a portal to `document.body`, or the dialog can be drawn under other parts of the page.

4. Keep signed-out visitors from leaving a contact. `showContact={false}` hides the box in the page; on the server, set:

    ```bash
    export TELLTALE_ANON_CONTACT=false
    ```

5. Check it. Sign in, send a note, and open it in the console as an admin. It shows your name and email. Key holders, such as the reviewer, see the note without the sender.
