Genesys Engage on-premises

 View Only

Discussion Thread View
  • 1.  Not able to read web service /web request output from Genestys composer voice application

    Posted 08-22-2018 13:44
    Hi team,
    We have developed a voice application in composer(8.1.4).we have tried web service /web request block for our REST API (https).
    but in both the block , we are not able to get the output(response) of web service. in default.composer logs we are able to see the web service request and response. but in composer voice application we are getting semantic error , when reading the response.
    kindly help.

    Regards,
    Deepti


    ------------------------------
    Deepti Srivastava
    AGC networks Australia Pty Ltd
    ------------------------------


  • 2.  RE: Not able to read web service /web request output from Genestys composer voice application

    Posted 08-22-2018 16:46
    ​I am taking a shot in the dark, but it's likely that your semantic error is caused by mis-handling the output results from the web service block.
    The output of your web call will be in the form of an object.

    Try this: immediately after your web service block, put in a Script block (ECMA) and print the output result variable in the logs, but use the JSON.stringify() function to do it. If my output result variable is "webOutput", this is how I would do it:
        __Log('RESTful results: '+JSON.stringify(webOutput);

    If this works, and you can see the results in the logs, then everything is fine and you need to use the return variable as an object.
    So, if my web service Block returned {"name":{"firstname":"John","lastname":"Smith"},"type":"business","acctno":"987654321"}
    ...then I could access that data and assign it to variables like this:
    var fName = webOutput.name.firstname;
    var lName = webOutput.name.lastname;
    var acctType = webOutput.type;
    var acctNum = webOutput.acctno;

    Give stringify a try to see what's what.

    Also, to determine the type of variable you are working with, you can use 'typeof', like this:
        var s_type = typeof webOutput;
        __Log('Variable "webOutput" is type: '+s_type);

    https://www.w3schools.com/js/js_datatypes.asp

    ------------------------------
    Todd McCall
    Bank of America
    ------------------------------



  • 3.  RE: Not able to read web service /web request output from Genestys composer voice application

    Posted 09-12-2018 05:36
    Hi Team,
    Customer has provided us https API URl for composer voice application integration.
    we have tried to use directly thuis URL in https request block .its showing us SSL error.
    so now we have developed a .net middleware application.now we are comsuming customer provided https API URl in our application.
    and we uae this middleware web servixe URL in web service block.in we service block.when we put output map false get black response.when we make it true. get json response.

    2018-09-11T18:19:48.372 Int 50035 006C01B9-1001D989 364312896 log  Webservice response is {"CheckBackendResponse":{"xmlns":"http://tempuri.org/","CheckBackendResult":"{\"status\":\"Success\",\"message\":\"valid\",\"responseId\":\"5b97b9ea7aaf613ec45b61a2\"}"}}

    In the above json response we are unable to parse status , message , responseId value .

    Whenever we are trying to assign to  composer variables it shows blank .

    Response from Middleware application :

     <string xmlns="http://tempuri.org/">

    {"status":"Success","message":"valid","responseId":"5b98d0bf9a5d243b0c8c49f1"}

    </string>

     

    Response when output is seen in Composer logs

      {"CheckBackendResponse":{"xmlns":"http://tempuri.org/","CheckBackendResult":"{\"status\":\"Success\",\"message\":\"valid\",\"responseId\":\"5b97a94f7aaf613ec45b616d\"}"}}






    ------------------------------
    Deepti Srivastava
    AGC networks Australia Pty Ltd
    ------------------------------



  • 4.  RE: Not able to read web service /web request output from Genestys composer voice application

    Posted 09-12-2018 09:01
    To help you visualize a JSON structure, indent at the curly brackets, and put a carriage return at every comma like this:
    {
        "CheckBackendResponse":
        {
            "xmlns":"http://tempuri.org/"
            ,"CheckBackendResult":"
            {
                \"status\":\"Success\"
                ,\"message\":\"valid\"
                ,\"responseId\":\"5b97b9ea7aaf613ec45b61a2\"
            }"
         }
    }

    I see a problem though. The value at "CheckBackendResult" is surrounded by quotes. That screws everything up.
    So do this:
    1) Convert the JSON string into an object, then assign the value for key "CheckBackendResult" in a new string.
         Te complete string: s_resp = {"CheckBackendResponse":{"xmlns":"http://tempuri.org/","CheckBackendResult":"{\"status\":\"Success\",\"message\":\"valid\",\"responseId\":\"5b97b9ea7aaf613ec45b61a2\"}"}}

        var j_resp = JSON.parse(s_resp); //This converts the JSON string into an object in a new variable, "j_resp"

        var s_result = j_resp.CheckBackendResponse.CheckBackendResult;
            //now s_result == "{\"status\":\"Success\",\"message\":\"valid\",\"responseId\":\"5b97b9ea7aaf613ec45b61a2\"}"

    2) Remove the backslash escape characters in the new string
        s_result = s_result.replace("\",""); //this will strip out all of the back slashes in the string


    3) convert the new string into a JSON object
        j_result = JSON.parse(s_result);

    4) Reference your values in j_result
        var s_status = j_result.status; //now s_status = "success"

    Good luck with this complicated string, and Happy coding!

    ------------------------------
    Todd McCall
    Bank of America
    ------------------------------



  • 5.  RE: Not able to read web service /web request output from Genestys composer voice application

    Posted 09-12-2018 05:37
      |   view attached

    Customer has shared API(https) URL for integration. we have developed a middleware application in .Net for this https API URl. 
    now we are using middleware application web service URL in web service block .
    In the Webservice block  the value of the property i.e. Map output value to variables when set to true gives us the semantic error .

    But when set to false ,  we get the response  as mentioned below :

     

    2018-09-11T18:19:48.372 Int 50035 006C01B9-1001D989 364312896 log                                                     Webservice response is {"CheckBackendResponse":{"xmlns":"http://tempuri.org/","CheckBackendResult":"{\"status\":\"Success\",\"message\":\"valid\",\"responseId\":\"5b97b9ea7aaf613ec45b61a2\"}"}}

     

    In the above json response we are unable to parse status , message , responseId value .

    Whenever we are trying to assign to  composer variables it shows blank .
    pls find attached logs.

    we have also tried web request block to directly use https URl.but giving us SSL error.

     



    ------------------------------
    Deepti Srivastava
    AGC networks Australia Pty Ltd
    ------------------------------

    Attachment(s)

    zip
    SemanticError.zip   277 KB 1 version


  • 6.  RE: Not able to read web service /web request output from Genestys composer voice application

    Posted 09-12-2018 11:24
    Hello there.

    I think the problem is the response from your web service:

    {  
       "CheckBackendResponse":{  
          "xmlns":"http://tempuri.org/",
          "CheckBackendResult":"{\"status\":\"Success\",\"message\":\"valid\",\"responseId\":\"5b97b9ea7aaf613ec45b61a2\"}"
       }
    }
    Try the followig:

    Try with a different web service and see if the error persist.

    Have a chat with Bevan (AGC Networks NZ) we had many similar problems parsing custom web service responses similar to what you are trying to do.

    Cheers,
    Amauri.

    ------------------------------
    Amauri de Oliveira
    Alctel Telecom
    http://amaurioliveira.com
    ------------------------------



Need Help finding something?

Check out the Genesys Knowledge Network - your all-in-one access point for Genesys resources