aws-lex-web-ui
aws-lex-web-ui copied to clipboard
File/photo upload
In addition to the default Lex slot types, would it be possible to do add a custom step on the chat bot - for instance, request a user to upload a file or photo (and store it on S3), then return to the Lex flow?
Hello,
This may be possible by embedding the Lex Web UI as an iframe and using the iframe API. In this scenario, the parent page hosting the iframe would be monitoring the Lex state updates to know when to prompt the user to upload the file (e.g. based on intent, dialogState or sessionAttribute).
Once the file has been uploaded, the upload function in the parent page would call the postText
iframe API function (either function or event) to send an utterance signaling that the file has been uploaded. The utterance can include a link that the bot can use to fill a slot or use in a Lambda hook.
Hope this helps. Let me know if you have further questions or comments.
-- Oliver
Any option to implement it from the console?
this is now possible (almost) with the new markdown feature!
with a markdown answer you can embedd an html tag and this will give a upload button in the bot response.
however, you will need to write a js handler for that. I did this in a project using the vue component and wrote a delegated handler to handle the file upload.
@JohnCalhoun - can you give an example on how you used the markdown feature? Are there any open sourced examples available?
Hi guys - any examples on how to achieve this?
@JohnCalhoun is there a chance you could share an example of that code? Looking for a way to upload a data (or .txt) file to a chat window.
@Ruzard I know it's bit late, but is there any chance you have found a workaround for that? Please share if you do. Thanks.
@JohnCalhoun any code update on this?
I believe it's doable. Couple of approaches came to my mind. If your application interacting with Lex via AWS SDK (such as boto3) then you can give permission to same boto3.client to access (s3) and throw the file there. See how boto3 with Django are doing it
Second approach is via Lambda function. Let lex invoke Lambda function responsible for communicating with AWS SDK to take the file and put it inside a predefined bucket
I've configured Django to put files in S3 and in separate project, I integrated Telegram with Lex So I believe it's doable