Versions Compared

Key

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

...

Code Block
languageyaml
pipeline:

  # Read email from inbox
  - imap.get:
      host: outlook.office365.com
      secret: my-office365-secret

  # Detect the intent in the email
  - ai.intent.detect:
      advice:
        intentCandidates:
          - intentId: "invoice"
            instruction: "Use this intent in case the attachment is an invoice."
            params:
              supplierAddress:
                instruction: "Extract the supplier address from the invoice."
              invoiceNumber:
                instruction: "Extract the invoice number from the invoice."
              totalAmount:
                instruction: "Extract the total amount of the invoice in cents without any currency chars, separators or other special characters."
          - intentId: "temination"
            instruction: "Use this intent in case the attachment is a termination of a contract."
            params:
                contractNumber:
                  instruction: "Extract the contract number."
                customerNumber:
                  instruction: "Extract the customer number."
                reason:
                  instruction: "Summarize in one sentence the reason for the termination."
          - intentId: "documentation"
            instruction: "Use this intent in case the attachment is a documentation."
            params:
                summary:
                  instruction: "Create a short summary what this documentation is about."

Result:

Code Block
languagejson
{
    "params": {
        "supplierAddress": {
            "name": "supplierAddress",
            "value": "ABC Software (Germany) GmbH - Im Weg 3 - 12345 Worth",
            "required": false,
            "pass": true,
            "type": "string"
        },
        "invoiceNumber": {
            "name": "invoiceNumber",
            "value": "123100401",
            "required": false,
            "pass": true,
            "type": "string"
        },
        "totalAmount": {
            "name": "totalAmount",
            "value": "45353",
            "required": false,
            "pass": true,
            "type": "string"
        }
    },
    "enabled": true,
    "intentId": "invoice",
    "command": null
}

...

Code Block
languageyaml
vars:
    containerProp: "global/app/io.pipeforce.test/data/container-${@text.random(10)}"

pipeline:

  # Read the email from inbox
  - imap.get:
      host: outlook.office365.com
      secret: office365-testlab-secret2
      subjectContains: test123

  # Create the container property for the attachment
  - property.schema.put:
      path: ${vars.containerProp}
      input: ""
      output: false

  # Save the attachment to the container property
  - property.attachment.put:
      path: ${vars.containerProp}
      content: ${body[0].attachments[0]}
      output: ${vars.attachment}

  # Detect the command
  - ai.intent.detect:
      runDetectedCommand: true
      advice:
        intentCandidates:
        
          - intentId: "startInvoiceWorkflow"
            command: workflow.start
            instruction: "Sender has submitted a payable invoice."
            params:
                invoiceNumber:
                    instruction: "Extract the invoice number."
                    pass: false
                key: 
                    value: io.pipeforce.test_invoice-wf
                variables:
                    value:
                        "totalAmount": "{{intent.params.invoiceNumber}}"
                        "invoice": ${vars.attachment}
                        
          - intentId: "startTerminationWorkflow"
            command: workflow.start
            instruction: "Sender has submitted a contract termination."
            params:
                contractNumber:
                    instruction: "Extract the contract number."
                    pass: false
                key: 
                    value: io.pipeforce.test_termination-wf
                variables:
                    value:
                        "contractNumber": "{{intent.params.contractNumber}}"
                        "terminationLetter": ${vars.attachment}

...