# Webhook

The **Webhook channel** allows you to trigger an Autom Mate AI Agent programmatically via an HTTP request.

This channel is designed for system-to-system communication, enabling external applications, services, or workflows to interact with AI Agents without a user interface.

It is ideal for backend integrations, custom applications, and automation scenarios where direct API access is required.

***

### How Webhook Integration Works

When a request is sent to the webhook endpoint:

1. An external system sends an HTTP request to the webhook URL
2. The request is received by Autom Mate
3. The configured AI Agent processes the input
4. The AI Agent may interact with connected systems (ServiceNow, Xurrent, ServiceDesk Plus, etc.)
5. A response is returned to the calling system

This enables AI Agents to be embedded into any system that supports HTTP communication.

***

### Enable Webhook for an AI Agent

#### Step 1 — Open AI Agent Composer

Navigate to:\
**AI Agent Composer**

Select the AI Agent you want to expose via API.

***

#### Step 2 — Open Channels

Go to the **Channels** section.

Select **Webhook**.

***

#### Step 3 — Copy the Webhook URL

The system will generate a unique Webhook URL:

```
https://aut.autommate.app/api/v1/automs/run/{autom_id}?apiKey={api_key}
```

This endpoint is used to send requests to the AI Agent.

> The API key is embedded in the URL and is required for authentication.

***

### Making a Request

#### Endpoint

```
POST {webhook_url}
```

#### Headers

```
Content-Type: application/json
```

#### Payload Example

```json
{
  "message": "Hello",
  "userId": "user123",
  "sessionId": "session123"
}
```

***

### Request Parameters

| Field     | Type   | Description                                  |
| --------- | ------ | -------------------------------------------- |
| message   | string | The user input or query sent to the AI Agent |
| userId    | string | Unique identifier for the user               |
| sessionId | string | Identifier to maintain conversation context  |

***

### Response Behavior

* The AI Agent processes the input
* Executes any required tools or integrations
* Returns a response to the caller

The response format depends on the AI Agent configuration and connected systems.

***

### Testing the Webhook

You can test the endpoint using:

* Postman
* cURL
* Any HTTP client

#### Example cURL Request

```bash
curl -X POST "{webhook_url}" \
  -H "Content-Type: application/json" \
  -d '{
    "message": "Hello",
    "userId": "test-user",
    "sessionId": "test-session"
  }'
```

***

### Typical Use Cases

Webhook-based AI Agents are commonly used for:

* Backend system integrations
* Triggering AI workflows from external applications
* Embedding AI into custom UIs
* Automation pipelines
* Event-driven processing

***

### Security Considerations

* Treat the Webhook URL as a **secure endpoint**
* Do not expose the API key publicly
* Restrict usage to trusted systems
* Rotate credentials if compromised

***

### When to Use Webhook

Use the Webhook channel when:

* You need direct API access to the AI Agent
* You are building custom integrations or applications
* You want full control over request/response handling
