With an
[integration](https://docs.cloud.google.com/dialogflow/cx/docs/concept/integration.md.txt),
end-user interactions are handled for you.
You just need to build an agent, optionally implement a webhook,
and configure the integration.

This guide shows you how to use the
[Dialogflow CX Messenger](https://docs.cloud.google.com/dialogflow/cx/docs/concept/integration/dialogflow-messenger.md.txt)
integration to provide a simple text chat user interface
for your agent.

## Before you begin

If you don't plan on using an integration, you can skip this quickstart.

You should do the following before reading this guide:

1. Read [flow basics](https://docs.cloud.google.com/dialogflow/cx/docs/basics.md.txt).
2. Perform [setup steps](https://docs.cloud.google.com/dialogflow/cx/docs/quick/setup.md.txt).
3. Perform steps in the [Build an agent using flows](https://docs.cloud.google.com/dialogflow/cx/docs/quick/build-agent.md.txt) quickstart guide. Steps below continue working on the same agent. If you no longer have that agent, you can [download the agent](https://docs.cloud.google.com/static/dialogflow/cx/docs/data/agent-shirts-1-flow.zip) and [restore it](https://docs.cloud.google.com/dialogflow/cx/docs/concept/agent.md.txt#export).

## Setup

> [!NOTE]
> **Note:** The steps below create an integration that allows unauthenticated agent query access. See the [Dialogflow CX Messenger documentation](https://docs.cloud.google.com/dialogflow/cx/docs/concept/integration/dialogflow-messenger.md.txt) for instructions to create an authenticated integration.


Before enabling or testing the integration, make sure
[billing is enabled](https://docs.cloud.google.com/dialogflow/cx/docs/quick/setup.md.txt#billing) on your
project.

> [!CAUTION]
> **Caution:** Enabling unauthenticated access lets anyone query your agent without signing in. Callers can send untrusted fields (such as `payload`, `endUserMetadata`, and `queryInput.event`) and set or overwrite session parameters in the allowlist (or all session parameters if **Accept any parameter** is enabled or on pre-existing unconfigured integrations). Use unauthenticated access only when your agent serves public information, and don't rely on client-supplied fields or session parameters to verify user identity or permissions. For non-public data or identity checks, use [authenticated
> access](https://docs.cloud.google.com/dialogflow/cx/docs/concept/integration/dialogflow-messenger#setup).

To set up unauthenticated access to your Dialogflow CX Messenger agent:

1. Go to the [Dialogflow CX console](https://dialogflow.cloud.google.com/cx/projects).
2. Choose your Google Cloud project.
3. Select your agent.
4. Select the **Manage** tab.
5. Click **Integrations** in the left sidebar menu.
6. Click **Connect** on **Dialogflow CX Messenger**.
7. A configuration dialog opens.
8. If the integration was previously setup for this agent, you will see embeddable HTML code. Regardless of whether you want what authenticated or unauthenticated, click the **Disable...** button at the bottom of the dialog, so you can reconfigure the settings in the next step.
9. Select an **Environment**.
10. Select **Unauthenticated API**.
11. Select a style.
12. Optionally restrict domain access. Domain access restriction checks only the browser `Origin` header and doesn't authenticate callers.
13. Under **Parameters from your website** , optionally list the session parameter names your website is allowed to send in `queryParams.parameters`. By default, no client-supplied session parameters are accepted. For details, see [Client
    parameter allowlist](https://docs.cloud.google.com/dialogflow/cx/docs/concept/integration/dialogflow-messenger#client-parameter-allowlist).
14. Click **Enable Conversational Messenger** (or **Enable Dialogflow Messenger** in the legacy Dialogflow CX console).
15. The dialog will show the embeddable HTML code that can be embedded on your website. Copy this code.
16. Click **Done**.

<br />

## Embed


Paste the embed code you copied above in a webpage on your website.
The `<script>` and `<df-messenger>` HTML elements
should be in the `<body>` element of your page.

If you are using an authenticated integration,
set the `oauth-client-id` attribute for `<df-messenger>`
to your Oauth client id. And if you want to use end-users' identities for [tool
authentication](https://docs.cloud.google.com/dialogflow/cx/docs/concept/playbook/tool#openapi_tool_api_authentication),
set the `access-token-name` attribute with any name you like.
Then use Bearer Token with value `$session.params.ACCESS_TOKEN_NAME`
for tool authentication.

Update any other attributes that require updating.

To allow for responsive layouts,
also add the following to your `<head>` element:

    <meta name="viewport" content="width=device-width, initial-scale=1">

<br />

Once embedded,
you can interact with your agent through the webpage
by clicking the chat icon in the lower right corner.

![Messenger interface screenshot](https://docs.cloud.google.com/static/dialogflow/cx/docs/images/quick-integration.png)

## Customize

You can customize the appearance and behavior of this user interface
in many ways.
See the
[Dialogflow CX Messenger documentation](https://docs.cloud.google.com/dialogflow/cx/docs/concept/integration/dialogflow-messenger.md.txt)
for more information.