Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. For integrating with the V3 chatbot please import the below code to the Experience Designer > Bot Manager flow/tab.

    Code Block
    languagejson
    [
        {
            "id": "db3f8895.c18028",
            "type": "orbita-adverse_event",
            "z": "25baf5ca.56d3aa",
            "skillConfig": "150ab083.2380ef",
            "name": "Orbita Detect",
            "utterance": "{{msg.payload.text}}",
            "x": 390,
            "y": 840,
            "wires": [
                [
                    "fc69261a.dd45a8"
                ]
            ]
        },
        {
            "id": "fc69261a.dd45a8",
            "type": "function",
            "z": "25baf5ca.56d3aa",
            "name": "Set Namespace",
            "func": "const _ = global.get('lodash');\nconst util = global.get('orbitaUtil');\nlet projectId = util.getProjectId(node);\n_.set(msg, 'orbita.session.NAMESPACE', `symptomtriage:${projectId}`);\n\nreturn msg;",
            "outputs": 1,
            "noerr": 0,
            "x": 580,
            "y": 840,
            "wires": [
                [
                    "7f356695.686e28"
                ]
            ]
        },
        {
            "id": "7f356695.686e28",
            "type": "function",
            "z": "25baf5ca.56d3aa",
            "name": "Check Symptoms",
            "func": "const _ = global.get('lodash');\nconst YES = \"LABEL_1\";\n\nconst NAMESPACE = _.get(msg, 'orbita.session.NAMESPACE');\nconst settings = global.get(NAMESPACE).settings;\n\n\nconst adverseEventDetected = _.get(msg, 'payload.data.adverseEvent[0][0].score', _.get(msg, 'payload.data.adverseEvent.score')) > 0.87 && _.get(msg, 'payload.data.adverseEvent[0][0].label', _.get(msg, 'payload.data.adverseEvent.label')) === YES;\nconst isLaunch = _.get(msg, `payload.session.${NAMESPACE}.isLaunch`);\nlet symptomValue = _.get(msg, 'payload.text');\n\nlet results = _.get(msg, 'data.dynamicData.result');\nlet excludedTerms = settings.excludeUtterancesFromSymTriFlow;\nlet checkUserValue = excludedTerms.findIndex(term => term.toLowerCase() === symptomValue.toString().toLowerCase());\n\n\nif(adverseEventDetected && isLaunch && checkUserValue === -1){\n  _.set(msg, `orbita.session.${NAMESPACE}.symptomValue`, symptomValue);\n  _.set(msg, 'payload.text', 'Symptoms Checker Conversation');\n}\n\n\nreturn [msg,null];",
            "outputs": 1,
            "noerr": 0,
            "x": 790,
            "y": 840,
            "wires": [
                [
                    "6961a47f.5949bc"
                ]
            ]
        },
        {
            "id": "6961a47f.5949bc",
            "type": "function",
            "z": "25baf5ca.56d3aa",
            "name": "Route",
            "func": "const _ = global.get('lodash');\nconst NAMESPACE = _.get(msg, 'orbita.session.NAMESPACE');\n//const NAMESPACE = 'symptomtriage';\nconst settings = global.get(NAMESPACE).settings;\nconst symptomChecker = global.get(NAMESPACE).symptomChecker || {};\nlet symptomCheckerSessionID = symptomChecker.sessionIDStore\n    ? symptomChecker.sessionIDStore[msg.payload.sessionId]\n    : null;\n_.set(msg, 'orbitaBotVersion', 3);\nif (symptomCheckerSessionID) {\n    let formatId = `hbConvId:${symptomCheckerSessionID}`;\n    global.get(`hbConvId:${symptomCheckerSessionID}`, function(err, cacheData) {\n        const input = typeof msg.payload.text === \"string\"\n            ? msg.payload.text.toLowerCase()\n            : msg.payload.text && msg.payload.text.message\n                ? msg.payload.text.message.toLowerCase()\n                : \"\";\n        let genderList = ['male', 'female'];\n        if(typeof msg.payload.text === 'string'){\n            genderIdx = genderList.findIndex(gender => gender.toLowerCase() === msg.payload.text.toLowerCase()); \n        }\n        let results = _.get(msg, 'data.dynamicData.result');\n        // if (results && results.length > 0) {\n        //     let result = results[0];\n            let excludedTerms = settings.excludeUtterancesFromSymConvFlow;\n            let checkUserValue = excludedTerms.findIndex(term => term.toLowerCase() === input.toString().toLowerCase());\n            if(checkUserValue >=0 ){\n                global.set(`hbConvId:${symptomCheckerSessionID}`, undefined);\n                global.set(`hbConvId:${symptomCheckerSessionID}:checkboxes`, undefined);\n                return node.send([msg, null]);\n            }\n        //}\n        // switch(input) {\n        //     case \"open\":\n        //     case \"mychart\":\n        //     case \"covid\":\n        //     case \"covid 19\":\n        //     case \"covid-19\":\n        //     case \"find a location\":\n        //     case \"find location\":\n        //     case \"agent\":\n        //     case \"can i please talk with a person\":\n        //     case \"can i talk to a human\":\n        //     case \"can i talk to a person\":\n        //     case \"can i talk to a real person\":\n        //     case \"can i talk to an agent\":\n        //     case \"can i talk to someone\":\n        //     case \"can i talk to the operator\":\n        //     case \"connect me to a human\":\n        //     case \"customer service\":\n        //     case \"customer service rep\":\n        //     case \"customer service representative\":\n        //     case \"how to chat with a human\":\n        //     case \"how to chat with an agent\":\n        //     case \"how to conncet with a agent\":\n        //     case \"how to conncet with a human\":\n        //     case \"how to conncet with a real person\":\n        //     case \"how to connect with a agent\":\n        //     case \"how to connect with an agent\":\n        //     case \"how to connect with rep\":\n        //     case \"how to connect with representative\":\n        //     case \"how to talk to a human\":\n        //     case \"human\":\n        //     case \"i am having trouble paying my bill\":\n        //     case \"i need to talk to an operator\":\n        //     case \"i want to talk to an agent\":\n        //     case \"i want to talk to someone\":\n        //     case \"i want to talk with a person\":\n        //     case \"let me talk to a human\":\n        //     case \"live agent\":\n        //     case \"mainmenuescalate\":\n        //     case \"need to talk with someone\":\n        //     case \"please let me talk to a human\":\n        //     case \"real person\":\n        //     case \"transfer me to a person\":\n        //     case \"covid screener\":\n        //     case \"ask a question\":\n        //     case \"help\":\n        //     case \"check my symptoms\":\n        //     case \"start checking symptoms\":\n        //     case \"symptom checker\":\n        //         // cacheData = null;\n        //         global.set(`hbConvId:${symptomCheckerSessionID}`, undefined);\n        //         global.set(`hbConvId:${symptomCheckerSessionID}:checkboxes`, undefined);\n        //         return node.send([msg, null]);\n        //         // break;\n        //     default:\n        //       break;\n        // }\n        msg.text = msg.payload.text;\n        if (cacheData) {\n            msg.origPayload = JSON.parse(JSON.stringify(msg.payload));\n            var myText  = msg.payload.text;\n            let formatCheckbox = `hbConvId:${symptomCheckerSessionID}:checkboxes`;\n            var choices = global.get(`hbConvId:${symptomCheckerSessionID}:checkboxes`);\n            if (isNaN(myText) === false && choices && choices.length > 0) {\n                var ans = '';\n                for(var i = 1; i < myText.length; i++) {\n                    if (myText[i] == \"1\") {\n                        var choice = choices[i-1];\n                        ans += choice.text + ',';\n                    }\n                    \n                }\n                if (ans) {\n                    ans = ans.substring(0, ans.length - 1);\n                }\n                if (ans === ''){   // multi select check box but did not click any button.\n                    ans = 'none';\n                }\n                msg.origPayload.text = ans;\n                msg.origPayload.session.recognizedText = ans;\n            }\n        }\n        if (err) {\n            node.warn('error');\n            node.error(err, msg);\n            node.send([msg, null]);\n        } \n        else if(cacheData && cacheData.hasOwnProperty('conversationId')) {\n            msg.payload = cacheData;\n            _.set(msg, `payload.${NAMESPACE}.subFlowName`, 'activityFlow')\n            return node.send([null, msg]);\n        } else if(cacheData && cacheData.state && cacheData.state === 'start') {\n            if(_.get(msg, `payload.session.${NAMESPACE}.symptomValue`)){\n              _.set(msg, `orbita.session.${NAMESPACE}.sexValue`, _.get(msg, 'payload.text'));\n            }\n            _.set(msg, `payload.${NAMESPACE}.subFlowName`, 'conversationFlow')\n            return node.send([null, msg]);\n        } \n        \n        else if((genderIdx > -1) && \n            (_.get(msg, `payload.session.${NAMESPACE}.symptomValue`)) && \n            (_.get(msg, `payload.session.${NAMESPACE}.genderAsked`))){\n            _.set(msg, `orbita.session.${NAMESPACE}.sexValue`, _.get(msg, 'payload.text'));\n            global.get(`hbConvId:${symptomCheckerSessionID}`, function(err, symptomCacheData) {\n              if (err) {\n                node.warn('error');\n                node.error(err, msg);\n                node.send([msg, null]);\n              } else if(symptomCacheData && symptomCacheData.state && symptomCacheData.state === 'start'){\n                _.set(msg, `payload.${NAMESPACE}.subFlowName`, 'conversationFlow')\n                return node.send([null, msg]);\n              }\n            });\n        }\n        else {\n            return node.send([msg, null]);\n        }\n    });\n} else {\n    return node.send([msg, null]);   \n}\n",
            "outputs": 2,
            "noerr": 0,
            "x": 990,
            "y": 840,
            "wires": [
                [
                    "6367ec18.d48104"
                ],
                [
                    "346a7253.36fb4e"
                ]
            ]
        },
        {
            "id": "150ab083.2380ef",
            "type": "alexa-skill-config",
            "skillname": "Symptom-Triage",
            "projectId": "607ee6aa02ca46007aef1752",
            "intents": "[]",
            "skillstate": "fromsession, useSymptomChecker, escalation, flowManager,flow, test,FlowStudio, testState, bill,escalation,confirm_escalation,help,emergency, Reminder, sanity, flow_stud,webWeight,fromSession,flowMngr,scheduleride,aMedication,Survey,whyhelpmessage,medication,callorcomeby,Januvia,survey2,glucose,faqquestion,DailySurveyInProgress,HeadacheSurveyInProgress,MonthlySurveyInProgress,FeedbackSurveyInProgress,AllReportsDone,AskedForChangeResponse,AskedForChangeTwice,MigraineTrackerQuestions1,MigraineTrackerQuestions2,MigraineTrackerQuestions3,StudyQuestions1,StudyQuestions2,StudyQuestions3,Help1,Help2,Help3,AskedForHeadacheStart,AskedForHeadacheStartYesterday,AskedForHeadacheStartTime,AskedForHeadacheEndTime,AskedForHeadacheTimeCorrectness,AskedForHeadacheChangeStartTime,AskedForHeadacheEndDate,InvalidHeadacheTime,AskedForContinuePartial,MaxRecognitionError,ServicePhoneNumber,ConfirmGoHome,ConfirmStop,ConfirmPause,ConfirmCancel,FORTESTING,testState,setup, startup, Survey,flowManager, survey, flowMngr,eventSurvey, whyhelpmessage, HeadacheSurveyInProgress, MonthlySurveyInProgress, FeedbackSurveyInProgress, AllReportsDone, AskedForChangeResponse, AskedForChangeTwice, MigraineTrackerQuestions1, MigraineTrackerQuestions2, MigraineTrackerQuestions3, StudyQuestions1, StudyQuestions2, StudyQuestions3, Help1, Help2, Help3, AskedForHeadacheStart, AskedForHeadacheStartYesterday, AskedForHeadacheStartTime, AskedForHeadacheEndTime, AskedForHeadacheTimeCorrectness, AskedForHeadacheChangeStartTime, AskedForHeadacheEndDate, InvalidHeadacheTime, AskedForContinuePartial, MaxRecognitionError, ServicePhoneNumber, ConfirmGoHome, ConfirmStop, ConfirmPause, ConfirmCancel,pain,dual,TreatmentSurgery,plateletsflow,password,changeappointmentList,MedicalHeart,chooseLocation,cancelAppointment,plateletsFlow, reminder, CheckUser, fromSession, plateletsFlow, cancelAppointment,PlateletsChangeOption,MedicalHemochromatosis, MedicalHeart,LifestyleSTD,setDateOrTimeIntent, FAQ,setTimelanding,setDatelanding,FAQ, fromsession, mayoKB, orbitaKB, askAnother, afterAssessment, phonePrompt, awaitingPhone, confirmPhone, finalPhonePrompt, inChunkedAnswer, appointmentPhonePrompt,reminder,CheckUser,Reminder,sanity,SymptomTriage"
        },
        {
            "id": "slots",
            "type": "slots",
            "z": "",
            "slots": []
        }
    ]

  2. To integrate with V2 Bot please import the below code to the Experience Designer > Bot Manager flow/tab.

...

  1. Copy the respective V2 or V3 bot code.

    1. Go to Experience Designer > Bot Manager Flow > Hamburger Menu > Import > Clipboard.

  2. The above import will add 4 nodes to the Bot Manager tab as shown below.

  3. Connect the nodes as described below screenshot:

    1. Add “http in” node with the “Post” Method to the “Orbita Detect” node.

    2. The first output pin of the “Route” function node should be connected to the “Bot provider v2” node.

    3. Disconnect the “http in” node with the “Post” Method and Bot Provider V2.

    4. Drag and drop a Link out node to the Bot Manager tab and name it.

    5. Connect the second output pin of the “Route” function node to the Link out node.

  4. Double click on the “Bot Provider V2” node and add the below code to the “Bot In Parser” section.

    Code Block
    var _ = global.get('lodash');
    const NAMESPACE = _.get(msg, 'orbita.session.NAMESPACE');
    let symptomValue = _.get(msg, 'orbita.session.${NAMESPACE}.symptomValue');
    if(symptomValue){
        _.set(msg, 'payload.originalRequest.data.symptomValue', 
        symptomValue);
    }
  5. Go to the “Modules Flows” tab

    1. Add a Link In node and name it.

    2. Connect the Link In node with the input pin of symptomstriage sub-flow.

      Image RemovedImage Added

    3. This “Link In” node should be connected to the “Link Out” node which you added in the “Bot Manager” tab.
      In the “Link In” node edit window, select the Link out node you added earlier.
      Refer

  6. Now Deploy the flow and validate it.

...