t6 Blog Posts > Using OpenAI and t6 IoT AI-Flex Feature to Customize Sensor Outputs

Using OpenAI and t6 IoT AI-Flex Feature to Customize Sensor Outputs

In the ever-evolving world of IoT, automation is no longer limited to collecting and responding to data. With the introduction of AI-Flex in the t6 IoT platform, users can now harness the power of OpenAI to dynamically customize and enhance sensor outputs. This feature takes IoT automation to the next level by integrating sophisticated language processing capabilities directly into Rule Engine workflows. In this recipe, we'll explore how to use AI-Flex to transform raw sensor data into actionable insights and tailor outputs to specific needs.

Tagged on #AI-Flex, #Artificial Intelligence, #AI, #NLP, #NLU, #rules, #recipe,

Using OpenAI and t6 IoT AI-Flex Feature to Customize Sensor Outputs

What is AI-Flex?

AI-Flex is a powerful feature in t6 IoT that integrates OpenAI’s language models directly into the Rule Engine. By using a simple text prompt, AI-Flex enables users to generate contextually enhanced outputs, replacing raw inputs with AI-generated responses. These enhanced outputs can be used to trigger intelligent automation workflows.


Example Use Case: Standardizing Text Input

The Scenario

Let’s say you have a system that occasionally receives poorly structured text statements. For example:

Using AI-Flex, the Rule Engine can automatically convert the raw input into a refined and grammatically correct statement, ready for use in IoT workflows.

Setting Up AI-Flex in t6 IoT

Sample CURL Request

Below is a sample CURL request that demonstrates how to configure AI-Flex to achieve the described functionality:

curl --location --request POST "https://api.internetcollaboratif.info/v2.0.1/data/openAI_fakeFlow" \
--header "Content-Type: application/json" \
--header "Accept: application/json" \
--header "Authorization: Bearer ey[***REDACTED***]" \
--data "[
    {
        \"value\": \"She no went to the market.\",
        \"flow_id\": \"openAI_fakeFlow\",
        \"text\": \"\",
        \"meta\": {
            \"foo\": \"bar\"
        },
        \"save\": false,
        \"unit\": \"\",
        \"mqtt_topic\": \"\",
        \"publish\": true,
        \"object_id\": \"f877-40ca-89e7-[***REDACTED***]\",
        \"datatype_id\": \"a394e18f-12bd-4c22-b9c3-74c387d1a8db\",
        \"rules\": [
            {
                \"conditions\": {
                    \"all\": [
                        {
                            \"fact\": \"flow\",
                            \"operator\": \"equal\",
                            \"value\": \"openAI_fakeFlow\"
                        }
                    ]
                },
                \"event\": {
                    \"type\": \"openAiChatCompletion\",
                    \"params\": {
                        \"model\": \"gpt-3.5-turbo\",
                        \"prompt\": \"You will be provided with statements, and your task is to convert them to standard English.\",
                        \"substituteValueWithResponse\": true,
                        \"temperature\": 0.7,
                        \"max_tokens\": 64,
                        \"top_p\": 1,
                        \"apiKey\": \"sk-proj-xEN[***REDACTED***]qNVjsA\"
                    }
                },
                \"priority\": \"1\"
            }
        ]
    }
]"

Workflow Explanation

  1. User Input: The statement She no went to the market. is submitted to the t6 IoT platform as raw input.
  2. AI-Flex Processing: The input is sent to OpenAI using the defined prompt
  3. OpenAI processes this input and returns the response: She did not go to the market.
  4. Value Substitution: The original input is replaced with the AI-generated response, which can then be published or used for further processing in the Rule Engine.
  5. Further Actions: The refined output can trigger additional actions, such as notifications, data logging, or publishing to MQTT topics.

AI-Flex revolutionizes how IoT systems process and refine data by combining automation with advanced language understanding. Whether it’s standardizing text inputs or adding context to raw sensor data, AI-Flex empowers t6 IoT users to create smarter, more efficient workflows.

Start using AI-Flex today and see how it can transform your IoT automation capabilities.

For questions or to share your use case, feel free to reach out to our support team.

Tagged on #AI-Flex, #Artificial Intelligence, #AI, #NLP, #NLU, #rules, #recipe,