cancel
Showing results for 
Search instead for 
Did you mean: 

SAP GUI to CAI webchat integration - Authenticated Scenario Issue

kalakonda4
Participant
0 Kudos

Hi ,


We are currently working on a end to end solution of both skills based and FAQ BOTs. Framework works fine with Webchat integration to SAP GUI but the issue is with retrieving user details from GUI.

I have configured using below blog but its for non authenticated scenarios, can you guys help me to check how we can retrieve the current user ID whoever is interacting with BOT on SAP GUI.

<<EDIT>> Was able to find the script and embedded in the program but still failing to get the userid due to java script error.


Accepted Solutions (0)

Answers (1)

Answers (1)

JonasB
Contributor
0 Kudos

Hi Srikanth,

SSO would be the only option to securely pass the user context, but as far as I'm aware there is currently no option to achieve this via SAP GUI, as an identity provider login is pre-requisite.

Also I assume it is not possible to execute JavaScript in SAP GUI, so passing the username somehow to the chatbot will also not be possible.

Regards
Jonas

kalakonda4
Participant
0 Kudos

It is possible to execute java script in SAP GUI by passing to HTML classes. I am referring to below script where we can pass logged in user name while invoking the same BOT but i am facing issues with the 'return' statement. It is throwing an error and not returning the desired value.

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 ).

JonasB
Contributor
0 Kudos

I guess this issue is discussed in https://answers.sap.com/questions/13361302/java-script-calling-issue-in-sap-abap-program-erro.html

Anyway I have to make very clear that security-wise you cannot rely on the username being passed from the client, as anyone who has the channel token / id will be able to inject any username. So it's fine for any type of "context" but not for authorisation.

Regards
Jonas