on 05-04-2021 10:58 PM
I am trying to call external BOT from GUI using its HTML/script, this works fine but when i try to send information like userid in the header parameter it doesn't work. When i debugged the program and tried the same html string in browser it throws error "Uncaught SyntaxError: Unexpected token return". Can you please check and let me know what am i doing wring in appending this string.
<<Created dummy BOT so i wont expose my actual token>>
DATA(html_str) =
'<html>' &&
' <head>' &&
' <script>' &&
' window.webchatMethods = ' &&
' { getMemory: (conversationId) => { const memory = { userId: "E123456" }; ' &&
' return { memory, merge: true } } }' &&
' </script>' &&
' </head>' &&
' <body>' &&
' <script src= "https://cdn.cai.tools.sap/webchat/webchat.js" ' &&
' channelId="02b00be2-4fa1-435d-9650-e48e50831913" ' &&
' token="35bb6bbb74173f08e48ca51acc2b8740" ' &&
' id="cai-webchat" > ' &&
' </script>' &&
' </body>' &&
'</html>' .
cl_abap_browser=>show_html(
EXPORTING
html_string = html_str
* modal = modal
position = cl_abap_browser=>middle
title = title
buttons = cl_abap_browser=>navigate_html
format = cl_abap_browser=>portrait
size = cl_abap_browser=>small
* data_table = ext_data
IMPORTING
html_errors = error_list ).
Was able to resolve this issue after adapting the java script code to IE standards. Thanks for all the insights.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
That error is coming because of the missing ";" for the getmemory function. But I believe the HTML itself is incorrect, I assume you pasted the code partially for reference.
'<html>' &&
' <head>' &&
' <script>' &&
' window.webchatMethods = ' &&
' { getMemory: (conversationId) => { const memory = { userId: "123456" }; ' &&
' return { memory, merge: true } } }' &&
' </script>' &&
' </head>' &&
' <body>' &&
' channelId="3132871f-xxxx-xxxx-xxxx-xxxxxxxxxx" ' &&
' token="32556652365XXXXXXXXXX" ' &&
' id="cai-webchat" > ' &&
' </script>' &&
' </body>' &&
'</html>' .
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Try using single quotes (or not quotes if it is just a number) for your userId. It did the trick for me: https://jsbin.com/macuvotoji/edit?html,output
You are also missing part of the WebChat script, but I assume it is a copy paste error.
BR - Jean-Yves
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
82 | |
11 | |
8 | |
8 | |
6 | |
6 | |
6 | |
6 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.