Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
A high level scripting API for bot builders, developers, and maintainers.
The Python Dialogflow CX Scripting API (DFCX SCRAPI) is a high level API that extends the official Google Python Client for Dialogflow CX. SCRAPI makes using DFCX easier, more friendly, and more pythonic for bot builders, developers, and maintainers.
SCRAPI --> Python Dialogflow CX
as
Keras --> Tensorflow
With DFCX SCRAPI you can perform many bot building and maintenance actions at scale including, but not limited to:
Authentication can vary depending on how and where you are interacting with SCRAPI.
If you're using SCRAPI with a Google Colab notebook, you can add the following to the top of your notebook for easy authentication:
project_id = '<YOUR_GCP_PROJECT_ID>'
# this will launch an interactive prompt that allows you to auth with GCP in a browser
!gcloud auth application-default login --no-launch-browser
# this will set your active project to the `project_id` above
!gcloud auth application-default set-quota-project $project_id
After running the above, Colab will pick up your credentials from the environment and pass them to SCRAPI directly. No need to use Service Account keys! You can then use SCRAPI simply like this:
from dfcx_scrapi.core.intents import Intents
agent_id = '<YOUR_AGENT_ID>'
i = Intents() # <-- Creds will be automatically picked up from the environment
intents_map = i.get_intents_map(agent_id)
If you're using SCRAPI with Cloud Functions or Cloud Run, SCRAPI can pick up on the default environment creds used by these services without any additional configuration!
dfcx-scrapi
to your requirements.txt
fileOnce you are setup with the above, your function code can be used easily like this:
from dfcx_scrapi.core.intents import Intents
agent_id = '<YOUR_AGENT_ID>'
i = Intents() # <-- Creds will be automatically picked up from the environment
intents_map = i.get_intents_map(agent_id)
Similar to Cloud Functions / Cloud Run, SCRAPI can pick up on your local authentication creds if you are using the gcloud CLI.
gcloud init
.gcloud auth login
gcloud auth list
to ensure your principal account is active.This will authenticate your principal GCP account with the gcloud CLI, and SCRAPI can pick up the creds from here.
There are some classes in SCRAPI which still rely on Service Account Keys, notably the DataframeFunctions class due to how it authenticates with Google Sheets.
In order to use these functions, you will need a Service Account that has appropriate access to your GCP project.
For more information and to view the official documentation for service accounts go to Creating and Managing GCP Service Accounts.
Once you've obtained a Service Account Key with appropriate permissions, you can use it as follows:
from dfcx_scrapi.core.intents import Intents
from dfcx_scrapi.tools.dataframe_functions import DataframeFunctions
agent_id = '<YOUR_AGENT_ID>'
creds_path = '<PATH_TO_YOUR_SERVICE_ACCOUNT_JSON_FILE>'
i = Intents(creds_path=creds_path)
dffx = DataframeFunctions(creds_path=creds_path)
df = i.bulk_intent_to_df(agent_id)
dffx.dataframe_to_sheets('GOOGLE_SHEET_NAME', 'TAB_NAME', df)
Set up Google Cloud Platform credentials and install dependencies.
gcloud auth login
gcloud auth application-default login
gcloud config set project <project name>
python3 -m venv venv
source ./venv/bin/activate
pip install -r requirements.txt
To run a simple bit of code you can do the following:
dfcx_scrapi.core
from dfcx_scrapi.core.intents import Intents
creds_path = '<PATH_TO_YOUR_SERVICE_ACCOUNT_JSON_FILE>'
agent_path = '<FULL_DFCX_AGENT_ID_PATH>'
# DFCX Agent ID paths are in this format:
# 'projects/<project_id>/locations/<location_id>/agents/<agent_id>'
# Instantiate your class object and pass in your credentials
i = Intents(creds_path, agent_id=agent_path)
# Retrieve all Intents and Training Phrases from an Agent and push to a Pandas DataFrame
df = i.bulk_intent_to_df()
Here is a brief overview of the SCRAPI library's structure and the motivation behind that structure.
The Core folder is synonymous with the core Resource types in the DFCX Agents (agents, intents, flows, etc.)
The Tools folder contains various customized toolkits that allow you to do more complex bot management tasks, such as
The Builders folder contains simple methods for constructing the underlying protos in Dialogflow CX
We welcome any contributions or feature requests you would like to submit!
Distributed under the Apache 2.0 License. See LICENSE for more information.
Patrick Marlow - pmarlow@google.com - @kmaphoenix
Milad Tabrizi - miladt@google.com - @MRyderOC
Project Link: https://github.com/GoogleCloudPlatform/dfcx-scrapi
Dialogflow CX Python Client Library
Hugging Face - Pegasus Paraphrase
FAQs
A high level scripting API for bot builders, developers, and maintainers.
We found that dfcx-scrapi demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.