Built motion from commit 6a09e18b.|2.6.11
[motion2.git] / legacy-libs / dialogflow / README.md
1 [//]: # "This README.md file is auto-generated, all changes to this file will be lost."
2 [//]: # "To regenerate it, use `npm run generate-scaffolding`."
3 <img src="https://avatars2.githubusercontent.com/u/2810941?v=3&s=96" alt="Google Cloud Platform logo" title="Google Cloud Platform" align="right" height="96" width="96"/>
4
5 # [Dialogflow: Node.js Client](https://github.com/googleapis/nodejs-dialogflow)
6
7 [![release level](https://img.shields.io/badge/release%20level-beta-yellow.svg?style&#x3D;flat)](https://cloud.google.com/terms/launch-stages)
8 [![npm version](https://img.shields.io/npm/v/dialogflow.svg)](https://www.npmjs.org/package/dialogflow)
9 [![codecov](https://img.shields.io/codecov/c/github/googleapis/nodejs-dialogflow/master.svg?style=flat)](https://codecov.io/gh/googleapis/nodejs-dialogflow)
10
11 [Dialogflow](https://dialogflow.com/docs/reference/v2-agent-setup) is an enterprise-grade NLU platform that makes it easy for developers to design and integrate conversational user interfaces into mobile apps, web applications, devices, and bots.
12
13
14 * [Using the client library](#using-the-client-library)
15 * [Samples](#samples)
16 * [Versioning](#versioning)
17 * [Contributing](#contributing)
18 * [License](#license)
19
20 ## Using the client library
21
22 1.  [Select or create a Cloud Platform project][projects].
23
24 1.  [Enable billing for your project][billing].
25
26 1.  [Enable the Dialogflow API][enable_api].
27
28 1.  [Set up authentication with a service account][auth] so you can access the
29     API from your local workstation.
30
31 1. Install the client library:
32
33         npm install --save dialogflow
34
35 1. Try an example:
36
37 ```javascript
38
39 const dialogflow = require('dialogflow');
40 const uuid = require('uuid');
41
42 /**
43  * Send a query to the dialogflow agent, and return the query result.
44  * @param {string} projectId The project to be used
45  */
46 async function runSample(projectId = 'your-project-id') {
47   // A unique identifier for the given session
48   const sessionId = uuid.v4();
49
50   // Create a new session
51   const sessionClient = new dialogflow.SessionsClient();
52   const sessionPath = sessionClient.sessionPath(projectId, sessionId);
53
54   // The text query request.
55   const request = {
56     session: sessionPath,
57     queryInput: {
58       text: {
59         // The query to send to the dialogflow agent
60         text: 'hello',
61         // The language used by the client (en-US)
62         languageCode: 'en-US',
63       },
64     },
65   };
66
67   // Send request and log result
68   const responses = await sessionClient.detectIntent(request);
69   console.log('Detected intent');
70   const result = responses[0].queryResult;
71   console.log(`  Query: ${result.queryText}`);
72   console.log(`  Response: ${result.fulfillmentText}`);
73   if (result.intent) {
74     console.log(`  Intent: ${result.intent.displayName}`);
75   } else {
76     console.log(`  No intent matched.`);
77   }
78 }
79 ```
80
81 ## Samples
82
83 Samples are in the [`samples/`](https://github.com/googleapis/nodejs-dialogflow/tree/master/samples) directory. The samples' `README.md`
84 has instructions for running the samples.
85
86 | Sample                      | Source Code                       | Try it |
87 | --------------------------- | --------------------------------- | ------ |
88 | Detect Intent (Text) | [source code](https://github.com/googleapis/nodejs-dialogflow/blob/master/samples/detect.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-dialogflow&page=editor&open_in_editor=samples/detect.js,samples/README.md) |
89 | Create Knowledge Base | [source code](https://github.com/googleapis/nodejs-dialogflow/blob/master/samples/detect.v2beta1.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-dialogflow&page=editor&open_in_editor=samples/detect.v2beta1.js,samples/README.md) |
90 | Get Knowledge Base | [source code](https://github.com/googleapis/nodejs-dialogflow/blob/master/samples/detect.v2beta1.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-dialogflow&page=editor&open_in_editor=samples/detect.v2beta1.js,samples/README.md) |
91 | list Knowledge Base | [source code](https://github.com/googleapis/nodejs-dialogflow/blob/master/samples/detect.v2beta1.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-dialogflow&page=editor&open_in_editor=samples/detect.v2beta1.js,samples/README.md) |
92 | list Knowledge Base | [source code](https://github.com/googleapis/nodejs-dialogflow/blob/master/samples/detect.v2beta1.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-dialogflow&page=editor&open_in_editor=samples/detect.v2beta1.js,samples/README.md) |
93 | create Document | [source code](https://github.com/googleapis/nodejs-dialogflow/blob/master/samples/detect.v2beta1.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-dialogflow&page=editor&open_in_editor=samples/detect.v2beta1.js,samples/README.md) |
94 | list Documents | [source code](https://github.com/googleapis/nodejs-dialogflow/blob/master/samples/detect.v2beta1.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-dialogflow&page=editor&open_in_editor=samples/detect.v2beta1.js,samples/README.md) |
95 | Get Document | [source code](https://github.com/googleapis/nodejs-dialogflow/blob/master/samples/detect.v2beta1.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-dialogflow&page=editor&open_in_editor=samples/detect.v2beta1.js,samples/README.md) |
96 | delete Document | [source code](https://github.com/googleapis/nodejs-dialogflow/blob/master/samples/detect.v2beta1.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-dialogflow&page=editor&open_in_editor=samples/detect.v2beta1.js,samples/README.md) |
97 | detect Intent with sentiment analysis | [source code](https://github.com/googleapis/nodejs-dialogflow/blob/master/samples/detect.v2beta1.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-dialogflow&page=editor&open_in_editor=samples/detect.v2beta1.js,samples/README.md) |
98 | detect Intent with text-to-speech response | [source code](https://github.com/googleapis/nodejs-dialogflow/blob/master/samples/detect.v2beta1.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-dialogflow&page=editor&open_in_editor=samples/detect.v2beta1.js,samples/README.md) |
99 | detect Intent with Knowledge Base | [source code](https://github.com/googleapis/nodejs-dialogflow/blob/master/samples/detect.v2beta1.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-dialogflow&page=editor&open_in_editor=samples/detect.v2beta1.js,samples/README.md) |
100 | Detect Intent (Audio) | [source code](https://github.com/googleapis/nodejs-dialogflow/blob/master/samples/detect.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-dialogflow&page=editor&open_in_editor=samples/detect.js,samples/README.md) |
101 | Detect Intent (Streaming) | [source code](https://github.com/googleapis/nodejs-dialogflow/blob/master/samples/detect.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-dialogflow&page=editor&open_in_editor=samples/detect.js,samples/README.md) |
102 | Create Entity | [source code](https://github.com/googleapis/nodejs-dialogflow/blob/master/samples/resource.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-dialogflow&page=editor&open_in_editor=samples/resource.js,samples/README.md) |
103 | Delete Entity | [source code](https://github.com/googleapis/nodejs-dialogflow/blob/master/samples/resource.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-dialogflow&page=editor&open_in_editor=samples/resource.js,samples/README.md) |
104 | Create Intent | [source code](https://github.com/googleapis/nodejs-dialogflow/blob/master/samples/resource.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-dialogflow&page=editor&open_in_editor=samples/resource.js,samples/README.md) |
105 | Delete Intent | [source code](https://github.com/googleapis/nodejs-dialogflow/blob/master/samples/resource.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-dialogflow&page=editor&open_in_editor=samples/resource.js,samples/README.md) |
106 | Create Context | [source code](https://github.com/googleapis/nodejs-dialogflow/blob/master/samples/resource.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-dialogflow&page=editor&open_in_editor=samples/resource.js,samples/README.md) |
107 | Delete Context | [source code](https://github.com/googleapis/nodejs-dialogflow/blob/master/samples/resource.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-dialogflow&page=editor&open_in_editor=samples/resource.js,samples/README.md) |
108 | Create Session Entity Type | [source code](https://github.com/googleapis/nodejs-dialogflow/blob/master/samples/resource.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-dialogflow&page=editor&open_in_editor=samples/resource.js,samples/README.md) |
109 | Delete Session Entity Type | [source code](https://github.com/googleapis/nodejs-dialogflow/blob/master/samples/resource.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-dialogflow&page=editor&open_in_editor=samples/resource.js,samples/README.md) |
110
111 The [Dialogflow Node.js Client API Reference][client-docs] documentation
112 also contains samples.
113
114 ## Versioning
115
116 This library follows [Semantic Versioning](http://semver.org/).
117
118 This library is considered to be in **beta**. This means it is expected to be
119 mostly stable while we work toward a general availability release; however,
120 complete stability is not guaranteed. We will address issues and requests
121 against beta libraries with a high priority.
122
123 More Information: [Google Cloud Platform Launch Stages][launch_stages]
124
125 [launch_stages]: https://cloud.google.com/terms/launch-stages
126
127 ## Contributing
128
129 Contributions welcome! See the [Contributing Guide](https://github.com/googleapis/nodejs-dialogflow/blob/master/CONTRIBUTING.md).
130
131 ## License
132
133 Apache Version 2.0
134
135 See [LICENSE](https://github.com/googleapis/nodejs-dialogflow/blob/master/LICENSE)
136
137 ## What's Next
138
139 * [Dialogflow Documentation][product-docs]
140 * [Dialogflow Node.js Client API Reference][client-docs]
141 * [github.com/googleapis/nodejs-dialogflow](https://github.com/googleapis/nodejs-dialogflow)
142
143 Read more about the client libraries for Cloud APIs, including the older
144 Google APIs Client Libraries, in [Client Libraries Explained][explained].
145
146 [explained]: https://cloud.google.com/apis/docs/client-libraries-explained
147
148 [client-docs]: https://dialogflow.com/docs/reference/api-v2/rpc/
149 [product-docs]: https://dialogflow.com/docs/reference/api-v2/rpc/
150 [shell_img]: https://gstatic.com/cloudssh/images/open-btn.png
151 [projects]: https://console.cloud.google.com/project
152 [billing]: https://support.google.com/cloud/answer/6293499#enable-billing
153 [enable_api]: https://console.cloud.google.com/flows/enableapi?apiid=dialogflow.googleapis.com
154 [auth]: https://cloud.google.com/docs/authentication/getting-started