Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A Dialogflow CX webhook is an HTTPS backend that handles a conversational turn when an agent reaches a webhook-enabled fulfillment. Dialogflow sends it a JSON request; your service runs the required business logic and returns a response the agent can use for messages, session state, or a page or flow transition. To build one, connect a webhook resource to a fulfillment, handle the request contract you choose, and make the endpoint secure, fast, and safe to retry.

How a Dialogflow CX webhook works

During a conversation, the integration sends a detect-intent request. If the matched flow or page reaches a fulfillment configured to call a webhook, Dialogflow CX sends an HTTPS POST request to your service. The service can query a database or call another API, then returns a webhook response. Dialogflow incorporates that response into the detect-intent response delivered to the interface.

Google documents encryption in transit and ALTS for internal Google communications. Your webhook is still a service you operate: it must accept the configured authentication, validate and process requests, and return a response in the required time.

Choose standard or flexible webhooks

Option Contract Best fit Trade-off
Standard Dialogflow-defined request and response messages, with conversational context such as the active page, matched intent, session parameters, language, and fulfillment information. A handler that needs rich CX context or returns standard CX response features. Your service must handle the standard contract, even if it uses only some of the available context.
Flexible You define the HTTP method, URL parameter references, request JSON fields, and response field mappings in the webhook resource. A small, stable interface where limiting the exchanged data helps reduce implementation complexity or exposure. The narrower contract may not carry the full conversational context a standard webhook provides.

Choose based on what the backend actually needs. Standard is generally the more direct fit when behavior depends on page, intent, or session context. Flexible is useful when the backend should receive only a deliberately selected set of fields. Keep the chosen contract consistent between the webhook resource and handler.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Connect the webhook to a fulfillment

  1. Deploy an HTTPS endpoint. Use a runtime and hosting service that can accept the configured request and return JSON. Cloud Functions is Google’s documented quickstart path; Cloud Run is a managed option for containerized handlers and service-agent authentication.
  2. Create or configure the webhook resource. Set the service URL, select standard or flexible behavior, choose an appropriate timeout, and configure authentication. Use separate URLs and authentication settings for development and production.
  3. Configure fulfillment to call that resource. Attach the webhook to the relevant page or flow fulfillment and assign a meaningful tag. The tag is sent as fulfillmentInfo.tag and can be used to dispatch to the correct handler logic.
  4. Test the complete turn. Verify that the fulfillment invokes the expected URL, the handler receives the expected request contract, and Dialogflow uses the returned response as intended.

Read and dispatch the request

A standard WebhookRequest is JSON. Its documented fields use camel case and include fulfillmentInfo.tag, intentInfo, pageInfo, and sessionInfo. Use the tag to select the operation, and read conversational state from the documented session or page structures relevant to that operation. Validate fields before relying on them: a request may not contain a value your handler expects in every conversational path.

Google notes that undocumented internal fields can appear in requests. Ignore them rather than building behavior around fields that are not part of the supported contract.

A practical handler sequence

  1. Parse the JSON body and reject malformed input with a controlled failure.
  2. Read the fulfillment tag and route only recognized tag values to business logic.
  3. Validate the required parameters and their types before calling a backend.
  4. Call databases or external services with bounded timeouts so downstream work cannot consume the entire webhook budget.
  5. Build a response using the contract configured for the webhook and return JSON.

Keep business logic separate from HTTP parsing and response formatting. This makes it easier to test tag dispatch and backend behavior without depending on a live conversational turn.

Design the webhook response

A standard response can set sessionInfo.parameters, return messages in fulfillmentResponse.messages, provide pageInfo for parameter or page status, attach integration-specific payload data, or request a transition using targetPage or targetFlow. A response cannot set both a target page and a target flow.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Google’s implementation guidance recommends setting session parameters so the agent’s fulfillment can consistently control dynamic responses. Use response messages when the webhook needs to return text or other supported fulfillment content directly; set session state when the agent should use returned values in its own logic.

For example, a minimal standard response expressed in the REST contract’s camel-case JSON uses this shape:

{
  "fulfillmentResponse": {
    "messages": [
      {
        "text": {
          "text": ["Your order is ready for pickup."]
        }
      }
    ]
  }
}

Implementation samples may show runtime-specific representations with different field casing. Follow the contract for the runtime and API version you are using; do not copy a sample’s casing without checking that it matches the endpoint’s expected JSON.

Handle timeouts, retries, and side effects

The webhook response must arrive within the timeout configured on the webhook resource and must be 64 KiB or smaller. Dialogflow retries once after a timeout or transient failure. If the retry also times out, the documented timeout event is raised.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • Choose a timeout that accounts for the slowest necessary dependency, while keeping backend calls individually bounded.
  • Make writes idempotent. A retried request should not create a duplicate payment, booking, or other side effect.
  • Where possible, use a request or transaction identifier to detect and deduplicate repeated work.
  • Return a controlled response for downstream failures rather than allowing an unhandled exception or an indefinite wait.
  • Keep responses compact and check their serialized size against the 64 KiB limit.

Secure the endpoint and its credentials

Dialogflow CX webhook resources support authorization headers, basic authentication, third-party OAuth client credentials, service accounts, service-agent ID tokens, and mutual TLS (mTLS). Use HTTPS and select the strongest option compatible with the deployment and integration.

Cloud Run and Cloud Functions access

For a Cloud Run service in the same Google Cloud project, Google documents using Service Agent Auth with an ID token. For a service in another project, grant the Dialogflow Service Agent the appropriate Cloud Run or Cloud Functions Invoker role. Apply least privilege: the service agent should receive only the access needed to invoke the endpoint and retrieve any required secret.

Secrets, identity tokens, and mTLS

Store static credentials in Secret Manager rather than embedding them in source code or logging them. Grant the Dialogflow Service Agent only the required secret-access role. When using identity tokens, verify the token and its audience at the endpoint. With mTLS, validate Dialogflow’s client certificate and the bearer service identity token; checking both helps authenticate requests from the intended agent.

Do not treat source IP ranges as the primary identity check. Google cautions that the machines making requests are not guaranteed to remain within fixed ranges.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Choose a hosting and deployment approach

Cloud Functions provides a simple documented quickstart for a handler that reads JSON, applies logic, and returns JSON. Cloud Run is a managed alternative for containerized services and supports secure service-agent authentication. Another HTTPS service can also work if it meets the contract, authentication, latency, and response-size requirements.

Evaluate an implementation on the dimensions that affect its reliability and exposure:

  • Contract: whether standard context or a deliberately narrow flexible request is needed.
  • Hosting: whether a function, containerized service, or another HTTPS backend best fits deployment and operations.
  • Latency: whether the complete handler, including downstream calls, can finish within the configured timeout.
  • Security: whether authentication, IAM permissions, token checks, and secret storage are appropriate.
  • Operations: whether environments are isolated and logs provide enough status and latency information to diagnose failures.
  • Retries: whether side effects remain safe when a transient failure causes Dialogflow to retry.

Troubleshoot a webhook that fails or times out

  • The wrong handler branch runs: Confirm the fulfillment uses the intended webhook and inspect fulfillmentInfo.tag in the request.
  • Dialogflow rejects or ignores the response: Check that the body is valid JSON, matches the configured contract and expected field casing, and contains the response fields the agent expects.
  • The call times out: Compare end-to-end latency with the webhook’s configured timeout. Check slow downstream dependencies and set bounded timeouts for them.
  • A response is too large: Measure the serialized response and keep it at or below 64 KiB.
  • An action happens twice: Account for the single automatic retry and make writes idempotent, using an identifier to deduplicate side effects where possible.
  • Authentication fails: Check Cloud Run or Cloud Functions invoker permissions, the Dialogflow Service Agent identity, Secret Manager access, and the identity token audience.
  • Development works but production does not: Check environment-specific URLs and authentication settings before changing the production configuration.
  • An unfamiliar request field appears: Ignore undocumented internal fields unless Google documents a supported use for them.

For diagnosis, log request status, latency, and a correlation identifier. Do not log secrets or personal data that is not needed to troubleshoot the integration.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.