Search code examples
dialogflow-cx

Start a conversation at the beginning of a flow using flow ID


Is it possible to use SessionClient or FlowClient to start a session with an agent at the beginning of a specific flow? Dialogflow ES API allows for sending an event, like a Welcome Event. Is there a similar functionality for CX that would take in a flow ID?


Solution

  • If you have your own Custom Integration, you can send a detectIntent request to your agent to trigger a custom event. This lets your agent trigger a page with the custom event and send a response to the user without any user query or input.

    Here’s a simple guide to create a custom event:

    1. Inside your flow, select the page you want to add a custom event to then click the "Event handlers". If the "Event handlers" is not visible, click the “Add route type” button to add the Event handlers.
    2. Click on the + sign beside “event handlers” field and select any event.
    3. Tick the check box beside “Use custom event”.
    4. Add the name of the custom event you want to use.
    5. Add the desired response under “Agent says”.
    6. Click save.

    enter image description here

    Here’s a sample detectIntent request that triggers the Default welcome intent using Node.js.

    enter image description here

    Here’s a sample detectIntent request that triggers a custom event using REST API:

    Sample URL for detect intent API:

    POST https://dialogflow.googleapis.com/v3beta1/projects/project-id/locations/us/agents/agent-id/sessions/session-id:detectIntent

    Make the following replacements for the URL:

    • project-id: your GCP project ID
    • agent-id: your agent ID
    • session-id: your session ID

    Sample JSON Request Body should look like this:

    {
      "queryInput": {
        "event": {
          "event": "custom-event" // custom event to be triggered
        },
        "languageCode": "en"
      },
      "queryParams": {
        "timeZone": "America/Los_Angeles"
      }
    }
    

    You can refer below for more information on:

    You can use Dialogflow CX’s Client Libraries, Rest API, or RPC API to create your own implementation/integration.