papercups-io / chat-widget Goto Github PK
View Code? Open in Web Editor NEWPapercups chat widget
Home Page: https://app.papercups.io/demo
License: MIT License
Papercups chat widget
Home Page: https://app.papercups.io/demo
License: MIT License
Figure out whichever is the easiest first, but eventually we'll very likely need to use an iframe here
Seems like this happens only within the React component implementation, particularly when hooks are being used (e.g. useEffect
, useContext
)
My suspicion is that the message passing between the iframe and the wrapper component cause this to happen when the component is re-rendered in rapid succession.
Potential solutions:
A couple things to try:
Anything else?
If a user opens/closes the chat widget on one page and then navigates to another page, it should remain in the same state.
(This is particularly important when defaulting the chat to "open", because it's annoying to have to keep closing it on every new page.)
Is there any documentation on how to build the widget.js for HTML sites?
I'd like to either make the bot more friendly, or preferably, set a default team member to start the conversation.
The debug messages are polluting the console in production. Can we have a prop that lets us turn them off?
Right now a user can bypass the email requirement by uploading a file.
Is there anywhere to change a users password and remove a user from the app?
Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object.
This error happened while generating the page. Any console logs will be displayed in the terminal window.
../../pages/_document.tsx (91:33) @ Function.getInitialProps
89 | }
90 |
> 91 | const { html, head } = await ctx.renderPage({ enhanceApp })
| ^
92 | const styles = [...flush()]
93 | return { html, head, styles }
94 | }
Function.getInitialProps
pages/_document.js (5:40)
I'm using React with react-helmet to include the scripts and getting a lot of errors via Sentry:
Cannot read property 'contentWindow' of undefined
undefined is not an object (evaluating 'n.iframeRef.contentWindow')
It looks like it's tracing back to
chat-widget/src/components/EmbeddableWidget.tsx
Lines 238 to 240 in c7e70fd
<Helmet>
<script>
{`
window.Papercups = {
config: {
accountId: 'my-account-id',
title: 'Welcome!',
subtitle: 'Ask us anything in the chat window below π',
primaryColor: '#1c64f2',
greeting: '',
newMessagePlaceholder: 'Start typing...',
baseUrl: 'https://app.papercups.io'
},
};
`}
</script>
<script
type="text/javascript"
async
defer
src="https://app.papercups.io/widget.js"
></script>
</Helmet>
Does my config look right? Should I switch over to @papercups-io/chat-widget
?
Rather than requiring devs to override CSS classes, let's add a styles
prop that enabled overriding the chat container properties as well as the chat toggle button properties.
For example, something like this should allow devs to render the widget on the left side of the page rather than the right:
styles={{
container: {left: 20, right: 'auto'},
button: {left: 20, right: 'auto'}
}}
Encountered this somewhat puzzling UI behaviour: when you start typing and the keyboard slides up, the header and previous messages slide up out of view too?
Would be great to keep as much context as possible for the user - is there a way to do this?
Note this is in React Native on iOS with Expo.
Once again, thanks for amazing work as always.π
Is there an API for devs to implement a form for say, raising a ticket?
That would be soooo amazing
I was just curious, being able to implement an iframe on the support page will be so awesome!
Right now you need to run 3 separate repos to get the development environment setup lets make it so that you only need a single one
Scroll behavior is broken in Firefox due to different way it implements flexbox.
Resulting in a double scrollbar and the window is not auto scrolled to the bottom when a client messages.
Cause:
#__next, body, html {
display: flex;
flex-direction: column;
}
Fix:
#__next{
display: flex;
flex-direction: column;
}
body, html {
display: flex;
flex-direction: row;
}
Tested in Firefox, Chrome and Safari
When I run yarn audit
I get the following high vulnerability report:
βββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β high β Incorrect Comparison in axios β
βββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Package β axios β
βββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Patched in β >=0.21.2 β
βββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Dependency of β frontend β
βββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Path β frontend > @papercups-io/chat-widget > @papercups-io/browser β
β β > axios β
βββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β More info β https://www.npmjs.com/advisories/1005018 β
βββββββββββββββββ΄βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
(Note: the code for this lives in the https://github.com/papercups-io/chat-window repo)
Only load the remaining messages if the customer scrolls up.
The problem we're trying to solve is that when too many messages are rendered, it slows down the animation of new messages being displays. So my thinking is that even if we have 100 messages in this.state.messages
, we don't need to render them all.
Open to other solutions as well!
Using Firefox 80.0 (64-bit) on a mac, I try to load the chat widget on this page and this is what I see:
Its weird because the iframe src URL seems to have the right content when opened in a separate window.
Some more context about js lib versions:
yarn list --depth 0 | grep '\(webpack\|paper\|react\)'
ββ @mdx-js/[email protected]
ββ @papercups-io/[email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
In case anyone wants to display some loading indicator in the meantime
Hello, I really like the papercups.
Would love if the placeholder could be a customisable for i18n.
It would be really handy to see when the other party is typing.
As the site owner, it might also be nice to see what the user is typing so that I can provide a faster reply.
Hello there!
My team is using this module to talk to a custom papercups instance.
We'd like to make sure our users aren't running external code as much as possible, which is why we chose papercups.
However when using this module, we noticed that the window is placed in a separate domain. We'd like to place the ChatWindow
component within our app code (possibly even using React.lazy and suspense to only load it ondemand much like what the iframe achieved)
The workaround we're currently evaluating is to add this line to the package.json dependencies field:
"chat-widget-raw": "papercups-io/chat-widget#0293e84"
And include that chat-widget-raw module in our typescript loader configuration.
Is there a plan to expose this component in the future?
Thanks in advance :)
Is the accountId the only thing protecting hackers from accessing our papercups account? Coz that is totally insecure.
Seems to me the best solution for you would be some kind of Auth0 integration.
I'm a Twilio user and looking to provide a chat experience on our web platform. The widget looks awesome, would it be possible to use it outside of the Papercup ecosystem - ie integrate with Twilio APIs for the messaging layer?
Google Ads is flagging the widget for some reason, need to figure out exactly what is causing this...
TODOs:
sandbox
attribute (https://www.w3schools.com/tags/att_iframe_sandbox.asp)I am trying to let a single browser user have multiple, isolated chat sessions at once, on different web pages on the same domain. Is there a way to force this to happen? I am happy for them, for the moment, to appear as multiple customers.
I have tried to provide a different external_id
in the config in each place when I would like an isolated/seperate chat session. The call to https://app.papercups.io/api/customers/identify
sends the unique external_id
but then always returns the same customer_id
.
It's a great piece of software -- looking forward to using it more!
It would be really nice if the widget supported rich responses or at least quick replies. This is very important for chatbot integrations. The way facebook does it could be an inspiration: Facebook conversation components.
I'd like to hook into callbacks for when the chat window is opened, it closes, and when a customer sends a message so that I may push events to Mixpanel / Google Analytics.
Hi. Thanks for your work. I woud like to have a way to set the font (Google fonts) and size to harmonize the design of the chat with the site. See here https://ecordl.ca
I've accidentally uploaded the wrong file it should send when you press send
The requireEmailUpfront option appears not to be working in the latest version available for Heroku Deployment.
Would be nice to be able to style "View new messages" component as well. For example to override the primary color or add the background color to the container so you can style it in case you have a different background as I have here
I can imagine it adding it styles attribute newMessagesNotificationContainer like this:
<ChatWidget
styles={{
toggleContainer: {...},
chatContainer: {...},
toggleButton: {...},
newMessagesNotificationContainer: {
color: "#ffffff"
},
}}
It's hard to tell sometimes if a new message has arrived in the chat widget. Let's add a small sound like we do in the dashboard.
Related to this issue #90
For example the chat widget shows sent just now, even though it's been long I sent it
The widget wont update the fuzzy timestamps until you send a new messgage
Hi, I can see that this project uses theme-ui for it's UI. I think it can easily be ported to the react-native using theme-ui-native. It can be on a separate repo but that would mean maintaining the same codebase twice.
And because there are no native modules for this to work, it can be used with expo too. There are not that many chat products that work on the expo.
Seems like our widget is breaking on Internet Explorer π’
(Seems to be related to the framer-motion
dependency)
Right now if you send an image in markdown (e.g. ![image](https://i.imgur.com/XC13fLf.png)
) you get an empty message:
Eventhough the papercups backend does not (yet) support uploading images it would be nice to have the ability to send images from a 3rd party service such as Imgur and have them render correctly. This could also be good preparation for when the backend does support images.
From email:
I tested this on a physical iphone 6s and it seems that the chat widget doesnβt work. It does not display the keyboard when you try to click and type some text.
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: [email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/react
npm ERR! react@"^17.0.2" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^16.0.0" from @papercups-io/[email protected]
npm ERR! node_modules/@papercups-io/chat-widget
npm ERR! @papercups-io/chat-widget@"^1.1.10" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See C:\Users\karti\AppData\Local\npm-cache\eresolve-report.txt for a full report.
Installing with --legacy-peer-deps
breaks craco
Wondering how to fix this as I am not facile with CSS. Running the chatwidget on an MVP landing page, everything runs properly and all CSS on the site renders except for the chat widget label at the bottom (the button you click to open the chat window). Welcome any tips or tricks. Thanks in advance.
Seems like the widget only has support for react between 16 and 17
When can we expect support for react 18? In the meantime we'll use the raw JS script to add it in as a workaround
npm ERR! node_modules/react
npm ERR! react@"18.0.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^16.0.0 || ^17.0.0" from @papercups-io/[email protected]
npm ERR! node_modules/@papercups-io/chat-widget
npm ERR! @papercups-io/chat-widget@"*" from the root project
Let's add a new prop: hideOutsideWorkingHours
.
If this is true
, we'll check the widget settings settings.account?.is_outside_working_hours
and completely hide the widget if this value is true
.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.