> For the complete documentation index, see [llms.txt](https://docs.tnid.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.tnid.com/api-reference/002_company/003_message_sentiment_analysis/001__report_communication_for_analysis.md).

# Report Communication For Analysis

GraphQL endpoint: `/company`

Report communications for Sentiment analysis. The communication will be analyzed based on the past few messages (between the sender and receiver). The result can be an action of "subscribe" where user will be automatically subscribed to selected topics, or it can be "unsubscribe", where the unsubscribe info will be sent to the company via registered webhooks.

The webhook will contain the following payload:

```json
{
  "external_communication_id": "00000000-0000-4000-8000-000000000001",
  "timestamp": "2026-01-15T09:00:00.000000",
  "action": "unsubscribe"
}
```

The subscribes are automatic, but for "unsubscribe", the company can provide feedback via the mutation `feedbackOnDetectedUnsubscribe` to confirm or deny the unsubscribe action. Check the next entry for more details.

## Query

```graphql
mutation (
    $direction: CommunicationDirection!
    $type: CommunicationType!
    $external_message_id: String!
    $host_address: String!
    $remote_address: String!
    $message_body: String!
    $timestamp: NaiveDateTime!
    $metadata: JSON
) {
  reportExternalCommunication (
    direction: $direction
    type: $type
    external_message_id: $external_message_id
    host_address: $host_address
    remote_address: $remote_address
    message_body: $message_body
    timestamp: $timestamp
    metadata: $metadata
  ) {
    status
  }
}

```

## Variables

```json
{
  "direction": "INBOUND",
  "external_message_id": "00000000-0000-4000-8000-000000000002",
  "host_address": "1",
  "message_body": "This is a test message!",
  "metadata": {
    "additional_info": "Test metadata"
  },
  "remote_address": "2",
  "timestamp": "2026-01-15T09:00:00.000000",
  "type": "SMS"
}
```

## Response

```json
{
  "data": {
    "reportExternalCommunication": {
      "status": "OK"
    }
  }
}
```
