├── .github └── FUNDING.yml ├── LICENSE ├── README.md └── hosted ├── README.md ├── api.md ├── configuration.md ├── faq.md ├── images ├── 0*8iYHLAGC8Qc5APhY.png ├── 0*Bw3c0_7Az-MWc4gD.png ├── 0*ZtCBwK0pme7dkEUa.png ├── 1*0zPrr0SOtY9ulOXmWHhXig.png ├── 1*1P5DjCpGfLWgP6lQpoV7OA.png ├── 1*62QR5SouuxZH_n9U9epMkg.png ├── 1*NQdQk2PPVFOrxHa56Q_qqw.png ├── 1*Sax2IOrqX6_09FPS-kqLdA.gif ├── 1*XiohDWc7br_BH_nkjHsLVw.png ├── 1*aKTMHA4wygSZb67T2G3S6w.png ├── 1*bitGmbe8nlnrr4IX0Ipcew.png ├── 1*dIvJurZEmgizndXTGdlFBw.png ├── 1*g7d0ZMyE_ODPiwGqalT_wQ.png ├── 1*mPnKhb4JonFQprSGAMQEXA.png ├── blocked.png ├── chatbaseapikey.png ├── console.png ├── consolesettings.png ├── consolewebhook.png ├── embeddeduiurl.png ├── gatewayurl.png ├── gatewayurlrt.png ├── inboxemail.png ├── manageagent.png ├── uiurl.png ├── unlink.png ├── uploadkeys.png ├── virtualagentanalytics.png ├── virtualagentanalyticsapikey.png ├── webhookurl.png └── webhookurlexample.png ├── installation.md ├── integrations.md └── usage.md /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | custom: https://paypal.me/ushakovhq -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | GNU Free Documentation License 3 | Version 1.3, 3 November 2008 4 | 5 | 6 | Copyright (C) 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc. 7 | 8 | Everyone is permitted to copy and distribute verbatim copies 9 | of this license document, but changing it is not allowed. 10 | 11 | 0. PREAMBLE 12 | 13 | The purpose of this License is to make a manual, textbook, or other 14 | functional and useful document "free" in the sense of freedom: to 15 | assure everyone the effective freedom to copy and redistribute it, 16 | with or without modifying it, either commercially or noncommercially. 17 | Secondarily, this License preserves for the author and publisher a way 18 | to get credit for their work, while not being considered responsible 19 | for modifications made by others. 20 | 21 | This License is a kind of "copyleft", which means that derivative 22 | works of the document must themselves be free in the same sense. It 23 | complements the GNU General Public License, which is a copyleft 24 | license designed for free software. 25 | 26 | We have designed this License in order to use it for manuals for free 27 | software, because free software needs free documentation: a free 28 | program should come with manuals providing the same freedoms that the 29 | software does. But this License is not limited to software manuals; 30 | it can be used for any textual work, regardless of subject matter or 31 | whether it is published as a printed book. We recommend this License 32 | principally for works whose purpose is instruction or reference. 33 | 34 | 35 | 1. APPLICABILITY AND DEFINITIONS 36 | 37 | This License applies to any manual or other work, in any medium, that 38 | contains a notice placed by the copyright holder saying it can be 39 | distributed under the terms of this License. Such a notice grants a 40 | world-wide, royalty-free license, unlimited in duration, to use that 41 | work under the conditions stated herein. The "Document", below, 42 | refers to any such manual or work. Any member of the public is a 43 | licensee, and is addressed as "you". You accept the license if you 44 | copy, modify or distribute the work in a way requiring permission 45 | under copyright law. 46 | 47 | A "Modified Version" of the Document means any work containing the 48 | Document or a portion of it, either copied verbatim, or with 49 | modifications and/or translated into another language. 50 | 51 | A "Secondary Section" is a named appendix or a front-matter section of 52 | the Document that deals exclusively with the relationship of the 53 | publishers or authors of the Document to the Document's overall 54 | subject (or to related matters) and contains nothing that could fall 55 | directly within that overall subject. (Thus, if the Document is in 56 | part a textbook of mathematics, a Secondary Section may not explain 57 | any mathematics.) The relationship could be a matter of historical 58 | connection with the subject or with related matters, or of legal, 59 | commercial, philosophical, ethical or political position regarding 60 | them. 61 | 62 | The "Invariant Sections" are certain Secondary Sections whose titles 63 | are designated, as being those of Invariant Sections, in the notice 64 | that says that the Document is released under this License. If a 65 | section does not fit the above definition of Secondary then it is not 66 | allowed to be designated as Invariant. The Document may contain zero 67 | Invariant Sections. If the Document does not identify any Invariant 68 | Sections then there are none. 69 | 70 | The "Cover Texts" are certain short passages of text that are listed, 71 | as Front-Cover Texts or Back-Cover Texts, in the notice that says that 72 | the Document is released under this License. A Front-Cover Text may 73 | be at most 5 words, and a Back-Cover Text may be at most 25 words. 74 | 75 | A "Transparent" copy of the Document means a machine-readable copy, 76 | represented in a format whose specification is available to the 77 | general public, that is suitable for revising the document 78 | straightforwardly with generic text editors or (for images composed of 79 | pixels) generic paint programs or (for drawings) some widely available 80 | drawing editor, and that is suitable for input to text formatters or 81 | for automatic translation to a variety of formats suitable for input 82 | to text formatters. A copy made in an otherwise Transparent file 83 | format whose markup, or absence of markup, has been arranged to thwart 84 | or discourage subsequent modification by readers is not Transparent. 85 | An image format is not Transparent if used for any substantial amount 86 | of text. A copy that is not "Transparent" is called "Opaque". 87 | 88 | Examples of suitable formats for Transparent copies include plain 89 | ASCII without markup, Texinfo input format, LaTeX input format, SGML 90 | or XML using a publicly available DTD, and standard-conforming simple 91 | HTML, PostScript or PDF designed for human modification. Examples of 92 | transparent image formats include PNG, XCF and JPG. Opaque formats 93 | include proprietary formats that can be read and edited only by 94 | proprietary word processors, SGML or XML for which the DTD and/or 95 | processing tools are not generally available, and the 96 | machine-generated HTML, PostScript or PDF produced by some word 97 | processors for output purposes only. 98 | 99 | The "Title Page" means, for a printed book, the title page itself, 100 | plus such following pages as are needed to hold, legibly, the material 101 | this License requires to appear in the title page. For works in 102 | formats which do not have any title page as such, "Title Page" means 103 | the text near the most prominent appearance of the work's title, 104 | preceding the beginning of the body of the text. 105 | 106 | The "publisher" means any person or entity that distributes copies of 107 | the Document to the public. 108 | 109 | A section "Entitled XYZ" means a named subunit of the Document whose 110 | title either is precisely XYZ or contains XYZ in parentheses following 111 | text that translates XYZ in another language. (Here XYZ stands for a 112 | specific section name mentioned below, such as "Acknowledgements", 113 | "Dedications", "Endorsements", or "History".) To "Preserve the Title" 114 | of such a section when you modify the Document means that it remains a 115 | section "Entitled XYZ" according to this definition. 116 | 117 | The Document may include Warranty Disclaimers next to the notice which 118 | states that this License applies to the Document. These Warranty 119 | Disclaimers are considered to be included by reference in this 120 | License, but only as regards disclaiming warranties: any other 121 | implication that these Warranty Disclaimers may have is void and has 122 | no effect on the meaning of this License. 123 | 124 | 2. VERBATIM COPYING 125 | 126 | You may copy and distribute the Document in any medium, either 127 | commercially or noncommercially, provided that this License, the 128 | copyright notices, and the license notice saying this License applies 129 | to the Document are reproduced in all copies, and that you add no 130 | other conditions whatsoever to those of this License. You may not use 131 | technical measures to obstruct or control the reading or further 132 | copying of the copies you make or distribute. However, you may accept 133 | compensation in exchange for copies. If you distribute a large enough 134 | number of copies you must also follow the conditions in section 3. 135 | 136 | You may also lend copies, under the same conditions stated above, and 137 | you may publicly display copies. 138 | 139 | 140 | 3. COPYING IN QUANTITY 141 | 142 | If you publish printed copies (or copies in media that commonly have 143 | printed covers) of the Document, numbering more than 100, and the 144 | Document's license notice requires Cover Texts, you must enclose the 145 | copies in covers that carry, clearly and legibly, all these Cover 146 | Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on 147 | the back cover. Both covers must also clearly and legibly identify 148 | you as the publisher of these copies. The front cover must present 149 | the full title with all words of the title equally prominent and 150 | visible. You may add other material on the covers in addition. 151 | Copying with changes limited to the covers, as long as they preserve 152 | the title of the Document and satisfy these conditions, can be treated 153 | as verbatim copying in other respects. 154 | 155 | If the required texts for either cover are too voluminous to fit 156 | legibly, you should put the first ones listed (as many as fit 157 | reasonably) on the actual cover, and continue the rest onto adjacent 158 | pages. 159 | 160 | If you publish or distribute Opaque copies of the Document numbering 161 | more than 100, you must either include a machine-readable Transparent 162 | copy along with each Opaque copy, or state in or with each Opaque copy 163 | a computer-network location from which the general network-using 164 | public has access to download using public-standard network protocols 165 | a complete Transparent copy of the Document, free of added material. 166 | If you use the latter option, you must take reasonably prudent steps, 167 | when you begin distribution of Opaque copies in quantity, to ensure 168 | that this Transparent copy will remain thus accessible at the stated 169 | location until at least one year after the last time you distribute an 170 | Opaque copy (directly or through your agents or retailers) of that 171 | edition to the public. 172 | 173 | It is requested, but not required, that you contact the authors of the 174 | Document well before redistributing any large number of copies, to 175 | give them a chance to provide you with an updated version of the 176 | Document. 177 | 178 | 179 | 4. MODIFICATIONS 180 | 181 | You may copy and distribute a Modified Version of the Document under 182 | the conditions of sections 2 and 3 above, provided that you release 183 | the Modified Version under precisely this License, with the Modified 184 | Version filling the role of the Document, thus licensing distribution 185 | and modification of the Modified Version to whoever possesses a copy 186 | of it. In addition, you must do these things in the Modified Version: 187 | 188 | A. Use in the Title Page (and on the covers, if any) a title distinct 189 | from that of the Document, and from those of previous versions 190 | (which should, if there were any, be listed in the History section 191 | of the Document). You may use the same title as a previous version 192 | if the original publisher of that version gives permission. 193 | B. List on the Title Page, as authors, one or more persons or entities 194 | responsible for authorship of the modifications in the Modified 195 | Version, together with at least five of the principal authors of the 196 | Document (all of its principal authors, if it has fewer than five), 197 | unless they release you from this requirement. 198 | C. State on the Title page the name of the publisher of the 199 | Modified Version, as the publisher. 200 | D. Preserve all the copyright notices of the Document. 201 | E. Add an appropriate copyright notice for your modifications 202 | adjacent to the other copyright notices. 203 | F. Include, immediately after the copyright notices, a license notice 204 | giving the public permission to use the Modified Version under the 205 | terms of this License, in the form shown in the Addendum below. 206 | G. Preserve in that license notice the full lists of Invariant Sections 207 | and required Cover Texts given in the Document's license notice. 208 | H. Include an unaltered copy of this License. 209 | I. Preserve the section Entitled "History", Preserve its Title, and add 210 | to it an item stating at least the title, year, new authors, and 211 | publisher of the Modified Version as given on the Title Page. If 212 | there is no section Entitled "History" in the Document, create one 213 | stating the title, year, authors, and publisher of the Document as 214 | given on its Title Page, then add an item describing the Modified 215 | Version as stated in the previous sentence. 216 | J. Preserve the network location, if any, given in the Document for 217 | public access to a Transparent copy of the Document, and likewise 218 | the network locations given in the Document for previous versions 219 | it was based on. These may be placed in the "History" section. 220 | You may omit a network location for a work that was published at 221 | least four years before the Document itself, or if the original 222 | publisher of the version it refers to gives permission. 223 | K. For any section Entitled "Acknowledgements" or "Dedications", 224 | Preserve the Title of the section, and preserve in the section all 225 | the substance and tone of each of the contributor acknowledgements 226 | and/or dedications given therein. 227 | L. Preserve all the Invariant Sections of the Document, 228 | unaltered in their text and in their titles. Section numbers 229 | or the equivalent are not considered part of the section titles. 230 | M. Delete any section Entitled "Endorsements". Such a section 231 | may not be included in the Modified Version. 232 | N. Do not retitle any existing section to be Entitled "Endorsements" 233 | or to conflict in title with any Invariant Section. 234 | O. Preserve any Warranty Disclaimers. 235 | 236 | If the Modified Version includes new front-matter sections or 237 | appendices that qualify as Secondary Sections and contain no material 238 | copied from the Document, you may at your option designate some or all 239 | of these sections as invariant. To do this, add their titles to the 240 | list of Invariant Sections in the Modified Version's license notice. 241 | These titles must be distinct from any other section titles. 242 | 243 | You may add a section Entitled "Endorsements", provided it contains 244 | nothing but endorsements of your Modified Version by various 245 | parties--for example, statements of peer review or that the text has 246 | been approved by an organization as the authoritative definition of a 247 | standard. 248 | 249 | You may add a passage of up to five words as a Front-Cover Text, and a 250 | passage of up to 25 words as a Back-Cover Text, to the end of the list 251 | of Cover Texts in the Modified Version. Only one passage of 252 | Front-Cover Text and one of Back-Cover Text may be added by (or 253 | through arrangements made by) any one entity. If the Document already 254 | includes a cover text for the same cover, previously added by you or 255 | by arrangement made by the same entity you are acting on behalf of, 256 | you may not add another; but you may replace the old one, on explicit 257 | permission from the previous publisher that added the old one. 258 | 259 | The author(s) and publisher(s) of the Document do not by this License 260 | give permission to use their names for publicity for or to assert or 261 | imply endorsement of any Modified Version. 262 | 263 | 264 | 5. COMBINING DOCUMENTS 265 | 266 | You may combine the Document with other documents released under this 267 | License, under the terms defined in section 4 above for modified 268 | versions, provided that you include in the combination all of the 269 | Invariant Sections of all of the original documents, unmodified, and 270 | list them all as Invariant Sections of your combined work in its 271 | license notice, and that you preserve all their Warranty Disclaimers. 272 | 273 | The combined work need only contain one copy of this License, and 274 | multiple identical Invariant Sections may be replaced with a single 275 | copy. If there are multiple Invariant Sections with the same name but 276 | different contents, make the title of each such section unique by 277 | adding at the end of it, in parentheses, the name of the original 278 | author or publisher of that section if known, or else a unique number. 279 | Make the same adjustment to the section titles in the list of 280 | Invariant Sections in the license notice of the combined work. 281 | 282 | In the combination, you must combine any sections Entitled "History" 283 | in the various original documents, forming one section Entitled 284 | "History"; likewise combine any sections Entitled "Acknowledgements", 285 | and any sections Entitled "Dedications". You must delete all sections 286 | Entitled "Endorsements". 287 | 288 | 289 | 6. COLLECTIONS OF DOCUMENTS 290 | 291 | You may make a collection consisting of the Document and other 292 | documents released under this License, and replace the individual 293 | copies of this License in the various documents with a single copy 294 | that is included in the collection, provided that you follow the rules 295 | of this License for verbatim copying of each of the documents in all 296 | other respects. 297 | 298 | You may extract a single document from such a collection, and 299 | distribute it individually under this License, provided you insert a 300 | copy of this License into the extracted document, and follow this 301 | License in all other respects regarding verbatim copying of that 302 | document. 303 | 304 | 305 | 7. AGGREGATION WITH INDEPENDENT WORKS 306 | 307 | A compilation of the Document or its derivatives with other separate 308 | and independent documents or works, in or on a volume of a storage or 309 | distribution medium, is called an "aggregate" if the copyright 310 | resulting from the compilation is not used to limit the legal rights 311 | of the compilation's users beyond what the individual works permit. 312 | When the Document is included in an aggregate, this License does not 313 | apply to the other works in the aggregate which are not themselves 314 | derivative works of the Document. 315 | 316 | If the Cover Text requirement of section 3 is applicable to these 317 | copies of the Document, then if the Document is less than one half of 318 | the entire aggregate, the Document's Cover Texts may be placed on 319 | covers that bracket the Document within the aggregate, or the 320 | electronic equivalent of covers if the Document is in electronic form. 321 | Otherwise they must appear on printed covers that bracket the whole 322 | aggregate. 323 | 324 | 325 | 8. TRANSLATION 326 | 327 | Translation is considered a kind of modification, so you may 328 | distribute translations of the Document under the terms of section 4. 329 | Replacing Invariant Sections with translations requires special 330 | permission from their copyright holders, but you may include 331 | translations of some or all Invariant Sections in addition to the 332 | original versions of these Invariant Sections. You may include a 333 | translation of this License, and all the license notices in the 334 | Document, and any Warranty Disclaimers, provided that you also include 335 | the original English version of this License and the original versions 336 | of those notices and disclaimers. In case of a disagreement between 337 | the translation and the original version of this License or a notice 338 | or disclaimer, the original version will prevail. 339 | 340 | If a section in the Document is Entitled "Acknowledgements", 341 | "Dedications", or "History", the requirement (section 4) to Preserve 342 | its Title (section 1) will typically require changing the actual 343 | title. 344 | 345 | 346 | 9. TERMINATION 347 | 348 | You may not copy, modify, sublicense, or distribute the Document 349 | except as expressly provided under this License. Any attempt 350 | otherwise to copy, modify, sublicense, or distribute it is void, and 351 | will automatically terminate your rights under this License. 352 | 353 | However, if you cease all violation of this License, then your license 354 | from a particular copyright holder is reinstated (a) provisionally, 355 | unless and until the copyright holder explicitly and finally 356 | terminates your license, and (b) permanently, if the copyright holder 357 | fails to notify you of the violation by some reasonable means prior to 358 | 60 days after the cessation. 359 | 360 | Moreover, your license from a particular copyright holder is 361 | reinstated permanently if the copyright holder notifies you of the 362 | violation by some reasonable means, this is the first time you have 363 | received notice of violation of this License (for any work) from that 364 | copyright holder, and you cure the violation prior to 30 days after 365 | your receipt of the notice. 366 | 367 | Termination of your rights under this section does not terminate the 368 | licenses of parties who have received copies or rights from you under 369 | this License. If your rights have been terminated and not permanently 370 | reinstated, receipt of a copy of some or all of the same material does 371 | not give you any rights to use it. 372 | 373 | 374 | 10. FUTURE REVISIONS OF THIS LICENSE 375 | 376 | The Free Software Foundation may publish new, revised versions of the 377 | GNU Free Documentation License from time to time. Such new versions 378 | will be similar in spirit to the present version, but may differ in 379 | detail to address new problems or concerns. See 380 | https://www.gnu.org/licenses/. 381 | 382 | Each version of the License is given a distinguishing version number. 383 | If the Document specifies that a particular numbered version of this 384 | License "or any later version" applies to it, you have the option of 385 | following the terms and conditions either of that specified version or 386 | of any later version that has been published (not as a draft) by the 387 | Free Software Foundation. If the Document does not specify a version 388 | number of this License, you may choose any version ever published (not 389 | as a draft) by the Free Software Foundation. If the Document 390 | specifies that a proxy can decide which future versions of this 391 | License can be used, that proxy's public statement of acceptance of a 392 | version permanently authorizes you to choose that version for the 393 | Document. 394 | 395 | 11. RELICENSING 396 | 397 | "Massive Multiauthor Collaboration Site" (or "MMC Site") means any 398 | World Wide Web server that publishes copyrightable works and also 399 | provides prominent facilities for anybody to edit those works. A 400 | public wiki that anybody can edit is an example of such a server. A 401 | "Massive Multiauthor Collaboration" (or "MMC") contained in the site 402 | means any set of copyrightable works thus published on the MMC site. 403 | 404 | "CC-BY-SA" means the Creative Commons Attribution-Share Alike 3.0 405 | license published by Creative Commons Corporation, a not-for-profit 406 | corporation with a principal place of business in San Francisco, 407 | California, as well as future copyleft versions of that license 408 | published by that same organization. 409 | 410 | "Incorporate" means to publish or republish a Document, in whole or in 411 | part, as part of another Document. 412 | 413 | An MMC is "eligible for relicensing" if it is licensed under this 414 | License, and if all works that were first published under this License 415 | somewhere other than this MMC, and subsequently incorporated in whole or 416 | in part into the MMC, (1) had no cover texts or invariant sections, and 417 | (2) were thus incorporated prior to November 1, 2008. 418 | 419 | The operator of an MMC Site may republish an MMC contained in the site 420 | under CC-BY-SA on the same site at any time before August 1, 2009, 421 | provided the MMC is eligible for relicensing. 422 | 423 | 424 | ADDENDUM: How to use this License for your documents 425 | 426 | To use this License in a document you have written, include a copy of 427 | the License in the document and put the following copyright and 428 | license notices just after the title page: 429 | 430 | Copyright (c) YEAR YOUR NAME. 431 | Permission is granted to copy, distribute and/or modify this document 432 | under the terms of the GNU Free Documentation License, Version 1.3 433 | or any later version published by the Free Software Foundation; 434 | with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. 435 | A copy of the license is included in the section entitled "GNU 436 | Free Documentation License". 437 | 438 | If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts, 439 | replace the "with...Texts." line with this: 440 | 441 | with the Invariant Sections being LIST THEIR TITLES, with the 442 | Front-Cover Texts being LIST, and with the Back-Cover Texts being LIST. 443 | 444 | If you have Invariant Sections without Cover Texts, or some other 445 | combination of the three, merge those two alternatives to suit the 446 | situation. 447 | 448 | If your document contains nontrivial examples of program code, we 449 | recommend releasing these examples in parallel under your choice of 450 | free software license, such as the GNU General Public License, 451 | to permit their use in free software. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Dialogflow Gateway 2 | 3 | ![Dialogflow Gateway schema](https://svgur.com/i/EHv.svg) 4 | 5 | Dialogflow Gateway is a backend enabling third-party integrations to securely access the Dialogflow V2 API. Any server, that implements the API (see below) can be refered as "Dialogflow Gateway" 6 | 7 | ## Contents 8 | 9 | - [API](#api) 10 | - [Response Codes](#response-codes) 11 | - [Errors](#errors) 12 | - [Endpoints](#endpoints) 13 | - [Base Endpoint](#base-endpoint) 14 | - [Base Endpoint Variables](#base-endpoint-variables) 15 | - [Base Endpoint Example](#base-endpoint-example) 16 | - [Requests](#requests) 17 | - [Retrieving Agents](#retrieving-agents) 18 | - [Request](#request) 19 | - [Request Variables](#request-variables) 20 | - [Response Body](#response-body) 21 | - [Example Request](#example-request) 22 | - [Example Response](#example-response) 23 | - [Detecting Intents](#detecting-intents) 24 | - [Request](#request-1) 25 | - [Request Variables](#request-variables-1) 26 | - [Request Body](#request-body) 27 | - [Response Body](#response-body-1) 28 | - [Example Request](#example-request-1) 29 | - [Example Response](#example-response-1) 30 | - [Realtime API](#realtime-api) 31 | - [Close Codes](#close-codes) 32 | - [Errors](#errors-1) 33 | - [Endpoints](#endpoints) 34 | - [Base Endpoint](#base-endpoint-1) 35 | - [Base Endpoint Variables](#base-endpoint-variables-1) 36 | - [Base Endpoint Example](#base-endpoint-example-1) 37 | - [Requests](#requests-1) 38 | - [Detecting Intents](#detecting-intents-1) 39 | - [Request](#request-2) 40 | - [Request Variables](#request-variables-2) 41 | - [Request Body](#request-body-1) 42 | - [Response Body](#response-body-2) 43 | - [Example Request](#example-request-2) 44 | - [Example Response](#example-response-2) 45 | - [Implementations](#implementations) 46 | - [Contact](#contact) 47 | 48 | ## API 49 | 50 | ### Response Codes 51 | 52 | | HTTP-Code | Reason | 53 | |-----------|--------------------------------------------------------------------------------| 54 | | 200 | Request was successful | 55 | | 400 | The request body or session ID is invalid and/or missing | 56 | | 403 | The deployment was blocked or the service account key is no longer valid | 57 | | 404 | The deployment was not found | 58 | | 500 | Internal server error | 59 | | 503 | The service is unavailable | 60 | 61 | ### Errors 62 | 63 | Example JSON response, containing error 64 | 65 | ```json 66 | {"error": "Deployment was not found", "code": 404} 67 | ``` 68 | 69 | ### Endpoints 70 | 71 | #### Base Endpoint 72 | 73 | Single-Agent scenario 74 | 75 | ``` 76 | https://.com 77 | ``` 78 | 79 | Multi-Agent scenario using wildcard subdomain 80 | 81 | ``` 82 | https://.example.com 83 | ``` 84 | 85 | Multi-Agent scenario using path parameter 86 | 87 | ``` 88 | https://example.com/ 89 | ``` 90 | 91 | Multi-Agent scenario using query parameter 92 | 93 | ``` 94 | https://example.com?agent= 95 | ``` 96 | 97 | #### Base Endpoint Variables 98 | 99 | | Variable | Description | 100 | |------------|------------------------------| 101 | | PROJECT_ID | Required, Project Identifier | 102 | 103 | #### Base Endpoint Example 104 | 105 | Multi-Agent scenario using wildcard subdomain on Dialogflow Gateway by Ushakov (Hosted) 106 | 107 | ``` 108 | https://dialogflow-web-v2.gateway.dialogflow.cloud.ushakov.co 109 | ``` 110 | 111 | ## Requests 112 | 113 | #### Retrieving Agents 114 | 115 | #### Request 116 | 117 | ```http 118 | GET 119 | ``` 120 | 121 | #### Request Variables 122 | 123 | | Variable | Description | 124 | |---------------|-----------------------------| 125 | | BASE_ENDPOINT | Required, Endpoint of Agent | 126 | 127 | #### Response Body 128 | 129 | [Agent](https://cloud.google.com/dialogflow/docs/reference/rest/v2beta1/projects.agent) 130 | 131 | #### Example Request 132 | 133 | Multi-Agent scenario using wildcard subdomain on Dialogflow Gateway by Ushakov (Hosted) 134 | 135 | ```http 136 | GET https://dialogflow-web-v2.gateway.dialogflow.cloud.ushakov.co 137 | ``` 138 | 139 | #### Example Response 140 | 141 | ```json 142 | { 143 | "parent": "projects/dialogflow-web-v2", 144 | "displayName": "DialogflowWebV2", 145 | "defaultLanguageCode": "en", 146 | "supportedLanguageCodes": [ 147 | "ru" 148 | ], 149 | "timeZone": "Europe/Madrid", 150 | "description": "This is a unofficial Progressive Web Application for Dialogflow V2, with support for rich-responses and amazing features you need to check out. Choose your language and send Hello to get started", 151 | "avatarUri": "https://storage.googleapis.com/cloudprod-apiai/ce408f19-7966-487d-8614-f5b1f0474ba6_x.png", 152 | "enableLogging": true, 153 | "matchMode": "MATCH_MODE_HYBRID", 154 | "classificationThreshold": 0.3 155 | } 156 | ``` 157 | 158 | ### Detecting Intents 159 | 160 | #### Request 161 | 162 | ```http 163 | POST 164 | ``` 165 | 166 | #### Request Variables 167 | 168 | | Variable | Description | 169 | |----------|-------------| 170 | | BASE_ENDPOINT | Required, Endpoint of Agent | 171 | 172 | #### Request Body 173 | 174 | [DetectIntentRequest](https://cloud.google.com/dialogflow/docs/reference/rpc/google.cloud.dialogflow.v2#google.cloud.dialogflow.v2.DetectIntentRequest) 175 | 176 | #### Response Body 177 | 178 | [DetectIntentResponse](https://cloud.google.com/dialogflow/docs/reference/rest/v2beta1/DetectIntentResponse) 179 | 180 | #### Example Request 181 | 182 | Multi-Agent scenario using wildcard subdomain on Dialogflow Gateway by Ushakov (Hosted) 183 | 184 | ```http 185 | POST https://app-of-the-day-9a9f6.gateway.dialogflow.cloud.ushakov.co 186 | Content-Type: application/json 187 | 188 | { 189 | "session": "test", 190 | "queryInput": { 191 | "text": { 192 | "text": "Hello", 193 | "languageCode": "en" 194 | } 195 | } 196 | } 197 | ``` 198 | 199 | #### Example Response 200 | 201 | ```json 202 | { 203 | "responseId": "85c3d6bd-6f8c-4000-a1ec-fdd6f636b2e8", 204 | "queryResult": { 205 | "queryText": "Hello", 206 | "action": "input.welcome", 207 | "parameters": {}, 208 | "allRequiredParamsPresent": true, 209 | "fulfillmentText": "Cannot display response in Dialogflow simulator. Please test on the Google Assistant simulator instead.", 210 | "fulfillmentMessages": [...], 211 | "webhookPayload": {...}, 212 | "intent": { 213 | "name": "projects/app-of-the-day-9a9f6/agent/intents/1e00bd68-62f0-4b8e-9cdd-a81c19f73855", 214 | "displayName": "Default Welcome Intent" 215 | }, 216 | "intentDetectionConfidence": 1, 217 | "diagnosticInfo": { 218 | "end_conversation": true, 219 | "webhook_latency_ms": 187 220 | }, 221 | "languageCode": "en" 222 | }, 223 | "webhookStatus": { 224 | "message": "Webhook execution successful" 225 | } 226 | } 227 | ``` 228 | 229 | ## Realtime API 230 | 231 | Realtime API implements [Secure WebSocket](https://en.wikipedia.org/wiki/WebSocket) communication between Dialogflow Gateway and the clients 232 | 233 | ### Close Codes 234 | 235 | | Code | Reason | 236 | |-----------|----------------------------------------------------------------------------| 237 | | 4400 | The request body or session ID is invalid and/or missing | 238 | | 4403 | The deployment was blocked or the service account key is no longer valid | 239 | | 4404 | The deployment was not found | 240 | | 4500 | Internal server error | 241 | 242 | ### Errors 243 | 244 | Example error: 245 | 246 | ``` 247 | 4404 'Deployment was not found' 248 | ``` 249 | 250 | ### Endpoints 251 | 252 | #### Base Endpoint 253 | 254 | Single-Agent scenario 255 | 256 | ``` 257 | wss://.com 258 | ``` 259 | 260 | Multi-Agent scenario using wildcard subdomain 261 | 262 | ``` 263 | wss://.example.com 264 | ``` 265 | 266 | Multi-Agent scenario using path parameter 267 | 268 | ``` 269 | wss://example.com/ 270 | ``` 271 | 272 | Multi-Agent scenario using query parameter 273 | 274 | ``` 275 | wss://example.com?agent= 276 | ``` 277 | 278 | #### Base Endpoint Variables 279 | 280 | | Variable | Description | 281 | |------------|------------------------------| 282 | | PROJECT_ID | Required, Project Identifier | 283 | 284 | #### Base Endpoint Example 285 | 286 | Multi-Agent scenario using wildcard subdomain on Dialogflow Gateway by Ushakov (Hosted) 287 | 288 | ``` 289 | wss://dialogflow-web-v2.gateway.dialogflow.cloud.ushakov.co 290 | ``` 291 | 292 | ## Requests 293 | 294 | ### Detecting Intents 295 | 296 | #### Request 297 | 298 | ```http 299 | POST 300 | ``` 301 | 302 | #### Request Variables 303 | 304 | | Variable | Description | 305 | |----------|-------------| 306 | | BASE_ENDPOINT | Required, Endpoint of Agent | 307 | 308 | #### Request Body 309 | 310 | [DetectIntentRequest](https://cloud.google.com/dialogflow/docs/reference/rpc/google.cloud.dialogflow.v2#google.cloud.dialogflow.v2.DetectIntentRequest) 311 | 312 | #### Response Body 313 | 314 | [DetectIntentResponse](https://cloud.google.com/dialogflow/docs/reference/rest/v2beta1/DetectIntentResponse) 315 | 316 | #### Example Request 317 | 318 | Note: The examples are using NodeJS 319 | 320 | Multi-Agent scenario using wildcard subdomain on Dialogflow Gateway by Ushakov (Hosted) 321 | 322 | ```js 323 | const WebSocket = require('ws') 324 | const ws = new WebSocket('ws://app-of-the-day-9a9f6.gateway.dialogflow.cloud.ushakov.co') 325 | 326 | ws.send( 327 | JSON.stringify({ 328 | session: "123", 329 | queryInput: { 330 | text: { 331 | text: "Hello", 332 | languageCode: "en" 333 | } 334 | } 335 | }) 336 | ) 337 | 338 | ws.on('message', data => { 339 | console.log(data) 340 | }) 341 | 342 | ws.on('close', (code, error) => { 343 | console.log(code, error) 344 | }) 345 | ``` 346 | 347 | #### Example Response 348 | 349 | ```json 350 | { 351 | "responseId": "85c3d6bd-6f8c-4000-a1ec-fdd6f636b2e8", 352 | "queryResult": { 353 | "queryText": "Hello", 354 | "action": "input.welcome", 355 | "parameters": {}, 356 | "allRequiredParamsPresent": true, 357 | "fulfillmentText": "Cannot display response in Dialogflow simulator. Please test on the Google Assistant simulator instead.", 358 | "fulfillmentMessages": [...], 359 | "webhookPayload": {...}, 360 | "intent": { 361 | "name": "projects/app-of-the-day-9a9f6/agent/intents/1e00bd68-62f0-4b8e-9cdd-a81c19f73855", 362 | "displayName": "Default Welcome Intent" 363 | }, 364 | "intentDetectionConfidence": 1, 365 | "diagnosticInfo": { 366 | "end_conversation": true, 367 | "webhook_latency_ms": 187 368 | }, 369 | "languageCode": "en" 370 | }, 371 | "webhookStatus": { 372 | "message": "Webhook execution successful" 373 | } 374 | } 375 | ``` 376 | 377 | ## Implementations 378 | 379 | | Title | Developer | Status | Homepage | Features | Cloud-based? | 380 | |-----------------------------------------|-----------|-----------------------------|--------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------|--------------| 381 | | Dialogflow Gateway (Hosted) | Ushakov | Stable, actively maintained | https://dialogflow.cloud.ushakov.co | Support, free updates, uptime guarantees, disaster recovery, dashboard, built-in integrations, pay-per-use, free quota | Yes | 382 | | Dialogflow Gateway (Enterprise Edition) | Ushakov | TBA | https://dialogflow.cloud.ushakov.co | Self-hosted, premium support, free updates | No | 383 | | Fulfillment Tester | Ushakov | Testing | https://github.com/mishushakov/dialogflow-fulfillment-tester | For testing purposes only | No | 384 | 385 | [Submit your implementation](https://github.com/mishushakov/dialogflow-gateway-docs/pulls) 386 | 387 | ## Contact 388 | 389 | If you have any questions or troubles regarding the API, please [contact us](https://ushakov.co/#contact) -------------------------------------------------------------------------------- /hosted/README.md: -------------------------------------------------------------------------------- 1 | # Dialogflow Gateway by Ushakov (Hosted) 2 | 3 | This directory contains documentation of the [Dialogflow Gateway by Ushakov (Hosted)](https://dialogflow.cloud.ushakov.co) 4 | 5 | - [Installation](installation.md) 6 | - [Configuration](configuration.md) 7 | - [API](api.md) 8 | - [Usage](usage.md) 9 | - [Integrations](integrations.md) 10 | - [FAQ](faq.md) -------------------------------------------------------------------------------- /hosted/api.md: -------------------------------------------------------------------------------- 1 | # Dialogflow Gateway by Ushakov (Hosted) API 2 | 3 | ## Contents 4 | 5 | - [API](#api) 6 | - [Response Codes](#response-codes) 7 | - [Errors](#errors) 8 | - [Endpoints](#endpoints) 9 | - [Base Endpoint](#base-endpoint) 10 | - [Base Endpoint Variables](#base-endpoint-variables) 11 | - [Base Endpoint Example](#base-endpoint-example) 12 | - [Requests](#requests) 13 | - [Retrieving Agents](#retrieving-agents) 14 | - [Request](#request) 15 | - [Request Variables](#request-variables) 16 | - [Response Body](#response-body) 17 | - [Example Request](#example-request) 18 | - [Example Response](#example-response) 19 | - [Detecting Intents](#detecting-intents) 20 | - [Request](#request-1) 21 | - [Request Variables](#request-variables-1) 22 | - [Request Body](#request-body) 23 | - [Response Body](#response-body-1) 24 | - [Example Request](#example-request-1) 25 | - [Example Response](#example-response-1) 26 | - [Realtime API](#realtime-api) 27 | - [Close Codes](#close-codes) 28 | - [Errors](#errors-1) 29 | - [Endpoints](#endpoints) 30 | - [Base Endpoint](#base-endpoint-1) 31 | - [Base Endpoint Variables](#base-endpoint-variables-1) 32 | - [Base Endpoint Example](#base-endpoint-example-1) 33 | - [Requests](#requests-1) 34 | - [Detecting Intents](#detecting-intents-1) 35 | - [Request](#request-2) 36 | - [Request Variables](#request-variables-2) 37 | - [Request Body](#request-body-1) 38 | - [Response Body](#response-body-2) 39 | - [Example Request](#example-request-2) 40 | - [Example Response](#example-response-2) 41 | - [Contact](#contact) 42 | 43 | ## API 44 | 45 | ### Response Codes 46 | 47 | | HTTP-Code | Reason | 48 | |-----------|--------------------------------------------------------------------------------| 49 | | 200 | Request was successful | 50 | | 400 | The request body or session ID is invalid and/or missing | 51 | | 403 | The deployment was blocked or the service account key is no longer valid | 52 | | 404 | The deployment was not found | 53 | | 500 | Internal server error | 54 | | 503 | The service is unavailable | 55 | 56 | ### Errors 57 | 58 | Example JSON response, containing error 59 | 60 | ```json 61 | {"error": "Deployment was not found", "code": 404} 62 | ``` 63 | 64 | ### Endpoints 65 | 66 | #### Base Endpoint 67 | 68 | ``` 69 | https://.gateway.dialogflow.cloud.ushakov.co 70 | ``` 71 | 72 | #### Base Endpoint Variables 73 | 74 | | Variable | Description | 75 | |------------|------------------------------| 76 | | PROJECT_ID | Required, Project Identifier | 77 | 78 | #### Base Endpoint Example 79 | 80 | ``` 81 | https://dialogflow-web-v2.gateway.dialogflow.cloud.ushakov.co 82 | ``` 83 | 84 | ## Requests 85 | 86 | #### Retrieving Agents 87 | 88 | #### Request 89 | 90 | ```http 91 | GET 92 | ``` 93 | 94 | #### Request Variables 95 | 96 | | Variable | Description | 97 | |---------------|-----------------------------| 98 | | BASE_ENDPOINT | Required, Endpoint of Agent | 99 | 100 | #### Response Body 101 | 102 | [Agent](https://cloud.google.com/dialogflow/docs/reference/rest/v2beta1/projects.agent) 103 | 104 | #### Example Request 105 | 106 | ```http 107 | GET https://dialogflow-web-v2.gateway.dialogflow.cloud.ushakov.co 108 | ``` 109 | 110 | #### Example Response 111 | 112 | ```json 113 | { 114 | "parent": "projects/dialogflow-web-v2", 115 | "displayName": "DialogflowWebV2", 116 | "defaultLanguageCode": "en", 117 | "supportedLanguageCodes": [ 118 | "ru" 119 | ], 120 | "timeZone": "Europe/Madrid", 121 | "description": "This is a unofficial Progressive Web Application for Dialogflow V2, with support for rich-responses and amazing features you need to check out. Choose your language and send Hello to get started", 122 | "avatarUri": "https://storage.googleapis.com/cloudprod-apiai/ce408f19-7966-487d-8614-f5b1f0474ba6_x.png", 123 | "enableLogging": true, 124 | "matchMode": "MATCH_MODE_HYBRID", 125 | "classificationThreshold": 0.3 126 | } 127 | ``` 128 | 129 | ### Detecting Intents 130 | 131 | #### Request 132 | 133 | ```http 134 | POST 135 | ``` 136 | 137 | #### Request Variables 138 | 139 | | Variable | Description | 140 | |----------|-------------| 141 | | BASE_ENDPOINT | Required, Endpoint of Agent | 142 | 143 | #### Request Body 144 | 145 | [DetectIntentRequest](https://cloud.google.com/dialogflow/docs/reference/rpc/google.cloud.dialogflow.v2#google.cloud.dialogflow.v2.DetectIntentRequest) 146 | 147 | #### Response Body 148 | 149 | [DetectIntentResponse](https://cloud.google.com/dialogflow/docs/reference/rest/v2beta1/DetectIntentResponse) 150 | 151 | #### Example Request 152 | 153 | ```http 154 | POST https://app-of-the-day-9a9f6.gateway.dialogflow.cloud.ushakov.co 155 | Content-Type: application/json 156 | 157 | { 158 | "session": "test", 159 | "queryInput": { 160 | "text": { 161 | "text": "Hello", 162 | "languageCode": "en" 163 | } 164 | } 165 | } 166 | ``` 167 | 168 | Note: Dialogflow Gateway converts `session` into `projects//agent/sessions/`. This behaviour is a subject to change 169 | 170 | #### Example Response 171 | 172 | ```json 173 | { 174 | "responseId": "85c3d6bd-6f8c-4000-a1ec-fdd6f636b2e8", 175 | "queryResult": { 176 | "queryText": "Hello", 177 | "action": "input.welcome", 178 | "parameters": {}, 179 | "allRequiredParamsPresent": true, 180 | "fulfillmentText": "Cannot display response in Dialogflow simulator. Please test on the Google Assistant simulator instead.", 181 | "fulfillmentMessages": [...], 182 | "webhookPayload": {...}, 183 | "intent": { 184 | "name": "projects/app-of-the-day-9a9f6/agent/intents/1e00bd68-62f0-4b8e-9cdd-a81c19f73855", 185 | "displayName": "Default Welcome Intent" 186 | }, 187 | "intentDetectionConfidence": 1, 188 | "diagnosticInfo": { 189 | "end_conversation": true, 190 | "webhook_latency_ms": 187 191 | }, 192 | "languageCode": "en" 193 | }, 194 | "webhookStatus": { 195 | "message": "Webhook execution successful" 196 | } 197 | } 198 | ``` 199 | 200 | ## Realtime API 201 | 202 | Realtime API implements [Secure WebSocket](https://en.wikipedia.org/wiki/WebSocket) communication between Dialogflow Gateway and the clients 203 | 204 | ### Close Codes 205 | 206 | | Code | Reason | 207 | |-----------|----------------------------------------------------------------------------| 208 | | 4400 | The request body or session ID is invalid and/or missing | 209 | | 4403 | The deployment was blocked or the service account key is no longer valid | 210 | | 4404 | The deployment was not found | 211 | | 4500 | Internal server error | 212 | 213 | ### Errors 214 | 215 | Example error: 216 | 217 | ``` 218 | 4404 'Deployment was not found' 219 | ``` 220 | 221 | ### Endpoints 222 | 223 | #### Base Endpoint 224 | 225 | ``` 226 | wss://.gateway.dialogflow.cloud.ushakov.co 227 | ``` 228 | 229 | #### Base Endpoint Variables 230 | 231 | | Variable | Description | 232 | |------------|------------------------------| 233 | | PROJECT_ID | Required, Project Identifier | 234 | 235 | #### Base Endpoint Example 236 | 237 | ``` 238 | wss://dialogflow-web-v2.gateway.dialogflow.cloud.ushakov.co 239 | ``` 240 | 241 | ## Requests 242 | 243 | ### Detecting Intents 244 | 245 | #### Request 246 | 247 | ```http 248 | POST 249 | ``` 250 | 251 | #### Request Variables 252 | 253 | | Variable | Description | 254 | |----------|-------------| 255 | | BASE_ENDPOINT | Required, Endpoint of Agent | 256 | 257 | #### Request Body 258 | 259 | [DetectIntentRequest](https://cloud.google.com/dialogflow/docs/reference/rpc/google.cloud.dialogflow.v2#google.cloud.dialogflow.v2.DetectIntentRequest) 260 | 261 | #### Response Body 262 | 263 | [DetectIntentResponse](https://cloud.google.com/dialogflow/docs/reference/rest/v2beta1/DetectIntentResponse) 264 | 265 | #### Example Request 266 | 267 | Note: The examples are using NodeJS 268 | 269 | Note: Dialogflow Gateway converts `session` into `projects//agent/sessions/`. This behaviour is a subject to change 270 | 271 | Multi-Agent scenario using wildcard subdomain on Dialogflow Gateway by Ushakov (Hosted) 272 | 273 | ```js 274 | const WebSocket = require('ws') 275 | const ws = new WebSocket('ws://app-of-the-day-9a9f6.gateway.dialogflow.cloud.ushakov.co') 276 | 277 | ws.send( 278 | JSON.stringify({ 279 | session: "123", 280 | queryInput: { 281 | text: { 282 | text: "Hello", 283 | languageCode: "en" 284 | } 285 | } 286 | }) 287 | ) 288 | 289 | ws.on('message', data => { 290 | console.log(data) 291 | }) 292 | 293 | ws.on('close', (code, error) => { 294 | console.log(code, error) 295 | }) 296 | ``` 297 | 298 | #### Example Response 299 | 300 | ```json 301 | { 302 | "responseId": "85c3d6bd-6f8c-4000-a1ec-fdd6f636b2e8", 303 | "queryResult": { 304 | "queryText": "Hello", 305 | "action": "input.welcome", 306 | "parameters": {}, 307 | "allRequiredParamsPresent": true, 308 | "fulfillmentText": "Cannot display response in Dialogflow simulator. Please test on the Google Assistant simulator instead.", 309 | "fulfillmentMessages": [...], 310 | "webhookPayload": {...}, 311 | "intent": { 312 | "name": "projects/app-of-the-day-9a9f6/agent/intents/1e00bd68-62f0-4b8e-9cdd-a81c19f73855", 313 | "displayName": "Default Welcome Intent" 314 | }, 315 | "intentDetectionConfidence": 1, 316 | "diagnosticInfo": { 317 | "end_conversation": true, 318 | "webhook_latency_ms": 187 319 | }, 320 | "languageCode": "en" 321 | }, 322 | "webhookStatus": { 323 | "message": "Webhook execution successful" 324 | } 325 | } 326 | ``` 327 | 328 | ## Contact 329 | 330 | If you have any questions or troubles regarding the API, please [contact us](https://ushakov.co/#contact) -------------------------------------------------------------------------------- /hosted/configuration.md: -------------------------------------------------------------------------------- 1 | # Dialogflow Gateway by Ushakov (Hosted) Configuration 2 | 3 | Before making any further steps, described below, please make sure, that you have successfully connected your Agent to the Gateway and it is displayed in the console: 4 | 5 | ![Dialogflow Gateway Console](images/console.png) 6 | 7 | ## Get into the configuration screen 8 | 9 | Please click on the “Manage” button on the right side of the Agent that you want to configure 10 | 11 | The “Manage” screen should pop up: 12 | 13 | ![Dialogflow Gateway Overview](images/manageagent.png) 14 | 15 | ## Configuring Webhook 16 | 17 | ![Dialogflow Gateway Settings (Webhook)](images/consolewebhook.png) 18 | 19 | The Webhook field allows you to paste a URL to a Webhook, which will receive a POST request from Dialogflow Gateway, when its triggered 20 | 21 | You can code the webhook in any programming language or framework (in our example we will use Node and Express) 22 | 23 | ### Example Webhook 24 | 25 | Here is the example Webhook on Webtask.io: 26 | 27 | ![Dialogflow Gateway example webhook](images/1*1P5DjCpGfLWgP6lQpoV7OA.png) 28 | 29 | The code: 30 | 31 | ```js 32 | let express = require('express') 33 | let Webtask = require('webtask-tools') 34 | let bodyParser = require('body-parser') 35 | let app = express() 36 | 37 | app.use(bodyParser.json()) 38 | 39 | app.post('/', (req, res) => { 40 | console.log(req.body) 41 | res.sendStatus(200) 42 | }) 43 | 44 | module.exports = Webtask.fromExpress(app) 45 | ``` 46 | 47 | It will log all the incoming requests. Notice, that these are not the requests which are received by the Gateway, instead they were matched Dialogflow responses 48 | 49 | For security reasons, i strongly recommend authenticating your requests via a secret request parameter or using CORS 50 | 51 | On the previous screenshoot, i highlighted the URL, which corresponds to the Webhook. Paste the URL in the Console and press on "Save": 52 | 53 | ![Dialogflow Gateway example webhook url](images/webhookurlexample.png) 54 | 55 | Note, that Dialogflow Gateway isn't aware of your endpoint's health. If its unavailable, you won't be able to receive requests at the time. Dialogflow Gateway isn’t going to retry and has very strict timeouts, so please make sure your webhook responds fast and is durable 56 | 57 | ## Connecting Virtual Agent Analytics 58 | 59 | ![Dialogflow Gateway Settings (Virtual Agent Analytics)](images/virtualagentanalytics.png) 60 | 61 | In this part of the Article, we are going to connect Google’s Area 120 [Chatbase](http://chatbase.com) Virtual Agent Analytics Service to our Dialogflow Gateway in order to get detailed Analytics of our Agent’s usage and reports from the Dialogflow Gateway Platform. Notice, that Dialogflow Gateway has no built-in service for such Analytics and does not store your message history 62 | 63 | ![Chatbase Dashboard](images/1*NQdQk2PPVFOrxHa56Q_qqw.png) 64 | 65 | ![Chatbase Dashboard messages](images/1*62QR5SouuxZH_n9U9epMkg.png) 66 | 67 | ![Chatbase Dashboard transcripts](images/1*mPnKhb4JonFQprSGAMQEXA.png) 68 | 69 | On top of that, Chatbase gives you cool features to play with: 70 | 71 | * Metrics 72 | 73 | * Session flow 74 | 75 | * Retention 76 | 77 | * Cohorts 78 | 79 | * Rich Filtering 80 | 81 | * Funnels 82 | 83 | * Transcripts 84 | 85 | * Sensitive Data Masking 86 | 87 | * Grouping of not-handled messages 88 | 89 | * Machine learning: Suggested intents for missed & misunderstood messages (Beta) 90 | 91 | Let’s connect our Agent! 92 | 93 | 1. Sign into [Chatbase](https://chatbase.com/overview) with your Google Account: 94 | 95 | ![Chatbase Bot List](images/1*dIvJurZEmgizndXTGdlFBw.png) 96 | 97 | 2. Press on “Add a bot” button on the Dashboard and enter the requested info: 98 | 99 | ![Chatbase Add bot](images/1*bitGmbe8nlnrr4IX0Ipcew.png) 100 | 101 | 3. Copy the API Key for your bot: 102 | 103 | ![Chatbase bot API key](images/1*XiohDWc7br_BH_nkjHsLVw.png) 104 | 105 | 4. Paste the API Key in your Dialogflow Gateway Integration and hit on "Save": 106 | 107 | ![Dialogflow Gateway Settings (Chatbase API Key)](images/virtualagentanalyticsapikey.png) 108 | 109 | 5. View your Analytics Data 110 | 111 | ![Chatbase Dialogflow Gateway Analytics](images/1*aKTMHA4wygSZb67T2G3S6w.png) 112 | 113 | Notice: Chatbase can take up to 24 hours to index your messages, so be patient. For your convenience Dialogflow Gateway messages are tagged as “Dialogflow gateway” platform in Chatbase 114 | 115 | ## Settings 116 | 117 | ### Platforms 118 | 119 | ![Dialogflow Gateway Settings (Platforms)](images/consolesettings.png) 120 | 121 | This feature allows you to target Platforms you want to support through Dialogflow Gateway 122 | 123 | ### Unlink 124 | 125 | ![Dialogflow Gateway Settings (Unlink)](images/unlink.png) 126 | 127 | You can press on the “Unlink” button to unlink your Agent from Dialogflow Gateway 128 | 129 | Note: the "Unlink" button is only visible on the "Settings" tab and unlinking will not reset the messages count -------------------------------------------------------------------------------- /hosted/faq.md: -------------------------------------------------------------------------------- 1 | # Dialogflow Gateway by Ushakov (Hosted) FAQ 2 | 3 | **Am i required to use Dialogflow Gateway in order to use Ushakov's integrations?** 4 | 5 | Yes 6 | 7 | **Am i required to use Dialogflow Gateway *by Ushakov*?** 8 | 9 | No, Dialogflow Gateway API is free for anyone to implement ([see the docs](./../README.md)). However, we will not provide support for any integrations, that use your variant of Dialogflow Gateway 10 | 11 | **What happens to my personal data?** 12 | 13 | This is a subject of the [Privacy Policy](https://cloud.ushakov.co/privacy) 14 | 15 | **Do you track any sessions?** 16 | 17 | No, we don't have to. The services are billed after amount of messages you sent us 18 | 19 | **Do you store any messages?** 20 | 21 | No, only the count of messages you sent us is stored for our billing purposes 22 | 23 | **What happens when you change the API or Terms?** 24 | 25 | You will be notified via the E-Mail, that you used to sign up 26 | 27 | **Will my integrations stop working after i exceed free quota?** 28 | 29 | No! 30 | 31 | **How is my usage going to be billed?** 32 | 33 | If you are over the free quota, you will get a e-mail on the 1th of the following month containing instructions on how to transmit your payment 34 | 35 | **Why is my integration displayed as "Blocked"?** 36 | 37 | ![Dialogflow Gateway Blocked](./images/blocked.png) 38 | 39 | Likely, because it has violated our ToS. [Get in touch](https://ushakov.co/#contact) and find out, why it happened and what you can do 40 | 41 | For any further questions, [contact us](https://ushakov.co/#contact) 42 | -------------------------------------------------------------------------------- /hosted/images/0*8iYHLAGC8Qc5APhY.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mishushakov/dialogflow-gateway-docs/569d903b598faa9879f21cd902dc8f1b6703a31d/hosted/images/0*8iYHLAGC8Qc5APhY.png -------------------------------------------------------------------------------- /hosted/images/0*Bw3c0_7Az-MWc4gD.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mishushakov/dialogflow-gateway-docs/569d903b598faa9879f21cd902dc8f1b6703a31d/hosted/images/0*Bw3c0_7Az-MWc4gD.png -------------------------------------------------------------------------------- /hosted/images/0*ZtCBwK0pme7dkEUa.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mishushakov/dialogflow-gateway-docs/569d903b598faa9879f21cd902dc8f1b6703a31d/hosted/images/0*ZtCBwK0pme7dkEUa.png -------------------------------------------------------------------------------- /hosted/images/1*0zPrr0SOtY9ulOXmWHhXig.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mishushakov/dialogflow-gateway-docs/569d903b598faa9879f21cd902dc8f1b6703a31d/hosted/images/1*0zPrr0SOtY9ulOXmWHhXig.png -------------------------------------------------------------------------------- /hosted/images/1*1P5DjCpGfLWgP6lQpoV7OA.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mishushakov/dialogflow-gateway-docs/569d903b598faa9879f21cd902dc8f1b6703a31d/hosted/images/1*1P5DjCpGfLWgP6lQpoV7OA.png -------------------------------------------------------------------------------- /hosted/images/1*62QR5SouuxZH_n9U9epMkg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mishushakov/dialogflow-gateway-docs/569d903b598faa9879f21cd902dc8f1b6703a31d/hosted/images/1*62QR5SouuxZH_n9U9epMkg.png -------------------------------------------------------------------------------- /hosted/images/1*NQdQk2PPVFOrxHa56Q_qqw.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mishushakov/dialogflow-gateway-docs/569d903b598faa9879f21cd902dc8f1b6703a31d/hosted/images/1*NQdQk2PPVFOrxHa56Q_qqw.png -------------------------------------------------------------------------------- /hosted/images/1*Sax2IOrqX6_09FPS-kqLdA.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mishushakov/dialogflow-gateway-docs/569d903b598faa9879f21cd902dc8f1b6703a31d/hosted/images/1*Sax2IOrqX6_09FPS-kqLdA.gif -------------------------------------------------------------------------------- /hosted/images/1*XiohDWc7br_BH_nkjHsLVw.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mishushakov/dialogflow-gateway-docs/569d903b598faa9879f21cd902dc8f1b6703a31d/hosted/images/1*XiohDWc7br_BH_nkjHsLVw.png -------------------------------------------------------------------------------- /hosted/images/1*aKTMHA4wygSZb67T2G3S6w.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mishushakov/dialogflow-gateway-docs/569d903b598faa9879f21cd902dc8f1b6703a31d/hosted/images/1*aKTMHA4wygSZb67T2G3S6w.png -------------------------------------------------------------------------------- /hosted/images/1*bitGmbe8nlnrr4IX0Ipcew.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mishushakov/dialogflow-gateway-docs/569d903b598faa9879f21cd902dc8f1b6703a31d/hosted/images/1*bitGmbe8nlnrr4IX0Ipcew.png -------------------------------------------------------------------------------- /hosted/images/1*dIvJurZEmgizndXTGdlFBw.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mishushakov/dialogflow-gateway-docs/569d903b598faa9879f21cd902dc8f1b6703a31d/hosted/images/1*dIvJurZEmgizndXTGdlFBw.png -------------------------------------------------------------------------------- /hosted/images/1*g7d0ZMyE_ODPiwGqalT_wQ.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mishushakov/dialogflow-gateway-docs/569d903b598faa9879f21cd902dc8f1b6703a31d/hosted/images/1*g7d0ZMyE_ODPiwGqalT_wQ.png -------------------------------------------------------------------------------- /hosted/images/1*mPnKhb4JonFQprSGAMQEXA.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mishushakov/dialogflow-gateway-docs/569d903b598faa9879f21cd902dc8f1b6703a31d/hosted/images/1*mPnKhb4JonFQprSGAMQEXA.png -------------------------------------------------------------------------------- /hosted/images/blocked.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mishushakov/dialogflow-gateway-docs/569d903b598faa9879f21cd902dc8f1b6703a31d/hosted/images/blocked.png -------------------------------------------------------------------------------- /hosted/images/chatbaseapikey.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mishushakov/dialogflow-gateway-docs/569d903b598faa9879f21cd902dc8f1b6703a31d/hosted/images/chatbaseapikey.png -------------------------------------------------------------------------------- /hosted/images/console.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mishushakov/dialogflow-gateway-docs/569d903b598faa9879f21cd902dc8f1b6703a31d/hosted/images/console.png -------------------------------------------------------------------------------- /hosted/images/consolesettings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mishushakov/dialogflow-gateway-docs/569d903b598faa9879f21cd902dc8f1b6703a31d/hosted/images/consolesettings.png -------------------------------------------------------------------------------- /hosted/images/consolewebhook.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mishushakov/dialogflow-gateway-docs/569d903b598faa9879f21cd902dc8f1b6703a31d/hosted/images/consolewebhook.png -------------------------------------------------------------------------------- /hosted/images/embeddeduiurl.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mishushakov/dialogflow-gateway-docs/569d903b598faa9879f21cd902dc8f1b6703a31d/hosted/images/embeddeduiurl.png -------------------------------------------------------------------------------- /hosted/images/gatewayurl.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mishushakov/dialogflow-gateway-docs/569d903b598faa9879f21cd902dc8f1b6703a31d/hosted/images/gatewayurl.png -------------------------------------------------------------------------------- /hosted/images/gatewayurlrt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mishushakov/dialogflow-gateway-docs/569d903b598faa9879f21cd902dc8f1b6703a31d/hosted/images/gatewayurlrt.png -------------------------------------------------------------------------------- /hosted/images/inboxemail.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mishushakov/dialogflow-gateway-docs/569d903b598faa9879f21cd902dc8f1b6703a31d/hosted/images/inboxemail.png -------------------------------------------------------------------------------- /hosted/images/manageagent.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mishushakov/dialogflow-gateway-docs/569d903b598faa9879f21cd902dc8f1b6703a31d/hosted/images/manageagent.png -------------------------------------------------------------------------------- /hosted/images/uiurl.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mishushakov/dialogflow-gateway-docs/569d903b598faa9879f21cd902dc8f1b6703a31d/hosted/images/uiurl.png -------------------------------------------------------------------------------- /hosted/images/unlink.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mishushakov/dialogflow-gateway-docs/569d903b598faa9879f21cd902dc8f1b6703a31d/hosted/images/unlink.png -------------------------------------------------------------------------------- /hosted/images/uploadkeys.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mishushakov/dialogflow-gateway-docs/569d903b598faa9879f21cd902dc8f1b6703a31d/hosted/images/uploadkeys.png -------------------------------------------------------------------------------- /hosted/images/virtualagentanalytics.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mishushakov/dialogflow-gateway-docs/569d903b598faa9879f21cd902dc8f1b6703a31d/hosted/images/virtualagentanalytics.png -------------------------------------------------------------------------------- /hosted/images/virtualagentanalyticsapikey.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mishushakov/dialogflow-gateway-docs/569d903b598faa9879f21cd902dc8f1b6703a31d/hosted/images/virtualagentanalyticsapikey.png -------------------------------------------------------------------------------- /hosted/images/webhookurl.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mishushakov/dialogflow-gateway-docs/569d903b598faa9879f21cd902dc8f1b6703a31d/hosted/images/webhookurl.png -------------------------------------------------------------------------------- /hosted/images/webhookurlexample.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mishushakov/dialogflow-gateway-docs/569d903b598faa9879f21cd902dc8f1b6703a31d/hosted/images/webhookurlexample.png -------------------------------------------------------------------------------- /hosted/installation.md: -------------------------------------------------------------------------------- 1 | # Dialogflow Gateway by Ushakov (Hosted) Installation 2 | 3 | ## Step 1: Get a Service Account 4 | 5 | Service Accounts represent identities of a Service (much like user accounts represent identity of a user). Dialogflow Gateway requires a Service Account to authenticate the requests as they were triggered from your service. In this step, we will generate such Service Account for your Google Cloud project that is connected to your Agent 6 | 7 | Visit [Google Cloud IAM](https://console.cloud.google.com/iam-admin/serviceaccounts) 8 | 9 | Make sure you are on the "Service Accounts" page and have selected the project, which your Dialogflow Agent is associated with 10 | 11 | Then, press on "Create Service Account" button 12 | 13 | Enter the name of your Service Account and press on "Create" 14 | 15 | ![Dialogflow Gateway Service Account creation](images/0*8iYHLAGC8Qc5APhY.png) 16 | 17 | ## Step 2: Grant permissions to the Service Account 18 | 19 | You have now successfully generated a service account! You just need to give it some permissions, so it can access certain resources of your Google Cloud project 20 | 21 | We will need following permissions: "Dialogflow API Client" and "Dialogflow API Reader" 22 | 23 | It’s important, that you set these permissions, otherwise your integration may not work as expected 24 | 25 | ![Dialogflow Gateway Service Account permissions](images/0*ZtCBwK0pme7dkEUa.png) 26 | 27 | Set the Roles and press on "Continue" 28 | 29 | ## Step 3: Get the keys of the Service Account 30 | 31 | In the this step we will generate the keys of our Service Account, which we will later give Dialogflow Gateway access to 32 | 33 | Press on "Create Key Button" and in the "Create Key" window set the "Key type" to "JSON". Then, press on "Create" 34 | 35 | The keys should been downloaded to your default Downloads folder. Make sure to check that as well 36 | 37 | ![Dialogflow Gateway Service Account keys](images/0*Bw3c0_7Az-MWc4gD.png) 38 | 39 | Now, when you have the keys with the correct permissions, you are ready to setup Dialogflow Gateway 40 | 41 | ## Final Step: Upload your keys to Dialogflow Gateway 42 | 43 | Go to the [Dialogflow Gateway Console](https://dialogflow.cloud.ushakov.co/console) 44 | 45 | Sign in with your Google Account 46 | 47 | And you will see the console 48 | 49 | ![Dialogflow Gateway Console](images/console.png) 50 | 51 | In the "Agents" section press on the "Upload Keys" button and select your keys 52 | 53 | ![Dialogflow Gateway Service Account upload](images/uploadkeys.png) 54 | 55 | Your agent should now appear on the "Agents" list. To find your connection information and settings, press on the "Manage" button 56 | 57 | ![Dialogflow Gateway Agents](images/manageagent.png) 58 | 59 | If you have any questions or need help to complete these steps, please contact [Google Cloud Support](https://cloud.google.com/support-hub/) -------------------------------------------------------------------------------- /hosted/integrations.md: -------------------------------------------------------------------------------- 1 | # Dialogflow Gateway by Ushakov (Hosted) Integrations 2 | 3 | ## First Party 4 | 5 | - [Dialogflow Gateway API](api.md#api) 6 | ![Dialogflow Gateway API (Integration)](./images/gatewayurl.png) 7 | 8 | - [Dialogflow Gateway Realtime API](api.md#realtime-api) 9 | ![Dialogflow Gateway Realtime API (Integration)](./images/gatewayurlrt.png) 10 | 11 | - [Dialogflow for Web v2](https://github.com/mishushakov/dialogflow-web-v2) 12 | ![Dialogflow Gateway Dialogflow for Web (Integration)](./images/uiurl.png) 13 | 14 | - [df-btn](https://github.com/mishushakov/df-btn) 15 | ![Dialogflow Gateway Dialogflow df-btn (Integration)](./images/embeddeduiurl.png) 16 | 17 | - [Dialogflow Inbox](https://github.com/mishushakov/dialogflow-inbox) 18 | ![Dialogflow Gateway Inbox (Integration)](./images/inboxemail.png) 19 | 20 | ## Third Party 21 | 22 | - [Webhook](./configuration.md#configuring-webhook) 23 | ![Dialogflow Gateway Webhook (Integration)](./images/webhookurl.png) 24 | 25 | - [Chatbase](./configuration.md#connecting-virtual-agent-analytics) 26 | ![Dialogflow Gateway Chatbase (Integration)](./images/chatbaseapikey.png) 27 | 28 | ## Other 29 | 30 | [Submit your own](https://github.com/mishushakov/dialogflow-gateway-docs/pulls) -------------------------------------------------------------------------------- /hosted/usage.md: -------------------------------------------------------------------------------- 1 | # Dialogflow Gateway by Ushakov (Hosted) Usage 2 | 3 | In this guide we will code our own CLI-Integration for Dialogflow using [Dialogflow Gateway API](api.md.md#api) and [Dialogflow Gateway Realtime API](api.md.md#realtime-api) 4 | 5 | ![Dialogflow Gateway Usage Example (Demo)](images/1*Sax2IOrqX6_09FPS-kqLdA.gif) 6 | 7 | It’s a badass idea, because sometimes you can’t have access to your Google Assistant, Web Browser or a Messenger, but still want to process your Messages through Dialogflow 💪 8 | 9 | Let’s do it! 10 | 11 | ## Preparing our Integration 12 | 13 | ### Requirements 14 | 15 | * NodeJS 16 | 17 | * NPM or Yarn 18 | 19 | * Agent, that is connected to Dialogflow Gateway 20 | 21 | * 5–10 minutes of free time 22 | 23 | ### Initialising Project 24 | 25 | 1. Create new directory 26 | 27 | 2. Run `npm init` or `yarn init` 28 | 29 | 3. Create new file, called `index.js` 30 | 31 | 4. Open the file using your favourite code editor 32 | 33 | ## Coding the Integration 34 | 35 | ### Step 1: Require and install the dependencies 36 | 37 | ```js 38 | /* Require dependencies */ 39 | const fetch = require('node-fetch') 40 | const readline = require('readline').createInterface({ 41 | input: process.stdin, 42 | output: process.stdout 43 | }) 44 | ``` 45 | 46 | 1. Install the `node-fetch` dependency 47 | 48 | `npm i node-fetch` or `yarn add node-fetch` 49 | 50 | ### Step 2: Define the variables 51 | 52 | ```js 53 | /* Define variables */ 54 | const appid = 'dialogflow-web-v2' // <- Google Cloud Project ID 55 | const session = 'dialogflow-cli' // <- Session ID 56 | const lang = 'en' // <- Language 57 | const endpoint = `https://${appid}.gateway.dialogflow.cloud.ushakov.co` // <- Endpoint 58 | ``` 59 | 60 | ### Step 3: Define the messages loop 61 | 62 | ```js 63 | /* Define the loop */ 64 | let ask = () => { 65 | /* Ask for your message */ 66 | readline.question('You: ', (message) => { 67 | /* Build a request */ 68 | let request = { 69 | session: session, 70 | queryInput: { 71 | text: { 72 | text: message, 73 | languageCode: lang 74 | } 75 | } 76 | } 77 | 78 | /* Talk to endpoint and return the results */ 79 | fetch(endpoint, {method: 'POST', body: JSON.stringify(request), headers: {'Content-Type': 'application/json'}}) 80 | .then(res => res.json()) 81 | .then(res => { 82 | let messages = res.queryResult.fulfillmentMessages 83 | for (let message in messages){ 84 | /* Display Dialogflow/Webhook Messages */ 85 | if (messages[message].text) console.log('Bot: ' + messages[message].text.text[0]) 86 | 87 | /* Display Actions on Google Simple Response */ 88 | else if (messages[message].simpleResponses) console.log('Bot: ' + messages[message].simpleResponses.simpleResponses[0].textToSpeech) 89 | 90 | ask() // <- Restart the messages loop 91 | } 92 | }) 93 | }) 94 | } 95 | ``` 96 | 97 | ### Step 4: Start the loop 98 | 99 | ```js 100 | ask() // <- Start the messages loop 101 | ``` 102 | 103 | ### Final Code 104 | 105 | ```js 106 | /* Require dependencies */ 107 | const fetch = require('node-fetch') 108 | const readline = require('readline').createInterface({ 109 | input: process.stdin, 110 | output: process.stdout 111 | }) 112 | 113 | /* Define variables */ 114 | const appid = 'dialogflow-web-v2' // <- Google Cloud Project ID 115 | const session = 'dialogflow-cli' // <- Session ID 116 | const lang = 'en' // <- Language 117 | const endpoint = `https://${appid}.gateway.dialogflow.cloud.ushakov.co` // <- Endpoint 118 | 119 | /* Define the loop */ 120 | let ask = () => { 121 | /* Ask for your message */ 122 | readline.question('You: ', (message) => { 123 | /* Build a request */ 124 | let request = { 125 | session: session, 126 | queryInput: { 127 | text: { 128 | text: message, 129 | languageCode: lang 130 | } 131 | } 132 | } 133 | 134 | /* Talk to endpoint and return the results */ 135 | fetch(endpoint, {method: 'POST', body: JSON.stringify(request), headers: {'Content-Type': 'application/json'}}) 136 | .then(res => res.json()) 137 | .then(res => { 138 | let messages = res.queryResult.fulfillmentMessages 139 | for (let message in messages){ 140 | /* Display Dialogflow/Webhook Messages */ 141 | if (messages[message].text) console.log('Bot: ' + messages[message].text.text[0]) 142 | 143 | /* Display Actions on Google Simple Response */ 144 | else if (messages[message].simpleResponses) console.log('Bot: ' + messages[message].simpleResponses.simpleResponses[0].textToSpeech) 145 | 146 | ask() // <- Restart the messages loop 147 | } 148 | }) 149 | }) 150 | } 151 | 152 | ask() // <- Start the messages loop 153 | ``` 154 | 155 | ### Step 5: Go test it! 156 | 157 | Run `node index.js` and you should see this: 158 | 159 | ![Dialogflow Gateway Usage Example (Console input)](images/1*g7d0ZMyE_ODPiwGqalT_wQ.png) 160 | 161 | Type your message and press Enter: 162 | 163 | ![Dialogflow Gateway Usage Example (Console output)](images/1*0zPrr0SOtY9ulOXmWHhXig.png) 164 | 165 | Your Agent will reply with Dialogflow Response, Webhook or Actions on Google Simple Response! That works 🤘 166 | 167 | ## Coding the Integration (with Realtime API) 168 | 169 | 1. Add the [ws](https://www.npmjs.com/package/ws) package 170 | 171 | `npm i ws` or `yarn add ws` 172 | 2. Change your code a little bit (hope you can do `diff` by yourself): 173 | ```js 174 | /* Require dependencies */ 175 | const WebSocket = require('ws') 176 | const readline = require('readline').createInterface({ 177 | input: process.stdin, 178 | output: process.stdout 179 | }) 180 | 181 | /* Define variables */ 182 | const appid = 'dialogflow-web-v2' // <- Google Cloud Project ID 183 | const session = 'dialogflow-cli' // <- Session ID 184 | const lang = 'en' // <- Language 185 | const endpoint = `wss://${appid}.gateway.dialogflow.cloud.ushakov.co/` // <- Endpoint 186 | const wss = new WebSocket(endpoint) 187 | wss.on('message', message => { 188 | let res = JSON.parse(message) 189 | let messages = res.queryResult.fulfillmentMessages 190 | for (let message in messages){ 191 | /* Display Dialogflow/Webhook Messages */ 192 | if (messages[message].text) console.log('Bot: ' + messages[message].text.text[0]) 193 | /* Display Actions on Google Simple Response */ 194 | else if (messages[message].simpleResponses) console.log('Bot: ' + messages[message].simpleResponses.simpleResponses[0].textToSpeech) 195 | ask() // <- Restart the messages loop 196 | } 197 | }) 198 | 199 | /* Define the loop */ 200 | let ask = () => { 201 | /* Ask for your message */ 202 | readline.question('You: ', (message) => { 203 | /* Build a request */ 204 | let request = { 205 | session: session, 206 | queryInput: { 207 | text: { 208 | text: message, 209 | languageCode: lang 210 | } 211 | } 212 | } 213 | 214 | /* Talk to endpoint and return the results */ 215 | wss.send(JSON.stringify(request)) 216 | }) 217 | } 218 | 219 | ask() // <- Start the messages loop 220 | ``` 221 | 3. Run that! 222 | 223 | I hope you have now learned the basics on how to build cool, stunning and simple Dialogflow integrations using Dialogflow Gateway APIs! Now is your turn to make some 😄 --------------------------------------------------------------------------------