<jupyter_start><jupyter_text>IntroductionIn this notebook, we will demonstrate how Google Sheets can be used as a simple medium for managing, updating, and evaluating Intents and Training Phrases in Dialogflow CX.Specifically, we will show how to `update` **_Existing Intents_** and Training Phrases in Dialogflow CX using Google Sheets as a Source Prerequisites- Ensure you have a GCP Service Account key with the Dialogflow API Admin privileges assigned to it<jupyter_code>#If you haven't already, make sure you install the `dfcx-scrapi` library

!pip install dfcx-scrapi<jupyter_output><empty_output><jupyter_text>Imports<jupyter_code>from dfcx_scrapi.core.intents import Intents
from dfcx_scrapi.tools.dataframe_functions import DataframeFunctions<jupyter_output><empty_output><jupyter_text>User InputsIn the next section, we will collect runtime variables needed to execute this notebook.   This should be the only cell of the notebook you need to edit in order for this notebook to run.For this notebook, we'll need the following inputs:- `creds_path`: Your local path to your GCP Service Account Credentials- `agent_id`: Your Dialogflow CX Agent ID in String format- `google_sheet_name`: The name of your Google Sheet- `google_sheet_tab_read`:  The name of the tab in your Google Sheet to read the data from<jupyter_code>creds_path = '<YOUR_CREDS_PATH_HERE>'
agent_id = '<YOUR_AGENT_ID_HERE>'
google_sheet_name = 'My Google Sheet Name'
google_sheet_tab_read = 'Read From My Tab Name'<jupyter_output><empty_output><jupyter_text>Sheets to CXHere, we'll demonstrate how to `update` an **_Existing Intent_** in your Dialogflow CX Agent based on data from a Google Sheet. Prerequisites- In order for the `DataframeFunctions` class to interact with Google Sheets, you *must* share your Google Sheet with your Service Account email address.- For this specific function, you must have exactly 2 columns with the following names:    - `display_name`    - `text`<jupyter_code>dffx = DataframeFunctions(creds_path)

df = dffx.sheets_to_dataframe(google_sheet_name, google_sheet_tab_read)
dffx.bulk_update_intents_from_dataframe(agent_id, df, update_flag=True, rate_limiter=1)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.062244434348023625, 'fraction_numerical': 0.0009086778736937755, 'mean_word_length': 6.515358361774744, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '554974', 'license': 'Apache-2.0', 'n_tokens_mistral': 671, 'n_tokens_neox': 643, 'n_words': 252, 'path': 'examples/google_sheets_series/sheets_to_cx.ipynb', 'repo_name': 'karkipra/dfcx-scrapi', 'size': '2201'}