-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Feature: Make thumbnail of upload image into channelData #2138
Comments
Seems related to #2084 |
Unfortunately v3 of Web Chat is in sunset mode right now and we're not performing maintenance that doesn't fall under security issues for v3. Could you try out your bot on a basic v4 web page made by following our sample 01.a? This is just to test if your errors are persisting to v4 of Web Chat. If so, we'll be able to investigate the problem and file this as a bug. Otherwise, my immediate fix recommendation would be to use v4 through CDN or MyGet until we get v4 available via embed, which will hopefully be in the upcoming weeks. |
@tdurnford , thanks your quickly response. I try to upgrade webchat version to V4, it seems this error still exists: Besides, the image can't be show as itself size, it looks like limited in 480px*240 px. |
@handsomeyao77 I'm having a difficult time reproducing this issue. Can you share the files you are uploading? It looks like you are sending a text file and a png. Also, double check the file size. Direct Line limits attachments to 4MB. |
@handsomeyao77 I was able to reproduce the error. The issue only occurs if you pass the Direct Line secret to Direct Line instead of exchanging it for a token first. Try using the code snippet below to test your bot. <!DOCTYPE html>
<html lang="en-US">
<head>
<title>WebChat</title>
<script src="https://cdn.botframework.com/botframework-webchat/latest/webchat.js"></script>
<style>
html, body { height: 100% }
body {
margin: 0;
}
#webchat {
height: 100%;
}
</style>
</head>
<body>
<div id="webchat" role="main"></div>
<script>
(async function() {
const webChatSecret = '<DIRECT_LINE_SECRET>';
const res = await fetch('https://directline.botframework.com/v3/directline/tokens/generate', {
method: 'POST',
headers: {
'Authorization': `Bearer ${webChatSecret}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({ user: { id: 'dl_user_123' }})
});
const { token } = await res.json();
const directLine = window.WebChat.createDirectLine({ token });
window.WebChat.renderWebChat({
directLine,
}, document.getElementById('webchat'));
})().catch(err => console.log(err));
</script>
</body> Thank you @stevkan for recommending this fix. |
@tdurnford , thanks your solution. Unfortunately, it occurs again, the image src attribute in html is: https://bcdirectlineeasia2.blob.core.windows.net/at27104/8RLaaFI7rYl-original |
@tdurnford , this bug is really urgent for me, could you give me more helps? |
@handsomeyao77 Please see the workaround described here: https://github.com/microsoft/botbuilder-dotnet/issues/2143#issuecomment-508830039 |
@EricDahlvang , thank you! I read microsoft/botbuilder-donet#2143 related info, this is different from our scenario. Some times we upload image successfully: But if I refresh our bot page or switch to other same host page , the image gets broken, the request URL is invalid. We save the images in our storage too, but we can't render images in chat window, all the messages in chat window are from bot-framework service. |
Hi @handsomeyao77 The best solution to workaround what you are experiencing is to create a thumbnail of the uploaded file and add it to channelData, then set the contentUrl to that channelData in DIRECT_LINE/INCOMING_ACTIVITY as demonstrated in the linked example. |
Hi@EricDahlvang , thanks your response. I am trying the workaround your mentioned: create a downscale image then add to channelData. Now, I am using this sample React-web-Chat-Redux to create a listener to listen upload file event. But I found that this sample has two ReactWebChats component. One in App.js, the other in webchat.js. Why do we have to init two WebChats? We only one WebChat in our page. |
There is really just one instance of the The App.js file imports the component created in WebChat.js - the one that is acting as a container - and adds it to the App. The App.js import { connect } from 'react-redux';
import React from 'react';
import WebChatContainer from './WebChat';
class App extends React.Component {
render() {
const { props: {
backgroundColor,
dispatch
} } = this;
return (
<div id="app" style={{ backgroundColor }}>
<WebChatContainer appDispatch={ dispatch } />
</div>
)
}
}
export default connect(
({ backgroundColor }) => ({ backgroundColor })
)(App) Hope this helps! |
Hi @EricDahlvang, here are some summaries what i met share to you. #1. Create a listener. #2. Listener implement .
} #3. Upload an image, render in chat window successfully, the contentUrl looks like bot-framework-service, not a base64 data. #4. But if i refresh the page, the contentUrl is invalid, not shown as a base64Data, so image broken. Is there something wrong? |
Append some related functions:
} |
@tdurnford Thanks your explanation, it really helps me a lot. |
@cwhitten We talked about making thumbnail in Web Chat via Could you give me some suggestions in this topic? E.g. do we need to use Web Worker if available? |
We're going to defer the logic into a WebWorker on browsers that support it - if the client is on a browser that does not fully support the isolation to run inside a WebWorker we will run the same logic on the main thread. cc @compulim |
Hi team, Thanks for your workaround: #2138 (comment), we fixed the image broken after refresh issue. But, we encountered the other image related error, image src is a default placeholder: just like this : #2152. The new error is different from the old one, should I create a new issue on GitHub? |
Hi Team, Thanks! |
The PR #2206 for this issue is pending for review. It will generate thumbnails and save it as part of the activity (i.e. channelData). The downscaling is verified to work in IE11 and all modern browsers including Safari. |
[Edit by corinagum]: this issue has a workaround. Please see @EricDahlvang's comment at the bottom of this thread:
Original comment:
Hi team,
I get an frequency error, the pictures can't be rendered in chat window, it's broken.
I view this picture src attribute in html:
src="https://bcdirectlineauseast.blob.core.windows.net/at27055/LSfhGXesbMy-original"
I think this is invalidate, because the right src in html is:
src="https://directline.botframework.com/attachments/F7RM2rUmRwUI1uS3WxU8LF-0/0000113/0/win10-gbi-19.jpg?t=ew0KICAiYWxnIjogIlJTMjU2IiwNCiAgImtpZCI6ICJBT08tZXhGd2puR3lDTEJhOTgwVkxOME1tUTgiLA0KICAieDV0IjogIkFPTy1leEZ3am5HeUNMQmE5ODBWTE4wTW1ROCIsDQogICJ0eXAiOiAiSldUIg0KfQ.ew0KICAiYm90IjogImNoYXRib3Qtc2VhLWludCIsDQogICJzaXRlIjogImd0amo3anhFVWFjIiwNCiAgImNvbnYiOiAiRjdSTTJyVW1Sd1VJMXVTM1d4VThMRi0wLTAwMDAxMTMiLA0KICAibmJmIjogMTU2MjA0OTY3OSwNCiAgImV4cCI6IDE1NjIwNTE0NzksDQogICJpc3MiOiAiaHR0cHM6Ly9kaXJlY3RsaW5lLmJvdGZyYW1ld29yay5jb20vIiwNCiAgImF1ZCI6ICJodHRwczovL2RpcmVjdGxpbmUuYm90ZnJhbWV3b3JrLmNvbS8iDQp9.LKtl-Od1isNFau_40g1SMD4YAF6_qrI7sxC9qRXqWru5UJBzCSHfLWMKlzZbNk3yUMvagSbk2ThXkLxihuWeDIR3wMPVllsz7ubEiaIRqRuRhYtb3I8HpPiERmij1G4SSEar4ZOw1B7B5ugMK3bEf_0o1Ir4B6GNtOU0v6yMzbl52FZUzHjMVeHxDeLUdLF1m79YKWH5zaa74pX_yrXz0BQnahFlXRemAyL8IdKOuOHU7e9j4Zzag6Ca7Ump3xbBa9BCvAzrp_i28zlE7oM8qCzaShLX1iVNWLMcS0-YYGODedlILEOdnn3TCWdJGkPtFidNsQNI0q81fjBwsixOWg"
The webchat version is V3.
We have multiple chat dialog in the same time, if we switch between these dialog, the image message in chat window often broken.
To Reproduce
Steps to reproduce the behavior:
Please kindly help me on this issue, thanks very much!
The text was updated successfully, but these errors were encountered: