# Creating and Viewing Insights

### **Create Insights**

Insights can be created using postMessage communication. Once the embedding app is connected with Tellius following the steps in [this section](https://help.tellius.com/6.0/embedding-tellius/embedding-url/embedding-insights), the below URL can be used to create an Insight:

{% hint style="info" %}
<http://domain/discover/create?businessviewID>
{% endhint %}

Here, the **businessviewID** indicates the Business View using which the Insight needs to be created.

The state of an Insight can be one of the following. A notification will be sent when the state gets changed.

1. Running - when the Insight is being created. actionType:`INSIGHT_INITIATED`
2. Completed - when the Insight has been created. actionType: `INSIGHT_COMPLETED`
3. Failed - when the Insight creation has failed. actionType: `INSIGHT_FAILED`

The following is the response postMessage sent from Tellius:

```json
{
    "actionType": "INSIGHT_COMPLETED",
    "timetaken": "18s",
    "result": {
        "insightId": "insight_4c0133ab-ed88-4512-8874-b9dbf3dae544",
        "driverId": "driver_e83557ed-14ca-4aeb-9b71-1412953d43b3",
        "type": "DriverCreateResponse"
},
"fromGraph": false,
"request": {
    "driverName": "gc1",
    "label": "Ship_Mode",
    "options": {
            "featureselection_featurenames": "Row_ID,Order_ID",
            "featureselection_includefeaturenames": "true",
            "targetLabel": "First Class",
            "treeDepth": "large,small",
            "sample": "0.1",
            "createStage": "false"
    },
    "sourceid": "bv_66513cf3-8a58-4be0-8d06-f8cf26d4725f",
    "createdBy": "18d60756-712e-4867-a301-430ba7f58880",
    "labelType": "categorical"
},
"consumed": false,
"jobType": "SegmentDiscoveryInsight",
"status": "SUCCESS",
"jobId": "ae661436-7863-4fb1-a63a-9fb8a90157ee",
"starttime": "2021-03-11T17:36:05.068Z",
"createdBy": "superUser",
"estimatedResourceSizeBytes": 2663691,
"name": "Segment Discovery Insight"}
```

The code consists of both request and response information. The result section has components such as **insightID** and **driverID**. These two can be utilised to form the URL <https://domain/discover/insight/insightID/driverID> -- which can be used to get redirected to the required Insight.

Tellius also sends the following details as a response:

1. **starttime**: The time in which the Insight creation was started
2. **createdBy**: The user who created the Insight
3. **driverName:** name of Insights
4. **jobType**: the type of Insight created. It could be one of the following:

* SegmentDiscoveryInsight
* Trend
* Cohort

5. **consumed:** flag indicating whether the Insight has been viewed. If set to `true`, then the Insight has been opened/viewed.

### **View Insights**&#x20;

***Request URL:*** `https://dev.app.tellius.com/discover/insight/insightID/driverID?access=edit`

The component **access** can be set to `read` or `edit` as required.

### **Add to Vizpads**

For more details on adding Insights to a Vizpad, please [refer to this section](https://help.tellius.com/6.0/embedding-tellius/embedding-url/embedding-vizpads/adding-a-viz-to-a-vizpad).
