<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Introduction
In 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 extract Intents and Training Phrases from Dialogflow CX to Google Sheets.
Prerequisites
Ensure you have a GCP Service Account key with the Dialogflow API Admin privileges assigned to it
Step1:  Imports
Step2:  User Inputs
In 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
Step3:  CX to Sheets
Here, we'll demonstrate how to extract all of the Intents and Training Phrases from your Dialogflow CX Agent and push them to 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.
<ASSISTANT_TASK:>
Python Code:
#If you haven't already, make sure you install the `dfcx-scrapi` library
!pip install dfcx-scrapi
Explanation: Introduction
In 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 extract Intents and Training Phrases from Dialogflow CX to Google Sheets.
Prerequisites
Ensure you have a GCP Service Account key with the Dialogflow API Admin privileges assigned to it
End of explanation
from dfcx_scrapi.core.intents import Intents
from dfcx_scrapi.tools.dataframe_functions import DataframeFunctions
Explanation: Imports
End of explanation
creds_path = '<YOUR_CREDS_PATH_HERE>'
agent_id = '<YOUR_AGENT_ID_HERE>'
google_sheet_name = 'My Google Sheet Name'
google_sheet_tab_write = 'Write To My Tab Name'
Explanation: User Inputs
In 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_write:  The name of the tab in your Google Sheet where the data will be written
End of explanation
# Instanstiate Classes
intents = Intents(creds_path)
dffx = DataframeFunctions(creds_path)
# Transform Intents into a DataFrame
df = intents.bulk_intent_to_df(agent_id)
# Push DataFrame to Google Sheets
dffx.dataframe_to_sheets(google_sheet_name, google_sheet_tab_write, df)
print('Total # of Intents = {}'.format(df.intent.nunique()))
print('Total # of Training Phrases = {}'.format(df.tp.nunique()))
Explanation: CX to Sheets
Here, we'll demonstrate how to extract all of the Intents and Training Phrases from your Dialogflow CX Agent and push them to 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.
End of explanation
<END_TASK>