Rob Boville
Published

Vizi-AI Twilio integration

When using Vizi-AI to inference from either a video or webcam I wanted to drive something in the real world. Enter Twilio integration.

BeginnerFull instructions provided2 hours3,736
Vizi-AI Twilio integration

Things used in this project

Story

Read more

Schematics

Architecture of SMS solution

Diagram to represent the flow of image capture and inferencing to generate a SMS

Code

my Node-Red flow file

JavaScript
this is the flows file I used to create
[
    {
        "id": "94ecffb6.108d7",
        "type": "tab",
        "label": "Flow 1",
        "disabled": false,
        "info": ""
    },
    {
        "id": "c4da6ae0.fcd0d8",
        "type": "data-river-subscribe",
        "z": "94ecffb6.108d7",
        "name": "DetectionBox_Reader",
        "contextid": "test",
        "context": "com.adlinktech.device",
        "version": "v1.0",
        "description": "why",
        "scanrate": "10000",
        "inputname": "stuffiwannaread",
        "server": "6bdc86d4.2a2c38",
        "x": 160,
        "y": 300,
        "wires": [
            [
                "2125ecc6.eaf1b4"
            ]
        ]
    },
    {
        "id": "86f9acc5.64643",
        "type": "switch",
        "z": "94ecffb6.108d7",
        "name": "Contents switch",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "cont",
                "v": "person",
                "vt": "str"
            },
            {
                "t": "cont",
                "v": "car",
                "vt": "str"
            },
            {
                "t": "cont",
                "v": "fire hydrant",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 3,
        "x": 640,
        "y": 300,
        "wires": [
            [
                "9ea63273.559cf"
            ],
            [
                "c97b3a8.c3174c8"
            ],
            [
                "5ca867bd.4f9518"
            ]
        ]
    },
    {
        "id": "2125ecc6.eaf1b4",
        "type": "function",
        "z": "94ecffb6.108d7",
        "name": "Extract Inferenced Objects",
        "func": "// Get only the detection boxes from the message\nlet detectionBoxes = msg.payload.data;\n\n// Get an array of object labels from the detection boxes\nlet detectedObjects = []\ndetectionBoxes.forEach(detectionBox =>\n    detectedObjects.push(detectionBox.obj_label)\n);\n\n// Update msg.payload\nmsg.payload = detectedObjects;\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "x": 400,
        "y": 300,
        "wires": [
            [
                "86f9acc5.64643",
                "72b1a341.6d9a6c"
            ]
        ]
    },
    {
        "id": "9ea63273.559cf",
        "type": "function",
        "z": "94ecffb6.108d7",
        "name": "Report a person",
        "func": "msg.payload = \"Vizi-AI again another delivery driver is here!\"\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "x": 840,
        "y": 260,
        "wires": [
            [
                "41d639fd.699b18",
                "476b9382.01924c"
            ]
        ]
    },
    {
        "id": "41d639fd.699b18",
        "type": "debug",
        "z": "94ecffb6.108d7",
        "name": "",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 1190,
        "y": 300,
        "wires": []
    },
    {
        "id": "c97b3a8.c3174c8",
        "type": "function",
        "z": "94ecffb6.108d7",
        "name": "Report a car",
        "func": "msg.payload = \"Hi my name is Vizi-AI and I just spotted a car!\"\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "x": 830,
        "y": 340,
        "wires": [
            [
                "41d639fd.699b18"
            ]
        ]
    },
    {
        "id": "5ca867bd.4f9518",
        "type": "function",
        "z": "94ecffb6.108d7",
        "name": "fire hydrant",
        "func": "msg.payload = \"Hi my name is Vizi-AI and I just spotted a fire hydrant!\"\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "x": 840,
        "y": 440,
        "wires": [
            [
                "41d639fd.699b18"
            ]
        ]
    },
    {
        "id": "72b1a341.6d9a6c",
        "type": "debug",
        "z": "94ecffb6.108d7",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 530,
        "y": 180,
        "wires": []
    },
    {
        "id": "476b9382.01924c",
        "type": "twilio out",
        "z": "94ecffb6.108d7",
        "twilio": "edb3d81c.c10e78",
        "twilioType": "sms",
        "url": "",
        "number": "",
        "name": "Delivery driver rage",
        "x": 1120,
        "y": 160,
        "wires": []
    },
    {
        "id": "6bdc86d4.2a2c38",
        "type": "tagGroup-server-subscribe",
        "z": "",
        "name": "DetectionBox",
        "context": "com.vision.data",
        "version": "*"
    },
    {
        "id": "edb3d81c.c10e78",
        "type": "twilio-api",
        "z": "",
        "name": "My first Twilio project",
        "sid": "",
        "from": ""
    }
]

Credits

Rob Boville

Rob Boville

1 project • 5 followers
Thanks to ADLINK UK Engineering Team.

Comments