Versions Compared

Key

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

Table of Contents
stylenone

What is the AI Studio?

Status
colourBlue
titleSince 11 - BETA

...

Info

BETA

Note that the AI Studio components including all ai.* commands are in BETA. This means definitions, interfaces and documentation is not final and could change without further notice.

Table of Contents
stylenone

Configure AI Backend (secret)

Before you can start, an AI backend needs to be configured. Depending on your license, by default PIPEFORCE comes with it’s own built-in AI backend. The secret name of this is ai-default-secret.

...

  • base_url: The base url of the API (requried).

  • model: The AI model to be used (required).

  • api_token: The security token to be used.

  • max_token: The max token to be send (defaults to 800)

  • custom_headers: Key-value pairs to be passed along as HTTP headers on any request. This is handy for example in case basic authentication or any other additional header setting is required.

Connect to OpenAI (ChatGPT)

In case you would like to connect to the OpenAI services for example, you could use these settings in your secret:

Code Block
languagejson
{
  "base_url": "https://api.openai.com/v1",
  "model": "gpt-3.5-turbo",
  "api_token": "your_token",
  "max_token": 800
} 

Prompting - Send a question or advice to AI

One of most generic and simplest use cases is to send a prompt (= question / advice) to the AI and use the response data in your pipeline. For this you can use the ai.prompt.send command. Here is an example to return some data from the AI:

...

Code Block
languagejson
[
    "Tokyo",
    "Delhi",
    "Shanghai",
    "Sao Paulo",
    "Mumbai",
    "Beijing",
    "Mexico City",
    "Osaka",
    "Cairo",
    "Dhaka"
]

Adding context data (input) to the prompt

You can also apply the prompt with context data. This context data can be set as input to the command:

...

Code Block
languagejson
{
    "person": {
        "firstName": "p_Alex",
        "lastName": "p_Johnson",
        "age": 48
    }
}

Avanced prompting: Send multiple messages

In case you need to send multiple messages in one prompt, you can use the parameter messages like this:

...

The parameter content can be a plain text or any AI convertable object (like a PDF file for example). The conversion and preparation to an AI compatible format is done by PIPEFORCE automatically.

Intent Detection - Detect what the user wants

Another feature of the AI studio is the ability to detect the intent of the user or to classify a given information and extract additional information based on the detected intent.

...

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

  • prompt
    Each intent has an 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.

Intent Parameters

The params section on each intent lists the parameters of the intent. These parameters will be automatically set in case the given intent was detected. They can later be used for further processing by calling a command of by passing them to external systems for example.

...

All parameter attributes are explained below.

name (optional)

The name of the parameter.

This attribute is optional. If not set, the params id will be used.

required (optional)

Defines whether this parameter is required. In case it is required and its value is finally missing or cannot be detected by AI, an error is thrown and further execution stops.

The default value is false.

type (optional)

The data type of the parameter such as string, boolean, integer, number, json

...

The default value is string.

value (optional)

The value of the intent parameter.

This can be a fixed value (literal) or a template.

Templated values

The value can also be template string. By default the Mustache template syntax can be used which starts with {{ and ends with }}. The variables advice and intent are passed as model context to the template. This way you can access for example settings and values of other parameters after they have been resolved by the AI in order to formulate the final parameter for a command.

...

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

prompt (optional)

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

...

As you can see in this example, there is no fixed value for parameter subject set. Instead the AI was instructured to extract the value from the given email input.

Text-to-Command - Let the AI auto-start a business process

This is the next level of automation where the AI can start a command and with this, start a business process fully automated. For this, the AI takes a non-structured text such as an email, a chat message or a PDF document for example, analyses it and then automatically detects and executes the according PIPEFORCE command in order to take action and fulfill the user’s request.

...

  • Automatically forward emails with a summary to internal team
    Scan any email sent to a given inbox such as info@mycompany.tld for example, find out the intention of the sender, then forward the email to the internal team such as support, sales, … which can handle the request. The AI can find out the type of request, whether it is a support request, an order request, a question regarding an invoice or any other type just by writing an advice to the AI and without any programming. It can also detect and extract all required data such as customerId, invoiceNumber and more from the sender’s email. Furthermore, it can also create a short summary about what the core intent of the sender is to make it easier for the internal team to process the request.

  • Automatically start an internal workflow by email
    Scan any email sent to a given inbox such as invoice@mycompany.tld for example and if this email matches to an existing workflow, extract all variables required for this workflow from the email, start the workflow and pass these variables along with it. For example to start an accounts payable workflow based on an given payable invoice. The AI can validate whether all required data exist and is valid in order to start the workflow.

  • Automatically call endpoints of other systems by email
    Scan any email sent to a given inbox such as info@mycompany.tld for example and if this email is related to a service, offered by a third party system which provides an remote API, call this remote API (for example REST) and pass along parameters extracted from the email. For example create a new ticket on an external ticket system.

Using the command ai.intent.detect

In order to integrate Text-to-Command functionality into your automation pipelines, you can use the command ai.intent.detect. It will

...

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.

UC1 - 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
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.

UC2 - 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
languageyaml
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:

Code Block
invoice

UC3 - 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
languageyaml
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:

Code Block
happy

UC4 - Transformative Prompt: Extract information from an PDF as JSON

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 in a valid JSON format.

...

Code Block
languagejson
{
    "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
        }
    ]
}

UC5 - 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
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
}

UC6 - 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.

...