Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(dialogflow-cx): migrate code from googleapis/python-dialogflow-cx #9077

Merged
merged 108 commits into from
Feb 8, 2023
Merged
Show file tree
Hide file tree
Changes from 107 commits
Commits
Show all changes
108 commits
Select commit Hold shift + click to select a range
0112e9b
docs(samples): add initial sample codes (#13)
wuyuexin Sep 30, 2020
4f327e7
fix: corrects the repo/homepage link (#15)
danoscarmike Nov 17, 2020
5f60b89
chore(deps): update dependency google-cloud-dialogflow-cx to v0.1.1 (…
renovate-bot Nov 17, 2020
28f0aac
chore(deps): update dependency google-cloud-dialogflow-cx to v0.2.0 (…
renovate-bot Dec 8, 2020
0149d88
Sample code update for regionalization (#29)
wuyuexin Dec 11, 2020
76260fa
chore(deps): update dependency google-cloud-dialogflow-cx to v0.4.0 (…
renovate-bot Mar 5, 2021
53fba49
chore(deps): update dependency google-cloud-dialogflow-cx to v0.4.1 (…
renovate-bot May 12, 2021
658e5ee
chore(deps): update dependency pytest to v6.2.4 (#82)
renovate-bot May 13, 2021
efc824a
chore(deps): update dependency google-cloud-dialogflow-cx to v0.5.0 (…
renovate-bot Jun 1, 2021
c85e53e
chore(deps): update dependency google-cloud-dialogflow-cx to v0.6.0 (…
renovate-bot Jun 8, 2021
a29428b
chore(deps): update dependency google-cloud-dialogflow-cx to v0.7.1 (…
renovate-bot Jun 19, 2021
6565a9b
chore(deps): update dependency google-cloud-dialogflow-cx to v0.8.0 (…
renovate-bot Jun 30, 2021
086d35c
chore(deps): update dependency google-cloud-dialogflow-cx to v1 (#123)
renovate-bot Jul 12, 2021
154a576
chore(deps): update dependency google-cloud-dialogflow-cx to v1.1.0 (…
renovate-bot Jul 22, 2021
9d4da7f
chore(deps): update dependency google-cloud-dialogflow-cx to v1.1.1 (…
renovate-bot Jul 26, 2021
0a42402
docs(samples): add agent creation code snippet (#146)
galz10 Aug 12, 2021
f9043ab
chore(deps): update dependency google-cloud-dialogflow-cx to v1.2.0 (…
renovate-bot Aug 13, 2021
e49d192
docs(samples): add update intent sample (#142)
galz10 Aug 13, 2021
d31a20f
chore: generate python samples templates in owlbot.py (#149)
busunkim96 Aug 18, 2021
46937cc
docs(samples): add region tags (#150)
galz10 Aug 20, 2021
568db06
docs(samples): add region tags (#151)
galz10 Aug 23, 2021
ae9febc
chore(deps): update dependency google-cloud-dialogflow-cx to v1.3.0 (…
renovate-bot Aug 31, 2021
25d0b85
chore(deps): update dependency pytest to v6.2.5 (#158)
renovate-bot Aug 31, 2021
c72d43a
chore(deps): update dependency google-cloud-dialogflow-cx to v1.3.1 (…
renovate-bot Sep 1, 2021
b9fad0c
docs(samples): added page management samples (#152)
galz10 Sep 1, 2021
04934ba
chore: blacken samples noxfile template (#170)
gcf-owl-bot[bot] Sep 17, 2021
50fda02
docs(samples): added filter sample (#171)
galz10 Sep 22, 2021
946349f
chore(deps): update dependency google-cloud-dialogflow-cx to v1.3.2 (…
renovate-bot Sep 28, 2021
5e8086b
chore: fail samples nox session if python version is missing (#180)
gcf-owl-bot[bot] Sep 30, 2021
bef2b3d
chore(python): Add kokoro configs for python 3.10 samples testing (#188)
gcf-owl-bot[bot] Oct 8, 2021
2c46431
chore(deps): update dependency google-cloud-dialogflow-cx to v1.4.0 (…
renovate-bot Oct 11, 2021
4e97dda
chore(deps): update dependency google-cloud-dialogflow-cx to v1.5.0 (…
renovate-bot Oct 11, 2021
c10a605
docs(samples): add voice selection (#184)
galz10 Oct 14, 2021
58439d1
docs(samples): added webhook sample (#169)
galz10 Oct 14, 2021
df77ff9
docs(samples): adds list training phrases sample (#196)
b-loved-dreamer Oct 20, 2021
8d8fc84
chore(deps): update dependency flask to v2.0.2 (#194)
renovate-bot Nov 5, 2021
6251865
docs(samples): added comment to webhook sample (#211)
galz10 Nov 12, 2021
835f148
chore(deps): update dependency google-cloud-dialogflow-cx to v1.6.0 (…
renovate-bot Nov 16, 2021
612b7eb
chore(deps): update dependency google-cloud-dialogflow-cx to v1.7.0 (…
renovate-bot Nov 16, 2021
ec75597
docs(samples): Added LRO code snippet (#220)
galz10 Jan 6, 2022
0f19d5f
chore(samples): Add check for tests in directory (#227)
gcf-owl-bot[bot] Jan 11, 2022
64065a7
chore(python): Noxfile recognizes that tests can live in a folder (#234)
gcf-owl-bot[bot] Jan 19, 2022
dc4546a
chore(deps): update dependency google-cloud-dialogflow-cx to v1.8.0 (…
renovate-bot Jan 19, 2022
9d3154f
chore(deps): update dependency pytest to v7 (#246)
renovate-bot Feb 4, 2022
d5147b8
chore: use gapic-generator-python 0.63.1 (#245)
gcf-owl-bot[bot] Feb 5, 2022
d1703cb
chore(deps): update all dependencies (#251)
renovate-bot Feb 25, 2022
550b930
chore(deps): update all dependencies (#256)
renovate-bot Mar 1, 2022
5dc60fd
chore: Adding support for pytest-xdist and pytest-parallel (#264)
gcf-owl-bot[bot] Mar 4, 2022
c715a7d
chore(deps): update dependency google-cloud-dialogflow-cx to v1.9.1 (…
renovate-bot Mar 8, 2022
0ca1981
chore(deps): update all dependencies (#271)
renovate-bot Mar 14, 2022
a7bdd48
chore(deps): update dependency pytest to v7.1.1 (#272)
renovate-bot Mar 19, 2022
ae0fe8d
chore(python): use black==22.3.0 (#282)
gcf-owl-bot[bot] Mar 29, 2022
e70c5ae
chore(deps): update dependency flask to v2.1.0 (#280)
renovate-bot Mar 30, 2022
e84d24c
chore(deps): update dependency flask to v2.1.1 (#284)
renovate-bot Apr 1, 2022
01f3c84
chore(python): add nox session to sort python imports (#295)
gcf-owl-bot[bot] Apr 21, 2022
458972b
chore(deps): update dependency pytest to v7.1.2 (#299)
renovate-bot Apr 25, 2022
a2e936a
chore(deps): update dependency flask to v2.1.2 (#301)
renovate-bot Apr 28, 2022
938c167
docs(samples): Adds snippet for validating a form parameter. (#302)
nicain Apr 28, 2022
ac0b67f
docs(samples): Configure session parameters snippet (#303)
nicain Apr 28, 2022
e2b77bf
docs(samples): Configure session parameters trigger transition (#304)
nicain Apr 28, 2022
d65329c
docs(samples): Adds snippet for configuring optional or required form…
nicain Apr 29, 2022
b6a7b61
docs(samples): Adds snippet for configuring a webhook to enable an ag…
nicain May 3, 2022
6560687
chore(deps): update dependency google-cloud-dialogflow-cx to v1.11.0 …
renovate-bot May 3, 2022
cd5e1e7
chore(deps): update dependency google-cloud-dialogflow-cx to v1.12.0 …
renovate-bot May 19, 2022
ca90f59
chore: Update dialogflow_cx_webhook snippet to match NodeJS (#409)
nicain Jun 28, 2022
b20018d
chore: Dialogflow cx v3 webhook validate form parameter (#410)
nicain Jun 29, 2022
5495af3
chore: update dialogflow_cx_v3_webhook_configure_session_parameters s…
nicain Jun 29, 2022
5695e6e
chore: Remove refactored webhook snippets (#412)
nicain Jun 29, 2022
bf7511c
docs: add streaming detect intent with partial response sample (#414)
nicain Jul 1, 2022
313338a
docs: add detect intent with sentiment analysis snippet (#416)
nicain Jul 1, 2022
8c0feaf
docs: add detect intent with intent input snippet (#417)
nicain Jul 5, 2022
bc45185
docs: add detect intent with text-to-speech synthesized output snippe…
nicain Jul 6, 2022
bbef545
docs: Dialogflow cx v3 detect intent event input snippet (#421)
nicain Jul 6, 2022
1a26a16
fix: Update detect_intent_synthesize_tts_response.py (#423)
nicain Jul 6, 2022
6db6133
docs: Add dialogflow cx detect intent with disabled webhook snippet (…
nicain Jul 6, 2022
7b9c2f7
chore(python): drop python 3.6 (#420)
gcf-owl-bot[bot] Jul 6, 2022
1cc61d9
docs: Update region_tag: dialogflow_detect_intent_text --> dialogflow…
nicain Jul 6, 2022
c04f09c
chore(deps): update all dependencies (#429)
renovate-bot Aug 2, 2022
e548aa3
chore(deps): update all dependencies (#430)
renovate-bot Aug 2, 2022
11560c0
chore(deps): update all dependencies (#431)
renovate-bot Aug 5, 2022
6f5eb42
chore(deps): update all dependencies (#432)
renovate-bot Aug 9, 2022
12b1fdc
chore(deps): update dependency google-cloud-dialogflow-cx to v1.13.1 …
renovate-bot Aug 19, 2022
8d24760
docs(samples): Add prebuilt telecom agent webhook code in python (#434)
yil532 Aug 22, 2022
85a3f44
chore(deps): update dependency pytest to v7.1.3 (#450)
renovate-bot Sep 6, 2022
fefd09d
chore: detect samples tests in nested directories (#456)
gcf-owl-bot[bot] Sep 13, 2022
b4bc327
feat: Adding snippet to extract SessionInfo (#457)
hjosiah Oct 3, 2022
573b32c
chore(deps): update dependency google-cloud-dialogflow-cx to v1.13.4 …
renovate-bot Oct 18, 2022
e6dda0a
chore(deps): update dependency pytest to v7.2.0 (#467)
renovate-bot Oct 26, 2022
da668a4
chore(deps): update dependency google-cloud-dialogflow-cx to v1.13.5 …
renovate-bot Oct 28, 2022
c16781a
chore(python): drop flake8-import-order in samples noxfile (#473)
gcf-owl-bot[bot] Nov 26, 2022
9f939a6
fix(deps): Require google-api-core >=1.34.0, >=2.11.0 (#469)
gcf-owl-bot[bot] Dec 15, 2022
454a3c2
chore(deps): update dependency google-cloud-dialogflow-cx to v1.14.0 …
renovate-bot Dec 16, 2022
22de71d
docs(samples): Update previous month logic to avoid zero-index bug in…
nicain Jan 6, 2023
6f87417
chore(python): add support for python 3.11 (#477)
gcf-owl-bot[bot] Jan 6, 2023
89d59ee
chore(deps): update dependency google-cloud-dialogflow-cx to v1.14.1 …
renovate-bot Jan 9, 2023
150bca0
chore(deps): update dependency google-cloud-dialogflow-cx to v1.15.0 …
renovate-bot Jan 10, 2023
892c28e
chore(deps): update dependency google-cloud-dialogflow-cx to v1.16.0 …
renovate-bot Jan 12, 2023
37d1189
chore(deps): update dependency pytest to v7.2.1 (#490)
renovate-bot Jan 14, 2023
20fa39c
chore(deps): update dependency google-cloud-dialogflow-cx to v1.17.0 …
renovate-bot Jan 17, 2023
d30d2e8
chore(deps): update dependency google-cloud-dialogflow-cx to v1.17.1 …
renovate-bot Jan 24, 2023
815d118
chore(deps): update dependency google-cloud-dialogflow-cx to v1.18.0 …
renovate-bot Feb 1, 2023
b7c00e6
Merge remote-tracking branch 'migration/main' into python-dialogflow-…
soheilazangeneh Feb 1, 2023
783603d
Rename folder
soheilazangeneh Feb 1, 2023
61e95be
Update CODEOWNERS
soheilazangeneh Feb 1, 2023
3a2e903
Update headers
soheilazangeneh Feb 2, 2023
b97bb76
remove dialogflow/noxfile.py
yil532 Feb 7, 2023
04fa7e9
Merge branch 'main' into python-dialogflow-cx-migration
holtskinner Feb 7, 2023
ad92697
Update .github/CODEOWNERS
dandhlee Feb 8, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,11 @@
/dataproc/**/* @GoogleCloudPlatform/python-samples-reviewers
/datastore/**/* @GoogleCloudPlatform/cloud-native-db-dpes @GoogleCloudPlatform/python-samples-reviewers
/dialogflow/**/* @GoogleCloudPlatform/dee-data-ai @GoogleCloudPlatform/python-samples-reviewers
/dialogflow-cx/**/* @GoogleCloudPlatform/python-samples-reviewers
dandhlee marked this conversation as resolved.
Show resolved Hide resolved
/dns/**/* @GoogleCloudPlatform/python-samples-reviewers
/documentai/**/* @GoogleCloudPlatform/dee-data-ai @GoogleCloudPlatform/python-samples-reviewers
/endpoints/**/* @GoogleCloudPlatform/python-samples-reviewers
/enterpriseknowledgegraph/**/* @GoogleCloudPlatform/dee-data-ai @GoogleCloudPlatform/python-samples-reviewers
/enterpriseknowledgegraph/**/* @GoogleCloudPlatform/dee-data-ai @GoogleCloudPlatform/python-samples-reviewers
/eventarc/**/* @GoogleCloudPlatform/aap-dpes @GoogleCloudPlatform/python-samples-reviewers
/error_reporting/**/* @GoogleCloudPlatform/python-samples-reviewers
/firestore/**/* @GoogleCloudPlatform/cloud-native-db-dpes @GoogleCloudPlatform/python-samples-reviewers
Expand Down
221 changes: 221 additions & 0 deletions dialogflow-cx/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,221 @@

.. This file is automatically generated. Do not edit this file directly.

Dialogflow CX API Python Samples
===============================================================================

.. image:: https://gstatic.com/cloudssh/images/open-btn.png
:target: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor=/README.rst


This directory contains samples for Dialogflow CX API. The `Dialogflow CX API`_ enables you to create conversational experiences across devices and platforms.




.. _Dialogflow CX API: https://cloud.google.com/dialogflow/cx/docs/


Setup
-------------------------------------------------------------------------------



Authentication
++++++++++++++

This sample requires you to have authentication setup. Refer to the
`Authentication Getting Started Guide`_ for instructions on setting up
credentials for applications.

.. _Authentication Getting Started Guide:
https://cloud.google.com/docs/authentication/getting-started




Install Dependencies
++++++++++++++++++++

#. Clone python-docs-samples and change directory to the sample directory you want to use.

.. code-block:: bash

$ git clone https://github.com/GoogleCloudPlatform/python-docs-samples.git

#. Install `pip`_ and `virtualenv`_ if you do not already have them. You may want to refer to the `Python Development Environment Setup Guide`_ for Google Cloud Platform for instructions.

.. _Python Development Environment Setup Guide:
https://cloud.google.com/python/setup

#. Create a virtualenv. Samples are compatible with Python 3.6+.

.. code-block:: bash

$ virtualenv env
$ source env/bin/activate

#. Install the dependencies needed to run the samples.

.. code-block:: bash

$ pip install -r requirements.txt

.. _pip: https://pip.pypa.io/
.. _virtualenv: https://virtualenv.pypa.io/






Samples
-------------------------------------------------------------------------------


Detect Intent Text
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

.. image:: https://gstatic.com/cloudssh/images/open-btn.png
:target: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor=/detect_intent_texts.py,/README.rst




To run this sample:

.. code-block:: bash

$ python detect_intent_texts.py


usage: detect_intent_texts.py [-h] --agent AGENT [--session-id SESSION_ID]
[--language-code LANGUAGE_CODE]
texts [texts ...]

DialogFlow API Detect Intent Python sample with text inputs.

Examples:
python detect_intent_texts.py -h
python detect_intent_texts.py --agent AGENT --session-id SESSION_ID "hello" "book a meeting room" "Mountain View"
python detect_intent_texts.py --agent AGENT --session-id SESSION_ID "tomorrow" "10 AM" "2 hours" "10 people" "A" "yes"

positional arguments:
texts Text inputs.

optional arguments:
-h, --help show this help message and exit
--agent AGENT Agent resource name. Required.
--session-id SESSION_ID
Identifier of the DetectIntent session. Defaults to a
random UUID.
--language-code LANGUAGE_CODE
Language code of the query. Defaults to "en-US".





Detect Intent Audio
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

.. image:: https://gstatic.com/cloudssh/images/open-btn.png
:target: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor=/detect_intent_audio.py,/README.rst




To run this sample:

.. code-block:: bash

$ python detect_intent_audio.py


usage: detect_intent_audio.py [-h] --agent AGENT [--session-id SESSION_ID]
[--language-code LANGUAGE_CODE]
--audio-file-path AUDIO_FILE_PATH

DialogFlow API Detect Intent Python sample with audio file.

Examples:
python detect_intent_audio.py -h
python detect_intent_audio.py --agent AGENT --session-id SESSION_ID --audio-file-path resources/hello.wav

optional arguments:
-h, --help show this help message and exit
--agent AGENT Agent resource name. Required.
--session-id SESSION_ID
Identifier of the DetectIntent session. Defaults to a
random UUID.
--language-code LANGUAGE_CODE
Language code of the query. Defaults to "en-US".
--audio-file-path AUDIO_FILE_PATH
Path to the audio file.





Detect Intent Stream
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

.. image:: https://gstatic.com/cloudssh/images/open-btn.png
:target: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor=/detect_intent_stream.py,/README.rst




To run this sample:

.. code-block:: bash

$ python detect_intent_stream.py


usage: detect_intent_stream.py [-h] --agent AGENT [--session-id SESSION_ID]
[--language-code LANGUAGE_CODE]
--audio-file-path AUDIO_FILE_PATH

DialogFlow API Detect Intent Python sample with audio files processed as an audio stream.

Examples:
python detect_intent_stream.py -h
python detect_intent_stream.py --agent AGENT --session-id SESSION_ID --audio-file-path resources/hello.wav

optional arguments:
-h, --help show this help message and exit
--agent AGENT Agent resource name. Required.
--session-id SESSION_ID
Identifier of the DetectIntent session. Defaults to a
random UUID.
--language-code LANGUAGE_CODE
Language code of the query. Defaults to "en-US".
--audio-file-path AUDIO_FILE_PATH
Path to the audio file.









The client library
-------------------------------------------------------------------------------

This sample uses the `Google Cloud Client Library for Python`_.
You can read the documentation for more details on API usage and use GitHub
to `browse the source`_ and `report issues`_.

.. _Google Cloud Client Library for Python:
https://googlecloudplatform.github.io/google-cloud-python/
.. _browse the source:
https://github.com/GoogleCloudPlatform/google-cloud-python
.. _report issues:
https://github.com/GoogleCloudPlatform/google-cloud-python/issues



.. _Google Cloud SDK: https://cloud.google.com/sdk/
25 changes: 25 additions & 0 deletions dialogflow-cx/README.rst.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# This file is used to generate README.rst

product:
name: Dialogflow CX API
short_name: Dialogflow CX API
url: https://cloud.google.com/dialogflow/cx/docs/
description: >
The `Dialogflow CX API`_ enables you to create conversational experiences across devices and platforms.

setup:
- auth
- install_deps

samples:
- name: Detect Intent Text
file: detect_intent_texts.py
show_help: True
- name: Detect Intent Audio
file: detect_intent_audio.py
show_help: True
- name: Detect Intent Stream
file: detect_intent_stream.py
show_help: True

cloud_client_library: true
40 changes: 40 additions & 0 deletions dialogflow-cx/create_agent.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Copyright 2023 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


"""DialogFlow API Create Agent Sample"""

## [START dialogflow_cx_create_agent_sample]
from google.cloud.dialogflowcx_v3.services.agents.client import AgentsClient
from google.cloud.dialogflowcx_v3.types.agent import Agent


def create_agent(project_id, display_name):

parent = "projects/" + project_id + "/locations/global"

agents_client = AgentsClient()

agent = Agent(
display_name=display_name,
default_language_code="en",
time_zone="America/Los_Angeles",
)

response = agents_client.create_agent(request={"agent": agent, "parent": parent})

return response


## [END dialogflow_cx_create_agent_sample]
42 changes: 42 additions & 0 deletions dialogflow-cx/create_agent_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Copyright 2023 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Test for create_agent"""

import os
import uuid

from google.cloud.dialogflowcx_v3.services.agents.client import AgentsClient
from google.cloud.dialogflowcx_v3.types.agent import DeleteAgentRequest

import pytest

from create_agent import create_agent

PROJECT_ID = os.getenv("GOOGLE_CLOUD_PROJECT")
pytest.AGENT_PATH = ""


def delete_agent(name):
agents_client = AgentsClient()
request = DeleteAgentRequest(name=name)
agents_client.delete_agent(request=request)


def test_create_agent():
agentName = f"fake_agent_{uuid.uuid4()}"
response = create_agent(PROJECT_ID, agentName)
delete_agent(response.name)

assert response.display_name == agentName
Loading