'manipulate an existing Dialogflow CX session with a python backend script

I have an existing and functional Chat Bot with Google Dialogflow CX. The Chatbot is directly integrated in a website by the Google Bootstrap.

In some cases a Python script must trigger an intent or page for the user from the backend. In that case the user (and his client) should directly jump in this intent. The session ID of the user is known.

So far I managed it to set a parameter for the user from the python script using the following code.

from google.cloud import dialogflowcx_v3beta1 as dialogflow
from google.cloud.dialogflowcx_v3beta1 import types

session_id = "7826e7-0b7-794-b24-b95271869"

api_endpoint = f"{location_id}-dialogflow.googleapis.com"
client_options = {"api_endpoint": api_endpoint}
client = dialogflow.services.sessions.SessionsClient(client_options=client_options)

event = "live_chat_event"
params = {'message': "Hello World"}

event_input = types.EventInput(event=event)
query_input = types.QueryInput(event=event_input, language_code=language_code)
query_params = types.QueryParameters(parameters=params)

request = types.DetectIntentRequest(
        session=session_path,
        query_input=query_input,
        query_params = query_params
        )
response = client.detect_intent(request=request)

print(response.query_result.response_messages[0])

These parameters are then visible by the user on his client, but only after typing the next message.

I need the client to refresh itself or let it jump directly into the next page without any additional input from the user.

How can that be achieved?



Solution 1:[1]

Hey bro don't get complicated.

If you are struggling to get the DF API to work you are not the only one.

I can advise you to try the Voximplant Python Client so you can connect to your DF CX Agent easily and control that script . On top of that you can also handle calls with your DF CX or ES Agent.

You can check the documentation to add teh Credentials for DF here.

Also please check this Python API Client so you can run a Scenario that communicates with your CX Agent.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Nicolás Calderón González