> For the complete documentation index, see [llms.txt](https://docs.immedio.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.immedio.io/guides/ai-sdr-trigger.md).

# AI接客トリガー（ホストサイト連携）

## AI接客トリガーとは

AI接客トリガーとは、ホストサイト側のJavaScriptからAI接客チャットにメッセージを送信できる機能です。ブラウザのCustomEventを使って、任意のボタンやリンクのクリックなど、ホストサイト側の操作をきっかけにAI接客の会話を開始できます。

たとえば「料金について聞く」ボタンをWebサイト上に配置し、クリック時にAI接客へメッセージを自動送信することで、リードが手入力せずにスムーズに会話を始められます。

## AI接客トリガーでできること

| 機能         | 説明                                        |
| ---------- | ----------------------------------------- |
| メッセージの自動送信 | ホストサイトからAI接客チャットへ任意のメッセージを送信できます          |
| チャットの自動展開  | メッセージ送信時にチャットウィジェットが最小化されていた場合、自動的に展開されます |

## イベント仕様

### イベント名

`immedio-trigger:send-ai-sdr-message`

### イベントの種類

ブラウザ標準の `CustomEvent` を使用します。`window.dispatchEvent()` でイベントを発火します。

### detail（イベントデータ）

| 項目      | 型      | 説明                 |
| ------- | ------ | ------------------ |
| message | string | AI接客チャットに送信するメッセージ |

### 動作の流れ

1. ホストサイト側でCustomEventを発火します
2. AI接客チャットが最小化されている場合、自動的に展開されます
3. `detail.message` に指定したメッセージがリードの発言としてAIに送信されます
4. AIが応答を返します

## 使い方（サンプルコード）

以下のコードを、immedioタグが読み込まれているページに配置すると、任意のタイミングでAI接客にメッセージを送信できます。

### 基本的な使い方

```javascript
window.dispatchEvent(new CustomEvent('immedio-trigger:send-ai-sdr-message', {
  detail: { message: '料金を教えて' },
}));
```

### ボタンクリック時に発火する例

```html
<button onclick="window.dispatchEvent(new CustomEvent('immedio-trigger:send-ai-sdr-message', { detail: { message: '料金プランについて教えてください' } }))">
  料金について聞く
</button>
```

### 複数のボタンを配置する例

```html
<button onclick="window.dispatchEvent(new CustomEvent('immedio-trigger:send-ai-sdr-message', { detail: { message: 'デモを予約したい' } }))">
  デモを予約する
</button>

<button onclick="window.dispatchEvent(new CustomEvent('immedio-trigger:send-ai-sdr-message', { detail: { message: '導入事例を教えてください' } }))">
  導入事例を見る
</button>
```

### 検索バーの入力内容をAI接客に送信する例

検索バーに入力された任意の文字列を、AI接客へそのまま送信する例です。リードが検索バーに質問を入力して送信ボタンを押すと、その内容がAI接客チャットに転送されます。

```html
<form onsubmit="event.preventDefault(); var input = this.querySelector('input'); var message = input.value.trim(); if (message) { window.dispatchEvent(new CustomEvent('immedio-trigger:send-ai-sdr-message', { detail: { message: message } })); input.value = ''; }">
  <input type="text" placeholder="AIに質問する..." />
  <button type="submit">送信</button>
</form>
```

## 注意事項

* イベントを発火するには、immedioのタグが読み込まれており、AI接客が有効になっている必要があります
* `detail.message` が空文字または空白のみの場合、メッセージは送信されません
* AI接客のチャット履歴の読み込みが完了する前にイベントが発火された場合、メッセージは送信されません

## 関連

* [AI接客 基本設定](/company-settings/ai-sdr/basic-settings.md)
* [AI接客 フロー設定](/company-settings/ai-sdr/flow.md)
* [immedioイベント（ブラウザイベント連携）](/guides/immedio-events.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.immedio.io/guides/ai-sdr-trigger.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
