response from aws lex can be displayed in HTML web page

0 votes

Is it possible to get response from lex into HTML page using Javascript(outside chatbot)?

Say I need details about the some customer, when I enter "Give me details about customer_01" in lex, it must respond back with customer_01 details like name, DOB etc in pop-up window in browser but not inside bot. I've also using AWS lambda and been looking in many blogs and websites, didn't find any solution to this.  

 If this is possible,It would be really great if you could explain the details. I'm building app in python, any solution with other languages is also appreciated.

Thank you in advance.

My code is still in beginner stage, here it is:

#checking if customer_id is in input, if present extracting it and storing in "req_customer"                                                    
query="Select * from customer where customer_id="+"'"+req_customer+"'"     
df= pd.read_sql(query, conn)   #storing result in from SQL in dataframe. 
name=df['name'][0]                                        
address=df['address'][0]                                         
dob=df['dob'][0]                                                 
phno=df['phno'][0]                                             
htm='''<h2>Customer Name: '+name+'</h2>   #these are the things I want to                    
<p>Phone Number: '+phno+'</p>             #display in pop-up window in the        
<p>Date of Birth: '+dob+'</p>             #same page                   
<p>Address: '+address+'</p> '''
    response = {
            "dialogAction": {
                "type": "Close",
                "fulfillmentState": "Fulfilled",
                "message": {
                    "contentType": "CustomPayload",
                    "content": htm                
                }
            }
        }  
   return response
Apr 1, 2020 in AWS by Vaibhav
• 120 points

edited Apr 1, 2020 by Vaibhav 1,964 views
Can you share your code?

Thank you for replying. My code is in beginning stage. I have given sample utterance as 'give details of customer_01'. Next the have give lambda as fulfillment in lex. The flow in lambda function is given below.

#checking if customer_id is in input, if present extracting it and storing in "req_customer"                                                    
query="Select * from customer where customer_id="+"'"+req_customer+"'"     
df= pd.read_sql(query, conn)   #storing result in from SQL in dataframe. 
name=df['name'][0]                                        
address=df['address'][0]                                         
dob=df['dob'][0]                                                 
phno=df['phno'][0]                                             
htm='''<h2>Customer Name: '+name+'</h2>   #these are the things I want to                    
<p>Phone Number: '+phno+'</p>             #display in pop-up window in the        
<p>Date of Birth: '+dob+'</p>             #same page                   
<p>Address: '+address+'</p> '''
    response = {
            "dialogAction": {
                "type": "Close",
                "fulfillmentState": "Fulfilled",
                "message": {
                    "contentType": "CustomPayload",
                    "content": htm                
                }
            }
        }  
   return response

 Please suggest what to do next as I'm stuck here. No idea about how to proceed further. 

Thank you.

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP