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

Custom UI sample error (21.customization-plain-ui) - hooks from 'botframework-webchat-component' not defined #2611

Closed
samazadi opened this issue Nov 18, 2019 · 12 comments · Fixed by #2740
Assignees
Labels
Bot Services Required for internal Azure reporting. Do not delete. Do not change color. bug Indicates an unexpected problem or an unintended behavior. customer-replied-to Required for internal reporting. Do not delete. customer-reported Required for internal Azure reporting. Do not delete.

Comments

@samazadi
Copy link

Screenshots

Version

Describe the bug

Running 21.customization-plain-ui throwing undefined errors for all hooks. Not sure if I'm missing a package, but I'm assuming the sample should work out of the box.

To Reproduce

Steps to reproduce the behavior:

  1. git clone BotFramework-WebChat
    2 cd BotFramework-WebChat/samples/21.customization-plain-ui
  2. npm i
  3. npm start

App starts on localhost:3000 but throws an error "TypeError: Cannot read property 'useSendMessage' of undefined" and stack trace points to "const { useSendMessage } = hooks;"

Expected behavior

App should start up

Additional context

[Bug]

@samazadi samazadi added Bot Services Required for internal Azure reporting. Do not delete. Do not change color. bug Indicates an unexpected problem or an unintended behavior. Pending customer-reported Required for internal Azure reporting. Do not delete. labels Nov 18, 2019
@tdurnford tdurnford assigned tdurnford and compulim and unassigned tdurnford Nov 18, 2019
@marq47
Copy link

marq47 commented Nov 19, 2019

I think not all hooks are completed yet, but if you use latests bits you can test the sample (removing suggested actions component by the moment). Almost every day the list of completed hooks is growing (good work rewriting components).

My problem testing the sample is that using and connecting with our own bot I always get activities as an empty list (useActivities hook). Is there someone experiencing the same? How can I test if responses from bot are arriving ?

Thanks!!

@tdurnford tdurnford added the customer-replied-to Required for internal reporting. Do not delete. label Nov 19, 2019
@tdurnford
Copy link
Contributor

@marq47 The useActivities hook should return an array where the first element in the array is a list of activities.

useActivities(): [Activity[]]

@compulim
Copy link
Contributor

compulim commented Nov 19, 2019

@samazadi thanks for reporting, we should write automated tests for our samples so they don't break from time to time. 🙇🏻‍♂️

@marq47 thanks for trying out our new hooks. :)

We try to scope our hooks into 3 types:

  • Value/setter, following React.useState pattern
    • They will have a signature of useXXX(): [value, (nextValue) => void], same as React.useState.
    • useSendBoxValue: [value: string, (nextValue: string) => void]
    • useLanguage: [language: string] (language is read-only, thus, no setters)
    • useActivities: [activities: Activity[]]
    • They will be named using nouns.
  • Action, e.g. useFocusSendBox, useSendMessage
    • They will have a signature of useXXX(): (...args) => any.
    • They will be named using verbs.
  • Localization, e.g. useLocalize
    • They will have a signature of useLocalizeXXX(identifier, ...args): string.

We are very new to hooks for composing UI components, please feel free to comment.

@samazadi
Copy link
Author

@compulim no worries, i know how it goes. Any instructions on how I can fix it and test out the sample? Or any idea of when it can be fixed?

@samazadi
Copy link
Author

samazadi commented Dec 2, 2019

Any update on these hooks?

@corinagum
Copy link
Contributor

@samazadi sorry for the delay. I am very hopeful that hooks will be fully implemented before the end of this week. We will circle back to this sample once the final PRs are in.

@samazadi
Copy link
Author

samazadi commented Dec 2, 2019

Sounds good, thanks you! :)

@corinagum corinagum added the needs-repro Waiting for repro or investigation label Dec 2, 2019
@samazadi
Copy link
Author

Hi @corinagum just wanted to see if there's been any progress? We're migrating to V4 and I really want to use these hooks in our implementation

@tdurnford
Copy link
Contributor

@samazadi All of the hooks were included in last weeks v4.7.1 release. Updating your botframework-webchat dependency to the latest version should unblock you.

@corinagum corinagum assigned corinagum and unassigned compulim Dec 16, 2019
@corinagum corinagum added R8 and removed needs-repro Waiting for repro or investigation Pending labels Dec 16, 2019
@samazadi
Copy link
Author

@tdurnford quick side question... If I wanted to add custom data to the channelData of my messages, whats the best way to do that using the new hooks?

@tdurnford
Copy link
Contributor

@samazadi using a custom store middleware is probably still the best way to add custom channel data. Take a look at the Piggyback Data on Every Outgoing Activity Web Chat sample.

@samazadi
Copy link
Author

@tdurnford thank you! Any chance there is documentation or examples on how to do this using React?

@compulim compulim mentioned this issue Mar 5, 2020
40 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bot Services Required for internal Azure reporting. Do not delete. Do not change color. bug Indicates an unexpected problem or an unintended behavior. customer-replied-to Required for internal reporting. Do not delete. customer-reported Required for internal Azure reporting. Do not delete.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants