...
The parameter runDetectedCommand
defines whether the command should directly be executed (true
) or the intent JSON should be simply returned for further processing (false
).
Use Case Examples
Below you can find a list of most often requested use cases for AI in PIPEFORCE and the pipeline recipe to solve it.
Reductive Prompt: Create a summary from an email attachment
Use Case: Given is an email with attachment as input. Create a summary from this email loaded from an IMAP inbox.
Code Block |
---|
|
pipeline:
- imap.get:
host: outlook.office365.com
secret: my-office365-secret
- ai.prompt.send:
prompt: |
Create a short summary of the attachment in the given email. |
Result:
Code Block |
---|
The attachment is an invoice from ABC Software (Germany) GmbH to Musterkunde AG,
detailing various services provided and their associated costs for the period from
01.02.2024 to 29.02.2024. The invoice includes information on user accounts,
transaction fees, VAT, and payment instructions. |
Classifying Prompt: Classify the type of an email attachment
Use Case: Given is an email with attachment as input. Classify the attachment of this email based on a given set of classes.
Code Block |
---|
|
pipeline:
- imap.get:
host: outlook.office365.com
secret: my-office365-secret
- ai.prompt.send:
prompt: |
Given are these categories: invoice, quote, termination.
In which of these fits the given attachment?
Return only the name from the list. |
Result:
Classifying Prompt: Classify the the mood of the sender of an email
Use Case: Given is an email as input. Based on a list of moods, classify the mood of the email’s sender.
Code Block |
---|
|
pipeline:
- imap.get:
host: outlook.office365.com
secret: my-office365-secret
- ai.prompt.send:
prompt: |
In which mood fits the given email?
Return only the one from this list which matches best:
happy, neutral, disappointed, angry, cannot detect |
Result:
Use Case: Given is an invoice as attachment PDF to an email. The goal is to extract all required information from this PDF and provide it transformed to JSON.
Code Block |
---|
|
pipeline:
- imap.get:
host: outlook.office365.com
secret: my-office365-secret
- ai.prompt.send:
secret: openai-default-secret
prompt: |
Extract the invoice in the attachment to a JSON using this structure:
{
"invoiceNumber": "value",
"address": "value",
"invoiceDate": "value",
"positions": [
{
"description": "value",
"pieces": "value",
"price": value
}
]
} |
Result:
Code Block |
---|
|
{
"invoiceNumber": "123100401",
"address": "ABC Provider (Germany) GmbH - Weg 3 - 12345 Stadt",
"invoiceDate": "01.02.2025 - 29.02.2025",
"positions": [
{
"description": "Invoice WMACCESS Internet, 1 Month",
"pieces": 1,
"price": 130.00
},
{
"description": "Router Type 3 rental",
"pieces": 1,
"price": 5.00
}
]
} |
Detect the intent and its parameters from an user email
Use Case: Given is an email with an attachment. Based on a given set of intents, the AI should detect the one which matches and additionally extract all required information from it.
Code Block |
---|
|
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 |
---|
|
{
"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
} |
Detect and start a command / workflow based on a user email
Use Case: Given is an email with attachments. The AI must detect the intent of this email and finally a command linked to this intent must be executed and all required parameters must be extracted from the input email and transformed and passed along to the command. Also the attachment file must be passed along.
Code Block |
---|
|
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}
|
Result:
For an invoice given in attachments of the email, this will select a the startInvoiceWorkflow
intent with final workflow parameters as as listed below:
Code Block |
---|
|
{
"params": {
"invoiceNumber": {
"name": "invoiceNumber",
"value": "45353",
"required": false,
"pass": false,
"type": "string"
},
"key": {
"name": "key",
"value": "io.pipeforce.invoicetest_invoice-wf",
"required": false,
"pass": true,
"type": "string"
},
"variables": {
"name": "variables",
"value": {
"firstName": "Max",
"lastName": "Mustermann",
"invoiceNumber": "45353",
"invoice": "${vars.attachment}"
},
"required": false,
"pass": true,
"type": "string"
}
},
"enabled": true,
"intentId": "startInvoiceWorkflow",
"command": "workflow.start"
} |
This JSON will then cause the command ai.intent.detect
to auto-execute the command workflow.start and pass along all parameters marked "pass": true
.