Comments

  • Abhishek Singh

    Hi Sikaar,

    I am looking for some guidance to integrate Alexa to my Chatbot which is currentlly using facebook channel and android. Could you please provide some links for well detailed documentation or steps.

     

    Thanks,

    Abhishek

  • Abhishek Singh

    For me scenario is same.

    To get the access token:

    curl -X POST -H "Content-Type: application/x-www-form-urlencoded" -H "Authorization: Bearer <app_secret_key>" -d "grant_type=client_credentials" https://ccadmin.dfsdsdfsdfsdfsdfd.com/ccadmin/v1/login

    To get the response:

    curl -X GET -H "Authorization: Bearer <access_token_received_from_above_step>" https://ccadmin.dfsdsdfsdfsdfsdfd.com/ccstore/v1/products

     

    I am not able to figure out what policy to choose for and value to these policy sub-fields.

    Error i am getting is

    {
      "type": "http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.1",
      "status": 500,
      "title": "Internal exception invoking Rest Connector.",
      "detail": "An unexpected exception occurred internal to the REST Connector. Review the exception and try calling the service again. If the exception occurs again, contact Oracle Support Services.",
      "o:ecid": "bceef410-ce73-47f7-aac8-cf0da14712ca-00032a15, 0:6",
      "o:errorCode": "MOBILE-16202",
      "o:errorPath": "/mobile/tools/1.0/ui-tooling/endpoint/mobile/connector/productlist",
      "o:errorDetails": [
        {
          "type": "http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.1",
          "title": "oracle.cloud.mobile.core.security.wss.WssException",
          "detail": "oracle.wsm.security.SecurityException: WSM-00398 : The OAuth2 policy configuration property token-uri has an invalid value of \"http://host:port/tokens\". The value must point to a valid Oauth token endpoint and should be specified in the form \"http(s)://host:port/tokens\"; it should not be a null or empty string.",
          "o:errorDetails": [
            {
              "type": "http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.1",
              "title": "oracle.wsm.security.SecurityException",
              "detail": "WSM-00398 : The OAuth2 policy configuration property token-uri has an invalid value of \"http://host:port/tokens\". The value must point to a valid Oauth token endpoint and should be specified in the form \"http(s)://host:port/tokens\"; it should not be a null or empty string."
            }
          ]
        }
      ]
    }
    
  • Abhishek Singh

    Bot builder version is as in snapshot below

  • Abhishek Singh

    Hi Frank,

    We have upgraded our OMCe instance to 18.2.5  and Bot Builder version is 18.2.2. Still i am not seeing where to locate QnA. Could help me on it. Below are the snapshot of instance version.

  • Abhishek Singh

    On the bot builder, i can see the following version.

  • Abhishek Singh

    providing the details in snapshot of mcs instance.

    thanks,

    abhishek

  • Abhishek Singh

    Hi Sunil,

    I am also facing same issue and there is another thread too. You can have look at it and see if you are able to connect the dots as i am looking for answer too.

    Post: Failing to create connector to call CX Cloud REST api in MCS
    https://cloudcustomerconnect.oracle.com/posts/e14522169b
     
    Please share if you are able to crack the puzzle.
     
    Thanks,
    Abhishek
     
  • Abhishek Singh

    Hi frank,

    I tried with lot of permutations and combinations as exactly i could not figure it out. here are some tried approach yet failed

        req.oracleMobile.connectors.cxproductsconnector.post(
    //    req.oracleMobile.connectors.cxproductsconnector.post(
    // 'login',
    // { externalAuthorization: 'Bearer '+appkey },
    //    {qs : {}, headers: headers}
     
     
    //post(resourceName, object, options, httpOptions)
     
       'login', // resource
    //    req.body, // object
    null,
    //   {  externalAuthorization: req.header('external-authorization')},  // options
      {  externalAuthorization: req.header('external-authorization') , inType: 'json'},  // options
                    //     null
     
            {  qs:     {}, 
             headers: { "accept": req.header('accept'),
                       "Content-Type": req.header('application/x-www-form-urlencoded'),
    "Authorization": req.header('Bearer '+appkey),
    "grant_type": req.header('client_credentials')
    }
                }
    ).then(
  • Abhishek Singh

    Forgot to thank, hope you ignore my ignorance as rightly it has been said, "Ignorance is blisssss" :)

    Thank you Frank.

  • Abhishek Singh
  • Abhishek Singh

    I just removed just two line from the above code and it worked great. But seeking further clarification on what is the meaning of not putting those two lines

    conversation.reply(cardResponseMessage);
    // conversation.keepTurn(false);
    // conversation.transition();
    done();

     

  • Abhishek Singh
    "use strict";
     
    var log4js = require('log4js');
    var logger = log4js.getLogger();
    console.log(" Abhishek: inside products.js file of tst_cxproductsccs module");
    module.exports = {


     
    metadata: () => ({
    "name": "CX.tst_products",
    "properties": {
    "productName": { "type": "string", "required": false },
    "brandName": { "type": "string", "required": false },
    "listPrice": { "type": "number", "required": false },
    "salePrice": { "type": "number", "required": false },
     
    "variable": { "type": "string", "required": true },
    "cardlayout": { "type": "string", "required": false },
    "keepTurn": { "type": "boolean", "required": false }
    },
    "supportedActions": ["found", "error", "textReceived"]
    }),
     
    invoke: (conversation, done) => {
     
    // context parameters
    const productName = conversation.properties().productName ? conversation.properties().productName : "";
    const brandName = conversation.properties().brandName ? conversation.properties().brandName : "";
    const listPrice = conversation.properties().listPrice ? conversation.properties().listPrice : "";
    const salePrice = conversation.properties().salePrice ? conversation.properties().salePrice : "";
     
    // card parameters
    var cardLayout = conversation.properties().cardlayout ? conversation.properties().cardlayout : "vertical";
    var keepTurn = conversation.properties().keepTurn ? conversation.properties().keepTurn : false;
    var variableName = conversation.properties().variable;
     
    // card tracker, if true i.e. already rendered, else yet to be rendered
    var statetracker = (conversation.variable('___cardcomp_state___') == 'true') ? 'true' : 'false';
     
    console.log("Abhishek: productName " + productName + " brandName " + brandName + " listPrice " + listPrice + " salePrice " + salePrice);
    console.log('Abhishek: cardLayout ' + cardLayout);
    console.log('Abhishek: keepTurn ' + keepTurn);
    console.log('Abhishek: variableName ' + variableName);
    console.log('Abhishek: statetracker ' + statetracker);
     
    // query string arguments
    var args = {};
    args.productName = productName;
    args.brandName = brandName;
    args.listPrice = listPrice;
    args.salePrice = salePrice;


     
     
    // let postbackpayload = conversation.postback();
    // console.log("Abhishek : before any if else postbackpayload " + JSON.stringify(postbackpayload));
    console.log('Abhishek: before any if else statetracker '+statetracker);
    //handle postback response i.e. user has selected one option among the cards
    // postback is true and statetracker is true
    if (conversation.postback() && statetracker == 'true')
    {
    console.log('Abhishek: Inside postback and card is already rendered')
    //reset state tracker ,
    conversation.variable('___cardcomp_state___', 'false');
     
    //postback contains a key-value object
    let postbackpayload = conversation.postback();
     
    console.log('Abhishek: variableName ' + variableName+' getting updated with '+ postbackpayload[variableName]);
     
    // console.log('Abhishek:variableName ' + postbackpayload[variableName]);
    // update variable with the postback value
     
    conversation.variable(variableName, postbackpayload[variableName]);
    console.log(' Abhishek : keepTurn '+keepTurn);
    conversation.keepTurn(keepTurn);
    conversation.transition('found');
    done();
     
    }
    //handle text response returning textReceived action as CRC component does
    else if (conversation.text() && statetracker == 'true')
    {
     
    console.log(' Abhishek: text has been received and card has been already rendered')
    //reset state tracker
    conversation.variable('___cardcomp_state___', 'false');
    conversation.transition('textReceived');
    //navigate to the next state with no further user input required
    conversation.keepTurn(true);
    done();
    }
     
    else{


     
    conversation.variable('___cardcomp_state___', 'true');
     
    conversation.oracleMobile.custom.tst_cxproducts.post('products', args, {
    inType: 'json'
    }).then(
     
    function (result) {
     
    //set state tracker indcating that card has been rendered
    console.log('Abhishek : inside Else i.e. rendering first time');
     
    var productsInfo = JSON.parse(result.result); // returned from shared api string
    var prodObj = JSON.parse(productsInfo); // object
    var itemArray = prodObj.items; // all items
    console.log('Abhishek: the number of items we have '+itemArray.length);
    var serviceuri = 'https://ccadmin-stage-nbgb.oracleoutsourcing.com';
    console.log('Abhishek: statetracker ' + statetracker);
     
    var cards = []; // to store messageModel objects
     
    if ((typeof itemArray) === "object") {
     
    for (var indexOfObject in itemArray) {
     
    var prodImages = itemArray[indexOfObject].thumbImageURLs;
     
     
    var brand = itemArray[indexOfObject].brand ? itemArray[indexOfObject].brand : "--";
    var description = itemArray[indexOfObject].description ? itemArray[indexOfObject].description : "--";
    var displayName = itemArray[indexOfObject].displayName ? itemArray[indexOfObject].displayName : "--";
    var lsPrice = itemArray[indexOfObject].listPrice ? itemArray[indexOfObject].listPrice : "--";
    console.log('Abhishek: Inside Else, action key '+variableName+' value '+brand);
     
     
    console.log(' prodImages.length '+prodImages.length+ '(typeof prodImages '+(typeof prodImages));
     
    if (prodImages.length != 0 && (typeof prodImages) === "object") {
    console.log('Abhishek : if of push ');
    let action = conversation.MessageModel().postbackActionObject('Buy at' + lsPrice + ' only', null, {
    //define which variable to update when postback action is used
    [variableName]: brand
    });
     
    let cardObj = conversation.MessageModel().cardObject(brand, description, serviceuri + prodImages, null, [action]);
    cards.push(cardObj);
    } else {
    console.log('abhishek : inside else of push');
     
    let action = conversation.MessageModel().postbackActionObject('Buy at' + lsPrice + ' only', null, {
    //define which variable to update when postback action is used
    [variableName]: brand
    });
    let cardObj = conversation.MessageModel().cardObject(brand + '\n' + displayName, description, null, null, [action]);
    cards.push(cardObj);
     
    }
     
    } // end of for loop
    } // end of if
     
     
    // var cardResponseMessage = conversation.MessageModel().cardConversationMessage(cardLayout, cards, null);
    var cardResponseMessage = conversation.MessageModel().cardConversationMessage(cardLayout, cards);
     
    conversation.reply(cardResponseMessage);
    conversation.keepTurn(false);
    conversation.transition("found");
    done();
    }, // end of result
     
    function (error) {
    var errorInfo = JSON.parse(error.error); // returned from shared api
    conversation.reply({ text: 'Oops! Error encountered ' + JSON.stringify(errorInfo) });
    conversation.transition("error");
    done();
    } // end of error
     
     
    ); // end then
    } // end of else
    } // end of invoke
    }; // end of exports
  • Abhishek Singh

    I am getting the same issue, In JSON response, i am getting as below. So any solution till now?

    "errorState": "callInstantApp",
                  "errorMessage": "javaException:Schema specific part is opaque.",
                  "currentDialogState": "System.DefaultErrorHandler",
                  "executedStates": [
                    "moreAnimals",
                    "evaluateDone",
                    "isDone",
                    "callInstantApp",
                    "System.DefaultErrorHandler"
    
  • Abhishek Singh

    I am facing similar issue with connector calling, tried two approaches, no success

    Tried two approached, failed in both

    1.

        req.oracleMobile.connectors.cxproductsconnector.post(   
    '/login', // resource
             { externalAuthorization: req.header('external-authorization')},
            
         { qs: {},
         headers: { "accept": req.header('accept'),
         "Content-Type": req.header('application/x-www-form-urlencoded'),
                           "Authorization": req.header('Bearer '+appkey),
                          "grant_type": req.header('client_credentials')
                         }
         }

     

    2.

      var appkey = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eytYjA3ZCc3MiOiJhcHBsaWNhdGlvbkF1dGgiLCJleHAiOjE1NjI4MzcwMTUsImlhdCI6MTUzMTMwMTAxNX0=.Qh4nwp51z824xCxEj9A0gSkwM2Xf1T2+/8j3QG1hWLw=';
     
      var headers= {
                      'Content-Type': 'application/x-www-form-urlencoded',
                        'Authorization': 'Bearer '+appkey,
                    };
     
    var body = {
                  'grant_type' : 'client_credentials'
                  };
      service.post('/mobile/custom/tst_cxproducts/products', function(req,res) {
     
        req.oracleMobile.connectors.cxproductsconnector.post(
          '/login',
           body,
           {inType: 'json', externalAuthorization: 'Bearer '+appkey },
         {qs : {}, headers: headers}
  • Abhishek Singh

    Tried two approached, failed in both

    1.

        req.oracleMobile.connectors.cxproductsconnector.post(   
    '/login', // resource
             { externalAuthorization: req.header('external-authorization')},
            
         { qs: {},
         headers: { "accept": req.header('accept'),
         "Content-Type": req.header('application/x-www-form-urlencoded'),
                           "Authorization": req.header('Bearer '+appkey),
                          "grant_type": req.header('client_credentials')
                         }
         }

     

    2.

      var appkey = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eytYjA3ZCc3MiOiJhcHBsaWNhdGlvbkF1dGgiLCJleHAiOjE1NjI4MzcwMTUsImlhdCI6MTUzMTMwMTAxNX0=.Qh4nwp51z824xCxEj9A0gSkwM2Xf1T2+/8j3QG1hWLw=';
     
      var headers= {
                      'Content-Type': 'application/x-www-form-urlencoded',
                        'Authorization': 'Bearer '+appkey,
                    };
     
    var body = {
                  'grant_type' : 'client_credentials'
                  };
      service.post('/mobile/custom/tst_cxproducts/products', function(req,res) {
     
        req.oracleMobile.connectors.cxproductsconnector.post(
          '/login',
           body,
           {inType: 'json', externalAuthorization: 'Bearer '+appkey },
         {qs : {}, headers: headers}