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"
            instructionprompt: "Use this intent in case the attachment is an invoice."
            params:
              supplierAddress:
                instructionprompt: Extract the supplier address from the invoice.
              invoiceNumber:
                instructionprompt: Extract the invoice number from the invoice.
              totalAmount:
                instructionprompt: Extract the total amount of the invoice in cents without any currency chars, separators or other special characters.
          - intentId: "temination"
            instructionprompt: "Use this intent in case the attachment is a termination of a contract."
            params:
                contractNumber:
                  instructionprompt: Extract the contract number.
                customerNumber:
                  instructionprompt: Extract the customer number.
                reason:
                  instructionprompt: Summarize in one sentence the reason for the termination.
          - intentId: "documentation"
            instructionprompt: "Use this intent in case the attachment is a documentation."
            params:
                summary:
                  instructionprompt: Create a short summary what this documentation is about.

...

  • intentId
    This attribute is mandatory and gives the intent a unique id. This should be an explainatory, unique name without special charaters or whitespaces.

  • instructionprompt
    Each intent has an instruction prompt in order to instruct the AI about the criteria to select this intent. In case such an intent is selected by AI, additionally the parameters will be extracted from the input. This parameter is mandatory.

  • params
    The list of optional parameters to be detected in case this intent was selected.

  • command
    The optional name of the command to be executed in case this intent was detected. Note: Additionally rundDetectecCommand must be set to true on the ai.intent.detect command which is false by default.

  • enabled
    An intent can optionally be disabled by setting enabled = false. This is useful mainly for testing purposes for example. In this case only the other intents will be considered by the AI.

...

Each parameter can have a fixed/templated value or its value can be detected by AI using the instruction prompt attribute.

All parameter attributes are explained below.

...

Code Block
languageyaml
...
params:
  customerId:
    value: "1234567"
  message:
    value: "The customerId is: {{intent.params.customerId}}"
  ...

...

prompt (optional)

For each parameter, an attribute instruction prompt instead of a value can be set. Not both!

In this case the AI will auto-detect the value of the parameter by reading and applying this instruction prompt on the input and setting the result on the value field automatically.

...

Code Block
languageyaml
...
params:
  subject:
    instructionprompt: "Use the subject from initial sender email"
  ...

...

  1. take a text, for example like an email as input,

  2. will apply the given AI instructions prompts on this text and

  3. finally will select a command to be executed and passes the detected parameters to this command.

...

Code Block
languageyaml
body: |
  From: customer@somedomain.tld
  Subject: I have a problem with your product
  Hello,
  I have a big problem with your product and need support.
  My customer id is 123456.
  Cheers, Valued Customer
  
pipeline:
  - ai.command.detect:
      runDetectedCommand: true
      advice:
        intentCandidates:
          - intentId: "forwardToSupport"
            instructionprompt: "Use this intent in case the sender needs product support."
            command: "mail.send"
            params:
              to:
                value: "support@internal.tld"
              from:
                instructionprompt: "The email address of the sender."
              subject:
                instructionprompt: "Use the subject of the sender's email."
              message:
                instructionprompt: "Use the message of the sender's email."
          - intentId: "forwardToInfo"
            instructionprompt: >
              Use this intent in case the sender's intent could not be detected.
            command: "mail.send"
            params:
              to:
                value: "info@internal.tld"
              from:
                instructionprompt: "The email address of the sender."
              subject:
                instructionprompt: "Use the subject of the sender's email."
              message:
                instructionprompt: "Use the message of the sender's email."

...

  • One intent will forward the customer email to the support team (=forwardToSupport) and

  • the other one to the info team in case it is related to any other topic (= forwardToInfo).

Each intent has an instruction prompt in order to instruct the AI about the criteria to select this intent. In case such an intent is selected by AI, there is the targetCommand field defining the name of the command which must be called. In this example this is the mail.send command.

...

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"
            instructionprompt: "Use this intent in case the attachment is an invoice."
            params:
              supplierAddress:
                instructionprompt: "Extract the supplier address from the invoice."
              invoiceNumber:
                instructionprompt: "Extract the invoice number from the invoice."
              totalAmount:
                instructionprompt: "Extract the total amount of the invoice in cents without any currency chars, separators or other special characters."
          - intentId: "termination"
            instructionprompt: "Use this intent in case the attachment is a termination of a contract."
            params:
                contractNumber:
                  instructionprompt: "Extract the contract number."
                customerNumber:
                  instructionprompt: "Extract the customer number."
                reason:
                  instructionprompt: "Summarize in one sentence the reason for the termination."
          - intentId: "documentation"
            instructionprompt: "Use this intent in case the attachment is a documentation."
            params:
                summary:
                  instructionprompt: "Create a short summary what this documentation is about."

...

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
            instructionprompt: "Sender has submitted a payable invoice."
            params:
                invoiceNumber:
                    instructionprompt: "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
            instructionprompt: "Sender has submitted a contract termination."
            params:
                contractNumber:
                    instructionprompt: "Extract the contract number."
                    pass: false
                key: 
                    value: io.pipeforce.test_termination-wf
                variables:
                    value:
                        "contractNumber": "{{intent.params.contractNumber}}"
                        "terminationLetter": ${vars.attachment}

...