{"id":20612044,"url":"https://github.com/tcarrio/dialogflow-as-code","last_synced_at":"2025-06-16T03:13:19.770Z","repository":{"id":93830355,"uuid":"304980447","full_name":"tcarrio/dialogflow-as-code","owner":"tcarrio","description":"[Mirror] Declarative management of Dialogflow resources","archived":false,"fork":false,"pushed_at":"2020-10-18T00:14:12.000Z","size":156,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-04T19:54:56.722Z","etag":null,"topics":["automation","devops","dialogflow","nlp"],"latest_commit_sha":null,"homepage":"https://git.sr.ht/~tcarrio/dialogflow-as-code","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tcarrio.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2020-10-17T22:31:18.000Z","updated_at":"2020-10-18T00:14:14.000Z","dependencies_parsed_at":"2023-06-15T06:45:28.724Z","dependency_job_id":null,"html_url":"https://github.com/tcarrio/dialogflow-as-code","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/tcarrio/dialogflow-as-code","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tcarrio%2Fdialogflow-as-code","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tcarrio%2Fdialogflow-as-code/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tcarrio%2Fdialogflow-as-code/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tcarrio%2Fdialogflow-as-code/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tcarrio","download_url":"https://codeload.github.com/tcarrio/dialogflow-as-code/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tcarrio%2Fdialogflow-as-code/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260089911,"owners_count":22957151,"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":["automation","devops","dialogflow","nlp"],"created_at":"2024-11-16T10:23:03.901Z","updated_at":"2025-06-16T03:13:19.746Z","avatar_url":"https://github.com/tcarrio.png","language":"TypeScript","readme":"![npm (scoped)](https://img.shields.io/npm/v/@0xc/dialogflow-as-code)\n[![builds.sr.ht status](https://builds.sr.ht/~tcarrio/dialogflow-as-code/.build.yml.svg)](https://builds.sr.ht/~tcarrio/dialogflow-as-code/.build.yml?)\n[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)\n\n# dialogflow-as-code\n\nThis package allows the creation of Dialogflow resources by using the [nodejs-dialogflow](https://github.com/googleapis/nodejs-dialogflow) project along with the types we have helped define in [@types/dialogflow](https://www.npmjs.com/package/@types/dialogflow). It was developed using Node.js and TypeScript.\n\nThe builder helpers can be used for generating resources, however the module also allows for objects to be directly passed to the builder. The builders eventually generate the same types expected by the `nodejs-dialogflow` API, so whichever you find easier will work fine. For some of the more advanced types, it can be much easier to work with the builders. The following provides several examples of defining Dialogflow resources and how they eventually tie together to be created and synced to a Dialogflow agent:\n\n```ts\n// Sample Entity Type Builder\nexport const etFruit = entityType()\n  .d(\"fruit\")\n  .e([syn(\"apple\"), syn(\"strawberry\")])\n  .k(ek.list)\n  .build();\n```\n\n```ts\n// Sample Entity Type\nexport const etSample: EntityType = {\n  displayName: \"sample\",\n  entities: [{ value: \"sample\", synonyms: [\"piece\", \"swab\", \"choice\"] }],\n  kind: \"KIND_MAP\",\n  autoExpansionMode: \"AUTO_EXPANSION_MODE_DEFAULT\",\n};\n```\n\n```ts\n// Sample Context Builder\nexport const cxFruit = cx()\n  .n(\"fruit-context\")\n  .lc(5)\n  .p(\"date-time-original\", \"string_value\")\n  .build();\n```\n\n```ts\n// Sample Events\nexport enum Event {\n  FEEDBACK = \"FEEDBACK\",\n  YES = \"YES\",\n  NO = \"NO\",\n}\n```\n\n```ts\n// Sample Intent\n// prettier-ignore\nexport const ntFruitInfo = intent(\"fruitInfo\")\n  .priority(Priority.LOW)\n  .webhook(true)\n  .trainingPhrases([\n    tp([\"describe the \", pb(\"sample\"), \" of \", etFruit, \" over \", det(\"date-time\")]),\n    tp([\"how was the \", pb(\"sample\"), \" of \", etFruit]),\n    tp([pb(\"sample\"), \" of \", etFruit, \" \", det(\"date-time\")]),\n    tp([pb(\"sample\"), \" of \", etFruit]),\n    tp([\"what was the \", pb(\"sample\"), \"inputContextsf \", etFruit, \" \", det(\"date-time\"), \"?\"]),\n    tp([\"what was the \", pb(\"sample\"), \" of \", etFruit]),\n  ])\n  .messages([\n    msg(\"text\").set([\"I'm sorry Dave, I can't do that\"]).build(),\n    msg(\"text\").set([\"Second response\"]).build(),\n  ])\n  .events([Event.FEEDBACK])\n  .outputContexts([cxFruit])\n  .followUpOf(ntFruitReminder);\n```\n\n```ts\n// Sample Resource Build and Sync Script\nconst svcAcctKeyJson: string = \"./service-account-key.json\";\nconst svcAcctConfig: DialogflowServiceAccount = require(`.${svcAcctKeyJson}`);\nContainer.set(KEY_FILENAME, svcAcctKeyJson);\nContainer.set(DIALOGFLOW_CONFIG, svcAcctConfig);\n\nconst resources = Container.get(DialogflowBuilder)\n  .entityTypes([etSample, etFruit])\n  .intents([ntFruitInfo, ntFruitReminder])\n  .build();\n\nContainer.get(DialogflowCreator).sync(resources);\n```\n\n**Note**: You will need to create a service account on the Dialogflow website and provide it at the project level as `service-account-key.json`. The file path and config object are passed to the `DialogflowBuilder`. The path can be changed, this is just the sample and converted project expectations.\n\nIf you would like to to take it for a spin, you can run the provided project sample:\n\n```sh\ngit clone https://git.sr.ht/~tcarrio/dialogflow-as-code\npushd dialogflow-as-code\nnpm i\nnpm run sample\n```\n\n# dialogflow-converter\n\nThis project contains a module for converting resources exported from Dialogflow into resources for use by `dialogflow-as-code`. These are rudimentary at the moment, with future improvements planned for the templating structure and full feature-set of `dialogflow-as-code`.\n\nRun the conversion by calling `npm start -- -i $input_path -o $output_path`. It can also be directly invoked with `node`, by calling `node lib/converter/dialogflow-converter.js`.\n\nIf this package was installed, it is available at the `bin` directory of the installation scope (locally at `node_modules/.bin/dialogflow-as-code` or globally at `$NODE_HOME/bin/dialogflow-as-code`).\n\nThe easiest way to get started with building out a `dialogflow-as-code` project is to `npm i -g dialogflow-as-code`. With this available you can use its CLI to specify input and output directories for generating the code from an extracted Dialogflow export.\n\n```\nUsage: dialogflow-as-code [options]\n\nGenerate a Dialogflow-as-Code project from a Dialogflow export\n\nOptions:\n  -V, --version       output the version number\n  -o, --output \u003cdir\u003e  Output directory (default: ./output)\n  -i, --input \u003cdir\u003e   Input directory (default: ./input)\n  -h, --help          output usage information\n```\n\nThe converter also makes use of [prettier](https://www.npmjs.com/package/prettier) to format the project after its creation.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftcarrio%2Fdialogflow-as-code","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftcarrio%2Fdialogflow-as-code","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftcarrio%2Fdialogflow-as-code/lists"}