예제 #1
0
def run(dialogflowResponse):
    parameters_json = json.loads(
        MessageToJson(dialogflowResponse.query_result.parameters))
    processName = parameters_json['process_name_parameter']

    try:
        # Aktuellen Prozess holen
        process = Process.query.filter_by(processName=processName).first()
        processId = process.id
    except:  #Kein Prozess angegeben, bzw. Prozess nicht gefunden --> alle Prozesse als Button anzeigen
        message1 = dialogflowResponse.query_result.fulfillment_text
        message2 = "These are the processes I can show you a model for:"

        showButtons = []
        for process in Process.query.all():
            button = buttons.createCustomButton(process.processName,
                                                "process_show",
                                                process.processName)
            showButtons.append(button)
        showButtons.extend(buttons.CANCEL_SHOW_BUTTON)

        return responseHelper.createResponseObject([message1, message2],
                                                   showButtons, "", "", "", "")

    message1 = dialogflowResponse.query_result.fulfillment_text
    currentProcess = processId
    currentProcessName = processName

    message2 = '<div id="processSVG" style="cursor:pointer;padding: 5px 0 5px 0;">![BPMN Model](http://127.0.0.1:5000/get_image/' + currentProcessName + '.html)</div>'

    return responseHelper.createResponseObject([message1, message2], [],
                                               currentProcess,
                                               currentProcessName, "", "")
예제 #2
0
def run(dialogflowResponse):

    parameters_json = json.loads(MessageToJson(dialogflowResponse.query_result.parameters))
    processName = parameters_json['process_name_parameter']

    try:
        # Aktuellen Prozess holen
        process = Process.query.filter_by(processName=processName).first()
        processId = process.id
        print(processId)
    except: #Kein Prozess angegeben, bzw. Prozess nicht gefunden --> alle Prozesse als Button anzeigen
        message1 = dialogflowResponse.query_result.fulfillment_text
        message2 = "These are the processes I have a documentation for:"
        docButtons = []
        for processDocu in ProcessDoc.query.all():
            processId = processDocu.processId
            processName = Process.query.filter_by(id=processId).first().processName
            button = buttons.createCustomButton(processName,"process_doc", processName)
            docButtons.append(button)
        docButtons.extend(buttons.CANCEL_DOC_BUTTON)
        messages = [message1, message2]

        return responseHelper.createResponseObject(messages,docButtons,"","","","")

    try:
        message1 = dialogflowResponse.query_result.fulfillment_text 
        message2 = ProcessDoc.query.filter_by(processId=processId).first().description # Prozessdoku für Prozess
        messages = [message1, message2]
        currentProcess = processId
        return responseHelper.createResponseObject(messages,[],currentProcess,processName,"","")
    except: # Für angegebenen Prozess gibt es keine Doku
        message1 = "Unfortunately there is no documentation for process \"" + processName + "\"."
        return responseHelper.createResponseObject([message1],[],"","","","")
예제 #3
0
def run(dialogflowResponse):
    message1 = "These are some commands you could type in, if you need support with your processes:"
    message2 = "Start process \"Order Pizza\""
    message3 = "What do I have to do at step \"Enter name\" in process \"Travel expenses claim\"?"
    message4 = "Which processes can you help me with?"
    messages = [message1,message2,message3,message4]
    return responseHelper.createResponseObject(messages,[],"","","","")
예제 #4
0
def run(dialogflowResponse):
    intentDisplayName = dialogflowResponse.query_result.intent.display_name
    # print(name)
    if intentDisplayName in intentDict:
        # print("intent exists")
        return intentDict.get(intentDisplayName).run(dialogflowResponse)
    else:
        # print("intent doesn't exists in intentDict")
        return responseHelper.createResponseObject([dialogflowResponse.query_result.fulfillment_text],[],"","","","")
예제 #5
0
def run(dialogflowResponse):

    message1 = "The buttons below represent the processes I can help you with. To start a process simply press the respective button."
 
    processButtons = []
    for process in Process.query.all():
        button = buttons.createCustomButton(process.processName,"process_names",process.processName)
        processButtons.append(button)
    processButtons.extend(buttons.CANCEL_NAMES_BUTTON)

    return responseHelper.createResponseObject([message1],processButtons,"","","","")
예제 #6
0
def run(dialogflowResponse):
    
    parameters_json = json.loads(MessageToJson(dialogflowResponse.query_result.parameters))
    processName = parameters_json['process_name_parameter']
    taskName = parameters_json['task_name_parameter']

    try:
        # gewünschten Prozess holen
        process = Process.query.filter_by(processName=processName).first()
        processId = process.id
        # gewünschten Task holen
        task = Node.query.filter_by(name=taskName).filter_by(type="task").filter_by(processId=processId).first()
        taskId = task.id
    except: # Entweder Task oder Process nicht erkannt bzw. angegeben
        message1 = dialogflowResponse.query_result.fulfillment_text
        return responseHelper.createResponseObject([message1],[],"","","","")
    
    message1 = dialogflowResponse.query_result.fulfillment_text
    message2 = GeneralInstruction.query.filter_by(nodeId=taskId).first().text # Generelle Anweisungen für gewünschten Schritt
    messages = [message1,message2]

    return responseHelper.createResponseObject(messages,buttons.STANDARD_STEP_BUTTONS,processId, processName,taskId,"")
예제 #7
0
def run(dialogflowResponse):
    parameters_json = json.loads(MessageToJson(dialogflowResponse.query_result.parameters))
    processName = parameters_json['process_name_parameter']

    try:
        # Aktuellen Prozess holen
        process = Process.query.filter_by(processName=processName).first()
        processId = process.id
    except: #Kein Prozess angegeben, bzw. Prozess nicht gefunden --> alle Prozesse als Button anzeigen
        message1 = dialogflowResponse.query_result.fulfillment_text
        message2 = "These are the processes I can help you with:"
        runButtons = []
        for process in Process.query.all():
            button = buttons.createCustomButton(process.processName,"process_run", process.processName)
            runButtons.append(button)
        runButtons.extend(buttons.CANCEL_RUN_BUTTON)
        messages = [message1, message2]
        return responseHelper.createResponseObject(messages,runButtons,"","","","")
    
    # falls Process zuvor abgebrochen wurde, frage ob an dieser Stelle fortfahren werden soll
    try:
        currentStepNode = Node.query.filter_by(currentStep = True).filter_by(processId = processId).first()
        message1 = "I have detected, that you have started this process before. Do you want to resume your last state?"
        return responseHelper.createResponseObject([message1],buttons.RESUME_RUN_BUTTONS,processId,processName,currentStepNode.id,"")
    
    except: # wenn nicht starte von vorne    
        # erste Aktivität im Prozess nehmen
        firstActivityId = Edge.query.filter(Edge.sourceId.like('StartEvent_%')).filter_by(processId=process.id).first().targetId
        previousStepId = Edge.query.filter(Edge.processId == process.id).filter(Edge.targetId == firstActivityId).first().sourceId
        firstActivity = Node.query.filter_by(id = firstActivityId).first()

        if(firstActivity.type == "exclusiveGateway"):
            try:
                splitQuestion = SplitQuestion.query.filter_by(nodeId=firstActivityId).first().text
            except:  # Falls es dafür keine Splitquestion gibt, dann handelt es sich um einen Join-Gateway --> Dann nächster Knoten ignorieren
                message = "You have reached a join gateway, press \"Yes\" to continue."
                messages = [message]
                return responseHelper.createResponseObject(messages, buttons.REDUCED_RUN_BUTTONS, processId, processName, firstActivityId, previousStepId)
                    
            # Splitquestion und Buttons ausgeben
            optionEdges = Edge.query.filter(Edge.sourceId == firstActivityId).filter_by(processId=processId)
            optionButtons = []
            for edge in optionEdges:
                eventId = edge.targetId
                buttonName = ButtonName.query.filter_by(nodeId=eventId).first().text
                optionButton = buttons.createCustomButton(buttonName,"process_run",eventId) # zB.: "process_run$customButton$IntermediateThrowEvent_1szmt2n"
                optionButtons.append(optionButton)
            optionButtons.extend(buttons.CANCEL_RUN_BUTTON) 
            return responseHelper.createResponseObject([splitQuestion], optionButtons, processId, processName, firstActivityId ,previousStepId)

        elif(firstActivity.type == "task"):
            message1 = dialogflowResponse.query_result.fulfillment_text # Okay, let's start process "Entity".
            message2 = GeneralInstruction.query.filter_by(nodeId=firstActivityId).first().text # Generelle Anweisungen für ersten Schritt
            message3 = "When you are done press \"Yes\", should you need further assistance press \"Help\"."
            messages = [message1, message2, message3]
            
            currentProcess = processId
            currentProcessName = processName
            currentProcessStep = firstActivityId
            previousProcessStep = previousStepId

            return responseHelper.createResponseObject(messages, buttons.STANDARD_RUN_BUTTONS,currentProcess, currentProcessName, currentProcessStep,previousProcessStep)

        else: #Intermediate Throw Event?
            pass #dürfte nicht vorkommen
예제 #8
0
def button_run(pressedButtonValue, currentProcess, currentProcessName, currentProcessStep, previousProcessStep):

    # Aktueller Prozesslauf abrechen
    if pressedButtonValue == "process_run_cancel":
        try:
            processName = Process.query.filter_by(id=currentProcess).first().processName
            message1 = "Okay, the current process instance of process \"" + processName + "\" will be canceled."
            message2 = "Your state will be saved for later."
            node = Node.query.filter_by(id=currentProcessStep).filter_by(processId=currentProcess).first()
            node.currentStep = True
            db.session.commit()
            messages = [message1,message2]
        except: # kein Prozessname
            message = "Alright, the request will be canceled."
            messages = [message]
        return responseHelper.createResponseObject(messages,[],"","","","")    
    
    # Gebe die DetailInstruction aus
    elif pressedButtonValue == "process_run_help":      
        try:
            message = DetailInstruction.query.filter_by(nodeId=currentProcessStep).first().text # Detail Anweisungen für aktuellen Schritt
        except:
            message = "Sorry, I can't provide you any further help for this task."
        return responseHelper.createResponseObject([message],buttons.REDUCED_RUN_BUTTONS,currentProcess, currentProcessName, currentProcessStep, previousProcessStep)

     # Starte den Prozess von Vorne
    elif pressedButtonValue == "process_run_no":
        # currentStep in der Datenbank zurücksetzen
        currentStepNode = Node.query.filter_by(id = currentProcessStep).first()
        currentStepNode.currentStep = False
        db.session.commit()
        # von vorne starten
        dialogflowResponse = dialogflowHelper.detect_intent_texts("run process " + currentProcessName)
        return run(dialogflowResponse)

     # Starte den Prozess an dem letzten State
    elif pressedButtonValue == "process_run_resume":
        # currentStep in der Datenbank zurücksetzen
        currentStepNode = Node.query.filter_by(id = currentProcessStep).first()
        currentStepNode.currentStep = False
        db.session.commit()

        # Prozess an dieser Stelle weitermachen:
        # Falls dieser Node ein Gateway ist, stelle die Splitquestion
        if (currentStepNode.type == "exclusiveGateway"):
            try:
                splitQuestion = SplitQuestion.query.filter_by(nodeId=currentProcessStep).first().text
            except:  # Falls es dafür keine Splitquestion gibt, dann handelt es sich um einen Join-Gateway --> Dann nächster Knoten ignorieren
                message = "You have reached a join gateway, press \"Yes\" to continue."
                messages = [message]
                return responseHelper.createResponseObject(messages, buttons.REDUCED_RUN_BUTTONS, currentProcess, currentProcessName, currentProcessStep ,"")
                
            # Splitquestion und Buttons ausgeben
            optionEdges = Edge.query.filter(Edge.sourceId == currentProcessStep).filter_by(processId=currentProcess)
            optionButtons = []
            for edge in optionEdges:
                eventId = edge.targetId
                buttonName = ButtonName.query.filter_by(nodeId=eventId).first().text
                optionButton = buttons.createCustomButton(buttonName,"process_run",eventId) # zB.: "process_run$customButton$IntermediateThrowEvent_1szmt2n"
                optionButtons.append(optionButton)
            optionButtons.extend(buttons.CANCEL_RUN_BUTTON) 
            return responseHelper.createResponseObject([splitQuestion], optionButtons, currentProcess, currentProcessName, currentProcessStep ,"")

        # Wenn ein Fehler fliegt, dann gibt es keine Anweisung mehr für die Activity --> Ende erreicht
        try:
            message = GeneralInstruction.query.filter_by(nodeId=currentProcessStep).first().text # Generelle Anweisungen für den nächsten Schritt
        except:
            message = "You have successfully gone through the process \"" + currentProcessName + "\"."
            return responseHelper.createResponseObject([message], [], "", "", "", "")

        return responseHelper.createResponseObject([message], buttons.STANDARD_RUN_BUTTONS, currentProcess, currentProcessName, currentProcessStep, "")

    else: # Nächster Schritt --> "process_run_yes"
        nextNodeId = Edge.query.filter(Edge.sourceId == currentProcessStep).filter_by(processId=currentProcess).first().targetId
        nextNode = Node.query.filter_by(id=nextNodeId).first()
        
        # Falls dieser Node ein Gateway ist, stelle die Splitquestion
        if (nextNode.type == "exclusiveGateway"):
            try:
                splitQuestion = SplitQuestion.query.filter_by(nodeId=nextNodeId).first().text
            except:  # Falls es dafür keine Splitquestion gibt, dann handelt es sich um einen Join-Gateway --> Dann nächster Knoten ignorieren
                message1 = "You have reached a join gateway, press \"Yes\" to continue."
                return responseHelper.createResponseObject([message1], buttons.REDUCED_RUN_BUTTONS, currentProcess, currentProcessName, nextNodeId ,currentProcessStep)
                
            # Splitquestion und Buttons ausgeben
            optionEdges = Edge.query.filter(Edge.sourceId == nextNodeId).filter_by(processId=currentProcess)
            optionButtons = []
            for edge in optionEdges:
                eventId = edge.targetId
                buttonName = ButtonName.query.filter_by(nodeId=eventId).first().text
                optionButton = buttons.createCustomButton(buttonName,"process_run",eventId) # zB.: "process_run$customButton$IntermediateThrowEvent_1szmt2n"
                optionButtons.append(optionButton)
            optionButtons.extend(buttons.CANCEL_RUN_BUTTON) 
            return responseHelper.createResponseObject([splitQuestion], optionButtons, currentProcess, currentProcessName, nextNodeId ,currentProcessStep)

        # Wenn ein Fehler fliegt, dann gibt es keine Anweisung mehr für die Activity --> Ende erreicht
        try:
            message = GeneralInstruction.query.filter_by(nodeId=nextNodeId).first().text # Generelle Anweisungen für den nächsten Schritt
        except:
            print("End of process reached")
            processName = Process.query.filter_by(id=currentProcess).first().processName
            message = "You have successfully gone through the process \"" + processName + "\"."
            return responseHelper.createResponseObject([message], [], "", "", "", "")

        return responseHelper.createResponseObject([message], buttons.STANDARD_RUN_BUTTONS, currentProcess, currentProcessName, nextNodeId, currentProcessStep)
예제 #9
0
def button_run(pressedButtonValue, currentProcess, currentProcessName, currentProcessStep, previousProcessStep):
    if pressedButtonValue == "process_doc_cancel":
        message = "Alright, the request will be canceled."
        return responseHelper.createResponseObject([message],[],"","","","")   
예제 #10
0
def button_run(pressedButtonValue, currentProcess, currentProcessName, currentProcessStep, previousProcessStep):

    if (pressedButtonValue == "process_step_previous"):
        previousStepId = Edge.query.filter(Edge.processId == currentProcess).filter(Edge.targetId == currentProcessStep).first().sourceId
        previousStep = Node.query.filter(Node.id == previousStepId).first()

        if previousStep.type == "startEvent":
            message1 = "There is no previous step. You have reached the start of the process."
            messages = [message1]
            return responseHelper.createResponseObject(messages,buttons.NEXT_STEP_BUTTONS,currentProcess,currentProcessName,currentProcessStep,"")

        elif (previousStep.type == "task"):
            try: #Beschreibung holen
                message1 = "Alright, the previous step is: \"" + previousStep.name +"\". This is the documentation:"
                message2 = GeneralInstruction.query.filter_by(nodeId=previousStep.id).first().text # Generelle Anweisungen für vorherigen Schritt
                messages = [message1,message2]
                return responseHelper.createResponseObject(messages,buttons.STANDARD_STEP_BUTTONS,currentProcess,currentProcessName,previousStepId,"")
            except:
                message1 = "There is no documentation for this step."
                messages = [message1]
                return responseHelper.createResponseObject(messages,buttons.STANDARD_STEP_BUTTONS,currentProcess,currentProcessName,previousStepId,"")
        
        elif (previousStep.type == "exclusiveGateway"):
                message1 = "There is no documentation for this step, as this is a gateway."
                messages = [message1]
                return responseHelper.createResponseObject(messages,buttons.STANDARD_STEP_BUTTONS,currentProcess,currentProcessName,previousStepId,"")
        
        elif (previousStep.type == "intermediateThrowEvent"):
                message1 =  DetailDescription.query.filter_by(nodeId=previousStep.id).first().text
                messages = [message1]
                return responseHelper.createResponseObject(messages,buttons.STANDARD_STEP_BUTTONS,currentProcess,currentProcessName,previousStepId,"")
    
    elif (pressedButtonValue == "process_step_next"):
        nextStepId = Edge.query.filter(Edge.processId == currentProcess).filter(Edge.sourceId == currentProcessStep).first().targetId
        nextStep = Node.query.filter(Node.id == nextStepId).first()

        if nextStep.type == "endEvent":
            message1 = "There is no next step. You have reached the end of the process."
            messages = [message1]
            return responseHelper.createResponseObject(messages,buttons.PREVIOUS_STEP_BUTTONS,currentProcess,currentProcessName,currentProcessStep,"")

        elif (nextStep.type == "task"):
            try: #Beschreibung holen
                message1 = "Alright, the next step is: \"" + nextStep.name +"\". This is the documentation:"
                message2 = GeneralInstruction.query.filter_by(nodeId=nextStep.id).first().text # Generelle Anweisungen für vorherigen Schritt
                messages = [message1,message2]
                return responseHelper.createResponseObject(messages,buttons.STANDARD_STEP_BUTTONS,currentProcess,currentProcessName,nextStepId,"")
            except:
                message1 = "There is no documentation for this step."
                messages = [message1]
                return responseHelper.createResponseObject(messages,buttons.STANDARD_STEP_BUTTONS,currentProcess,currentProcessName,nextStepId,"")
        
        elif (nextStep.type == "exclusiveGateway"):
                # Was machen hier? Welchen Pfal auswählen und gehen?
                message1 = "There is no documentation for this step, as this is a gateway."
                messages = [message1]
                return responseHelper.createResponseObject(messages,buttons.STANDARD_STEP_BUTTONS,currentProcess,currentProcessName,nextStepId,"")
        
        elif (nextStep.type == "intermediateThrowEvent"):
                message1 =  DetailDescription.query.filter_by(nodeId=nextStep.id).first().text
                messages = [message1]
                return responseHelper.createResponseObject(messages,buttons.STANDARD_STEP_BUTTONS,currentProcess,currentProcessName,nextStepId,"")
    
    else: #"process_step_cancel"
        print ("end")
        message = "Alright, the request will be canceled."
        return responseHelper.createResponseObject([message],[],"","","","")