{"id":15221523,"url":"https://github.com/googlecloudplatform/dfcx-scrapi","last_synced_at":"2025-05-15T20:07:13.265Z","repository":{"id":37848378,"uuid":"397338367","full_name":"GoogleCloudPlatform/dfcx-scrapi","owner":"GoogleCloudPlatform","description":"A high level scripting API for bot builders, developers, and maintainers.","archived":false,"fork":false,"pushed_at":"2025-05-08T15:48:58.000Z","size":6039,"stargazers_count":113,"open_issues_count":40,"forks_count":67,"subscribers_count":30,"default_branch":"main","last_synced_at":"2025-05-15T20:06:08.331Z","etag":null,"topics":["chatbot","dialogflow","dialogflow-fulfillment","google","google-cloud-platform","nlu","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/GoogleCloudPlatform.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2021-08-17T17:24:26.000Z","updated_at":"2025-05-09T10:42:57.000Z","dependencies_parsed_at":"2022-06-22T20:44:14.215Z","dependency_job_id":"c7701bfe-0091-4865-85e6-e901ecd6a6c0","html_url":"https://github.com/GoogleCloudPlatform/dfcx-scrapi","commit_stats":{"total_commits":932,"total_committers":30,"mean_commits":"31.066666666666666","dds":0.7328326180257511,"last_synced_commit":"db724d6c75b19c54b9564f3714cce0e702067d54"},"previous_names":[],"tags_count":41,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GoogleCloudPlatform%2Fdfcx-scrapi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GoogleCloudPlatform%2Fdfcx-scrapi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GoogleCloudPlatform%2Fdfcx-scrapi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GoogleCloudPlatform%2Fdfcx-scrapi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GoogleCloudPlatform","download_url":"https://codeload.github.com/GoogleCloudPlatform/dfcx-scrapi/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254414501,"owners_count":22067272,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["chatbot","dialogflow","dialogflow-fulfillment","google","google-cloud-platform","nlu","python"],"created_at":"2024-09-28T15:05:34.069Z","updated_at":"2025-05-15T20:07:08.189Z","avatar_url":"https://github.com/GoogleCloudPlatform.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!-- PROJECT LOGO --\u003e\n\u003cdiv align=\"center\"\u003e\n    \u003cimg src=\"images/logo.png\" alt=\"Scrappy, the SCRAPI mascot!\" width=\"200\"\u003e\n\n  \u003ch3 align=\"center\"\u003ePython Dialogflow CX Scripting API (SCRAPI)\u003c/h3\u003e\n  \u003cp align=\"center\"\u003e\n    A high level scripting API for bot builders, developers, and maintainers.\u003cbr\u003e\n  \u003c/p\u003e\n\u003c/div\u003e\n\n\u003c!-- TABLE OF CONTENTS --\u003e\n\u003cdetails open=\"open\"\u003e\n  \u003csummary\u003eTable of Contents\u003c/summary\u003e\n  \u003col\u003e\n    \u003cli\u003e\n      \u003ca href=\"#introduction\"\u003eIntroduction\u003c/a\u003e\n      \u003cul\u003e\n        \u003cli\u003e\u003ca href=\"#what-can-i-do-with-dfcx-scrapi\"\u003eWhat Can I Do with SCRAPI?\u003c/a\u003e\u003c/li\u003e\n        \u003cli\u003e\u003ca href=\"#built-with\"\u003eBuilt With\u003c/a\u003e\u003c/li\u003e\n      \u003c/ul\u003e\n    \u003c/li\u003e\n    \u003cli\u003e\n      \u003ca href=\"#getting-started\"\u003eGetting Started\u003c/a\u003e\n      \u003cul\u003e\n        \u003cli\u003e\u003ca href=\"#environment-setup\"\u003eEnvironment Setup\u003c/a\u003e\u003c/li\u003e\n        \u003cli\u003e\u003ca href=\"#authentication\"\u003eAuthentication\u003c/a\u003e\u003c/li\u003e\n      \u003c/ul\u003e\n    \u003c/li\u003e\n    \u003cli\u003e\u003ca href=\"#usage\"\u003eUsage\u003c/a\u003e\n    \u003cli\u003e\n      \u003ca href=\"#library-composition\"\u003eLibrary Composition\u003c/a\u003e\n      \u003cul\u003e\n        \u003cli\u003e\u003ca href=\"#core\"\u003eCore\u003c/a\u003e\u003c/li\u003e\n        \u003cli\u003e\u003ca href=\"#tools\"\u003eTools\u003c/a\u003e\u003c/li\u003e\n      \u003c/ul\u003e\n    \u003c/li\u003e\n    \u003cli\u003e\u003ca href=\"#contributing\"\u003eContributing\u003c/a\u003e\u003c/li\u003e\n    \u003cli\u003e\u003ca href=\"#license\"\u003eLicense\u003c/a\u003e\u003c/li\u003e\n    \u003cli\u003e\u003ca href=\"#contact\"\u003eContact\u003c/a\u003e\u003c/li\u003e\n    \u003cli\u003e\u003ca href=\"#acknowledgements\"\u003eAcknowledgements\u003c/a\u003e\u003c/li\u003e\n  \u003c/ol\u003e\n\u003c/details\u003e\n\n\u003c!-- INTRODUCTION --\u003e\n# Introduction\n\nThe Python Dialogflow CX Scripting API (DFCX SCRAPI) is a high level API that extends the official Google [Python Client for Dialogflow CX](https://github.com/googleapis/python-dialogflow-cx). SCRAPI makes using DFCX easier, more friendly, and more pythonic for bot builders, developers, and maintainers.\n\n```\nSCRAPI --\u003e Python Dialogflow CX\nas\nKeras --\u003e Tensorflow\n```\n\n## What Can I Do With DFCX SCRAPI?\nWith DFCX SCRAPI you can perform many bot building and maintenance actions at scale including, but not limited to:\n- Create, Update, Delete, Get, and List for all CX resources types (i.e. Intents, Entity Types, Pages, Flows, etc.)\n- Convert commonly accessed CX Resources to Pandas Dataframes\n- Have fully automated conversations with a CX agent (powerful for regression testing!)\n- Extract Validation information\n- Extract Change History information\n- Search across all Flows/Pages/Routes to find a specific parameter or utterance using Search Util functions\n- Quickly move CX resources between agents using Copy Util functions!\n- Build the fundamental protobuf objects that CX uses for each resource type using Builder methods\n- ...and much, much more!\n\n## Built With\n* Python 3.8+\n\n\n\u003c!-- AUTHENTICATION --\u003e\n# Authentication  \nAuthentication can vary depending on how and where you are interacting with SCRAPI.\n\n## Google Colab\nIf you're using SCRAPI with a [Google Colab](https://colab.research.google.com/) notebook, you can add the following to the top of your notebook for easy authentication:\n```py\nproject_id = '\u003cYOUR_GCP_PROJECT_ID\u003e'\n\n# this will launch an interactive prompt that allows you to auth with GCP in a browser\n!gcloud auth application-default login --no-launch-browser\n\n# this will set your active project to the `project_id` above\n!gcloud auth application-default set-quota-project $project_id\n```\n\nAfter 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!\nYou can then use SCRAPI simply like this:\n```py\nfrom dfcx_scrapi.core.intents import Intents\n\nagent_id = '\u003cYOUR_AGENT_ID\u003e'\ni = Intents() # \u003c-- Creds will be automatically picked up from the environment\nintents_map = i.get_intents_map(agent_id)\n```\n---\n## Cloud Functions / Cloud Run\nIf you're using SCRAPI with [Cloud Functions](https://cloud.google.com/functions) or [Cloud Run](https://cloud.google.com/run), SCRAPI can pick up on the default environment creds used by these services without any additional configuration! \n\n1. Add `dfcx-scrapi` to your `requirements.txt` file\n2. Ensure the Cloud Function / Cloud Run service account has the appropriate Dialogflow IAM Role\n\nOnce you are setup with the above, your function code can be used easily like this:\n```py\nfrom dfcx_scrapi.core.intents import Intents\n\nagent_id = '\u003cYOUR_AGENT_ID\u003e'\ni = Intents() # \u003c-- Creds will be automatically picked up from the environment\nintents_map = i.get_intents_map(agent_id)\n```\n\n---\n## Local Python Environment\nSimilar to Cloud Functions / Cloud Run, SCRAPI can pick up on your local authentication creds _if you are using the gcloud CLI._\n\n1. Install [gcloud CLI](https://cloud.google.com/sdk/docs/install).\n2. Run `gcloud init`.\n3. Run `gcloud auth login`\n4. Run `gcloud auth list` to ensure your principal account is active.\n\nThis will authenticate your principal GCP account with the gcloud CLI, and SCRAPI can pick up the creds from here.  \n\n---\n## Exceptions and Misc.\nThere are some classes in SCRAPI which still rely on Service Account Keys, notably the [DataframeFunctions](https://github.com/GoogleCloudPlatform/dfcx-scrapi/blob/main/src/dfcx_scrapi/tools/dataframe_functions.py) class due to how it authenticates with Google Sheets.\n\nIn order to use these functions, you will need a Service Account that has appropriate access to your GCP project.  \nFor more information and to view the official documentation for service accounts go to [Creating and Managing GCP Service Accounts](https://cloud.google.com/iam/docs/creating-managing-service-accounts).\n\nOnce you've obtained a Service Account Key with appropriate permissions, you can use it as follows:\n```py\nfrom dfcx_scrapi.core.intents import Intents\nfrom dfcx_scrapi.tools.dataframe_functions import DataframeFunctions\n\nagent_id = '\u003cYOUR_AGENT_ID\u003e'\ncreds_path = '\u003cPATH_TO_YOUR_SERVICE_ACCOUNT_JSON_FILE\u003e'\n\ni = Intents(creds_path=creds_path)\ndffx = DataframeFunctions(creds_path=creds_path)\n\ndf = i.bulk_intent_to_df(agent_id)\ndffx.dataframe_to_sheets('GOOGLE_SHEET_NAME', 'TAB_NAME', df)\n```\n\n\u003c!-- GETTING STARTED --\u003e\n# Getting Started\n## Environment Setup\nSet up Google Cloud Platform credentials and install dependencies.\n```sh\ngcloud auth login\ngcloud auth application-default login\ngcloud config set project \u003cproject name\u003e\n```\n```sh\npython3 -m venv venv\nsource ./venv/bin/activate\npip install -r requirements.txt\n```\n\n## Usage\nTo run a simple bit of code you can do the following:\n- Import a Class from `dfcx_scrapi.core`\n- Assign your Service Account to a local variable\n\n```python\nfrom dfcx_scrapi.core.intents import Intents\n\ncreds_path = '\u003cPATH_TO_YOUR_SERVICE_ACCOUNT_JSON_FILE\u003e'\nagent_path = '\u003cFULL_DFCX_AGENT_ID_PATH\u003e'\n\n# DFCX Agent ID paths are in this format:\n# 'projects/\u003cproject_id\u003e/locations/\u003clocation_id\u003e/agents/\u003cagent_id\u003e'\n\n# Instantiate your class object and pass in your credentials\ni = Intents(creds_path, agent_id=agent_path)\n\n# Retrieve all Intents and Training Phrases from an Agent and push to a Pandas DataFrame\ndf = i.bulk_intent_to_df()\n```\n\n# Library Composition\nHere is a brief overview of the SCRAPI library's structure and the motivation behind that structure.\n\n## Core  \nThe [Core](/src/dfcx_scrapi/core) folder is synonymous with the core Resource types in the DFCX Agents (agents, intents, flows, etc.)\n* This folder contains the high level building blocks of SCRAPI\n* These classes and methods can be used to build higher level methods or custom tools and applications\n\n## Tools\nThe [Tools](/src/dfcx_scrapi/tools) folder contains various customized toolkits that allow you to do more complex bot management tasks, such as\n- Manipulate Agent Resource types into various DataFrame structures\n- Copy Agent Resources between Agents and GCP Projects on a resource by resource level\n- Move data to and from DFCX and other GCP Services like BigQuery, Sheets, etc.\n- Create customized search queries inside of your agent resources\n\n## Builders\nThe [Builders](/src/dfcx_scrapi/builders) folder contains simple methods for constructing the underlying protos in Dialogflow CX\n- Proto objects are the fundamental building blocks of Dialogflow CX\n- Builder classes allow the user to construct Dialogflow CX resource _offline_ without any API calls\n- Once the resource components are constructed, they can then be pushed to a live Dialogflow CX agent via API\n\n\u003c!-- CONTRIBUTING --\u003e\n# Contributing\nWe welcome any contributions or feature requests you would like to submit!\n\n1. Fork the Project\n2. Create your Feature Branch (git checkout -b feature/AmazingFeature)\n3. Commit your Changes (git commit -m 'Add some AmazingFeature')\n4. Push to the Branch (git push origin feature/AmazingFeature)\n5. Open a Pull Request\n\n\u003c!-- LICENSE --\u003e\n# License\nDistributed under the Apache 2.0 License. See [LICENSE](LICENSE.txt) for more information.\n\n\u003c!-- CONTACT --\u003e\n# Contact\nPatrick Marlow - pmarlow@google.com  - [@kmaphoenix](https://github.com/kmaphoenix)  \nMilad Tabrizi - miladt@google.com - [@MRyderOC](https://github.com/MRyderOC)\n\nProject Link: [https://github.com/GoogleCloudPlatform/dfcx-scrapi](https://github.com/GoogleCloudPlatform/dfcx-scrapi)\n\n\u003c!-- ACKNOWLEDGEMENTS --\u003e\n# Acknowledgements\n[Dialogflow CX Python Client Library](https://github.com/googleapis/python-dialogflow-cx)   \n[Hugging Face - Pegasus Paraphrase](https://huggingface.co/tuner007/pegasus_paraphrase)\n\n\n\n\u003c!-- MARKDOWN LINKS \u0026 IMAGES --\u003e\n\u003c!-- https://www.markdownguide.org/basic-syntax/#reference-style-links --\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgooglecloudplatform%2Fdfcx-scrapi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgooglecloudplatform%2Fdfcx-scrapi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgooglecloudplatform%2Fdfcx-scrapi/lists"}