0

I have been trying to warn the user that their session is about to end using dialogflow CX. But I can't get it to respond to me, without the user making a request first.

Is there any way to do this without the user making a request first?

Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189

1 Answers1

3

For your use case, if you’ve integrated your agent to your custom application, you can do your own implementation to create a timer that tracks the session time of the user and display a warning on your custom application that the user’s session is ending soon. This approach must be done on your custom application’s side and does not require the use of Dialogflow.

Alternatively, you can use the timer that tracks the session time of the user on your custom application to send a detectIntent request containing the current session ID of the user to your agent to trigger an event. This lets your agent send a response to the user within the same session without having the user to first send a request.

  1. Inside your flow, select the page you want to add a custom event to. Then, click the “Add route type” button to add the Event handlers if not yet added. enter image description here

  2. Click on the + sign beside “event handlers” field and select any event. enter image description here

  3. Tick the check box beside “Use custom event”. enter image description here

  4. Add the name of the custom event you want to use. 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-name" // custom event to be triggered
    },
    "languageCode": "en"
  },
  "queryParams": {
    "timeZone": "America/Los_Angeles"
  }
}

You can refer below for more information on:

For more samples on detect intent calls, please refer to this link.

To integrate your agent with your own application, you can use Dialogflow CX’s Client Libraries, Rest API, or RPC API.

Jessica Rodriguez
  • 2,899
  • 1
  • 12
  • 27
Zeke
  • 31
  • 1