├── hello-world-bot ├── .gitignore ├── LICENSE ├── README.md ├── assets │ └── connexion-settings.png ├── botfile.js ├── index.js ├── modules_config │ └── botpress-messenger.json └── package.json ├── hello-world-rivescript-bot ├── .gitignore ├── LICENSE ├── README.md ├── assets │ ├── connexion-settings.png │ ├── delete-file.png │ ├── new-file.png │ ├── rivescript-code.png │ ├── save-script.png │ └── stop.png ├── botfile.js ├── data │ └── rivescript │ │ ├── begin.rive │ │ └── star.rive ├── index.js ├── modules_config │ └── botpress-messenger.json └── package.json ├── motivation-bot ├── .dockerignore ├── .gitignore ├── Dockerfile ├── LICENSE ├── README.md ├── assets │ └── connexion-settings.png ├── botfile.js ├── data │ └── rivescript │ │ ├── begin.rive │ │ └── star.rive ├── index.js ├── modules_config │ ├── botpress-messenger.json │ └── botpress-subscription.json ├── package.json ├── strip_tokens.js ├── subscription.js └── videos.js └── wit-bot ├── .gitignore ├── LICENSE ├── README.md ├── assets ├── messenger-connexion-settings.png ├── wit-access-token.png ├── wit-connexion-settings.png ├── wit-conversation-weather.png ├── wit-documentation.png ├── wit-hello.png ├── wit-settings.png ├── wit-test.png └── wit-weather.png ├── botfile.js ├── index.js ├── modules_config ├── botpress-messenger.json └── botpress-wit.json └── package.json /hello-world-bot/.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | /logs 3 | *.log 4 | npm-debug.log* 5 | 6 | # Runtime data 7 | pids 8 | *.pid 9 | *.seed 10 | *.pid.lock 11 | 12 | # Directory for instrumented libs generated by jscoverage/JSCover 13 | lib-cov 14 | 15 | # Coverage directory used by tools like istanbul 16 | coverage 17 | 18 | # nyc test coverage 19 | .nyc_output 20 | 21 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 22 | .grunt 23 | 24 | # node-waf configuration 25 | .lock-wscript 26 | 27 | # Compiled binary addons (http://nodejs.org/api/addons.html) 28 | build/Release 29 | 30 | # Dependency directories 31 | node_modules 32 | jspm_packages 33 | 34 | # Optional npm cache directory 35 | .npm 36 | 37 | # Optional eslint cache 38 | .eslintcache 39 | 40 | # Optional REPL history 41 | .node_repl_history 42 | 43 | # Output of 'npm pack' 44 | *.tgz 45 | 46 | # *** Botpress specifics *** 47 | /data -------------------------------------------------------------------------------- /hello-world-bot/LICENSE: -------------------------------------------------------------------------------- 1 | GNU AFFERO GENERAL PUBLIC LICENSE 2 | Version 3, 19 November 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU Affero General Public License is a free, copyleft license for 11 | software and other kinds of works, specifically designed to ensure 12 | cooperation with the community in the case of network server software. 13 | 14 | The licenses for most software and other practical works are designed 15 | to take away your freedom to share and change the works. By contrast, 16 | our General Public Licenses are intended to guarantee your freedom to 17 | share and change all versions of a program--to make sure it remains free 18 | software for all its users. 19 | 20 | When we speak of free software, we are referring to freedom, not 21 | price. Our General Public Licenses are designed to make sure that you 22 | have the freedom to distribute copies of free software (and charge for 23 | them if you wish), that you receive source code or can get it if you 24 | want it, that you can change the software or use pieces of it in new 25 | free programs, and that you know you can do these things. 26 | 27 | Developers that use our General Public Licenses protect your rights 28 | with two steps: (1) assert copyright on the software, and (2) offer 29 | you this License which gives you legal permission to copy, distribute 30 | and/or modify the software. 31 | 32 | A secondary benefit of defending all users' freedom is that 33 | improvements made in alternate versions of the program, if they 34 | receive widespread use, become available for other developers to 35 | incorporate. Many developers of free software are heartened and 36 | encouraged by the resulting cooperation. However, in the case of 37 | software used on network servers, this result may fail to come about. 38 | The GNU General Public License permits making a modified version and 39 | letting the public access it on a server without ever releasing its 40 | source code to the public. 41 | 42 | The GNU Affero General Public License is designed specifically to 43 | ensure that, in such cases, the modified source code becomes available 44 | to the community. It requires the operator of a network server to 45 | provide the source code of the modified version running there to the 46 | users of that server. Therefore, public use of a modified version, on 47 | a publicly accessible server, gives the public access to the source 48 | code of the modified version. 49 | 50 | An older license, called the Affero General Public License and 51 | published by Affero, was designed to accomplish similar goals. This is 52 | a different license, not a version of the Affero GPL, but Affero has 53 | released a new version of the Affero GPL which permits relicensing under 54 | this license. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | TERMS AND CONDITIONS 60 | 61 | 0. Definitions. 62 | 63 | "This License" refers to version 3 of the GNU Affero General Public License. 64 | 65 | "Copyright" also means copyright-like laws that apply to other kinds of 66 | works, such as semiconductor masks. 67 | 68 | "The Program" refers to any copyrightable work licensed under this 69 | License. Each licensee is addressed as "you". "Licensees" and 70 | "recipients" may be individuals or organizations. 71 | 72 | To "modify" a work means to copy from or adapt all or part of the work 73 | in a fashion requiring copyright permission, other than the making of an 74 | exact copy. The resulting work is called a "modified version" of the 75 | earlier work or a work "based on" the earlier work. 76 | 77 | A "covered work" means either the unmodified Program or a work based 78 | on the Program. 79 | 80 | To "propagate" a work means to do anything with it that, without 81 | permission, would make you directly or secondarily liable for 82 | infringement under applicable copyright law, except executing it on a 83 | computer or modifying a private copy. Propagation includes copying, 84 | distribution (with or without modification), making available to the 85 | public, and in some countries other activities as well. 86 | 87 | To "convey" a work means any kind of propagation that enables other 88 | parties to make or receive copies. Mere interaction with a user through 89 | a computer network, with no transfer of a copy, is not conveying. 90 | 91 | An interactive user interface displays "Appropriate Legal Notices" 92 | to the extent that it includes a convenient and prominently visible 93 | feature that (1) displays an appropriate copyright notice, and (2) 94 | tells the user that there is no warranty for the work (except to the 95 | extent that warranties are provided), that licensees may convey the 96 | work under this License, and how to view a copy of this License. If 97 | the interface presents a list of user commands or options, such as a 98 | menu, a prominent item in the list meets this criterion. 99 | 100 | 1. Source Code. 101 | 102 | The "source code" for a work means the preferred form of the work 103 | for making modifications to it. "Object code" means any non-source 104 | form of a work. 105 | 106 | A "Standard Interface" means an interface that either is an official 107 | standard defined by a recognized standards body, or, in the case of 108 | interfaces specified for a particular programming language, one that 109 | is widely used among developers working in that language. 110 | 111 | The "System Libraries" of an executable work include anything, other 112 | than the work as a whole, that (a) is included in the normal form of 113 | packaging a Major Component, but which is not part of that Major 114 | Component, and (b) serves only to enable use of the work with that 115 | Major Component, or to implement a Standard Interface for which an 116 | implementation is available to the public in source code form. A 117 | "Major Component", in this context, means a major essential component 118 | (kernel, window system, and so on) of the specific operating system 119 | (if any) on which the executable work runs, or a compiler used to 120 | produce the work, or an object code interpreter used to run it. 121 | 122 | The "Corresponding Source" for a work in object code form means all 123 | the source code needed to generate, install, and (for an executable 124 | work) run the object code and to modify the work, including scripts to 125 | control those activities. However, it does not include the work's 126 | System Libraries, or general-purpose tools or generally available free 127 | programs which are used unmodified in performing those activities but 128 | which are not part of the work. For example, Corresponding Source 129 | includes interface definition files associated with source files for 130 | the work, and the source code for shared libraries and dynamically 131 | linked subprograms that the work is specifically designed to require, 132 | such as by intimate data communication or control flow between those 133 | subprograms and other parts of the work. 134 | 135 | The Corresponding Source need not include anything that users 136 | can regenerate automatically from other parts of the Corresponding 137 | Source. 138 | 139 | The Corresponding Source for a work in source code form is that 140 | same work. 141 | 142 | 2. Basic Permissions. 143 | 144 | All rights granted under this License are granted for the term of 145 | copyright on the Program, and are irrevocable provided the stated 146 | conditions are met. This License explicitly affirms your unlimited 147 | permission to run the unmodified Program. The output from running a 148 | covered work is covered by this License only if the output, given its 149 | content, constitutes a covered work. This License acknowledges your 150 | rights of fair use or other equivalent, as provided by copyright law. 151 | 152 | You may make, run and propagate covered works that you do not 153 | convey, without conditions so long as your license otherwise remains 154 | in force. You may convey covered works to others for the sole purpose 155 | of having them make modifications exclusively for you, or provide you 156 | with facilities for running those works, provided that you comply with 157 | the terms of this License in conveying all material for which you do 158 | not control copyright. Those thus making or running the covered works 159 | for you must do so exclusively on your behalf, under your direction 160 | and control, on terms that prohibit them from making any copies of 161 | your copyrighted material outside their relationship with you. 162 | 163 | Conveying under any other circumstances is permitted solely under 164 | the conditions stated below. Sublicensing is not allowed; section 10 165 | makes it unnecessary. 166 | 167 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 168 | 169 | No covered work shall be deemed part of an effective technological 170 | measure under any applicable law fulfilling obligations under article 171 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 172 | similar laws prohibiting or restricting circumvention of such 173 | measures. 174 | 175 | When you convey a covered work, you waive any legal power to forbid 176 | circumvention of technological measures to the extent such circumvention 177 | is effected by exercising rights under this License with respect to 178 | the covered work, and you disclaim any intention to limit operation or 179 | modification of the work as a means of enforcing, against the work's 180 | users, your or third parties' legal rights to forbid circumvention of 181 | technological measures. 182 | 183 | 4. Conveying Verbatim Copies. 184 | 185 | You may convey verbatim copies of the Program's source code as you 186 | receive it, in any medium, provided that you conspicuously and 187 | appropriately publish on each copy an appropriate copyright notice; 188 | keep intact all notices stating that this License and any 189 | non-permissive terms added in accord with section 7 apply to the code; 190 | keep intact all notices of the absence of any warranty; and give all 191 | recipients a copy of this License along with the Program. 192 | 193 | You may charge any price or no price for each copy that you convey, 194 | and you may offer support or warranty protection for a fee. 195 | 196 | 5. Conveying Modified Source Versions. 197 | 198 | You may convey a work based on the Program, or the modifications to 199 | produce it from the Program, in the form of source code under the 200 | terms of section 4, provided that you also meet all of these conditions: 201 | 202 | a) The work must carry prominent notices stating that you modified 203 | it, and giving a relevant date. 204 | 205 | b) The work must carry prominent notices stating that it is 206 | released under this License and any conditions added under section 207 | 7. This requirement modifies the requirement in section 4 to 208 | "keep intact all notices". 209 | 210 | c) You must license the entire work, as a whole, under this 211 | License to anyone who comes into possession of a copy. This 212 | License will therefore apply, along with any applicable section 7 213 | additional terms, to the whole of the work, and all its parts, 214 | regardless of how they are packaged. This License gives no 215 | permission to license the work in any other way, but it does not 216 | invalidate such permission if you have separately received it. 217 | 218 | d) If the work has interactive user interfaces, each must display 219 | Appropriate Legal Notices; however, if the Program has interactive 220 | interfaces that do not display Appropriate Legal Notices, your 221 | work need not make them do so. 222 | 223 | A compilation of a covered work with other separate and independent 224 | works, which are not by their nature extensions of the covered work, 225 | and which are not combined with it such as to form a larger program, 226 | in or on a volume of a storage or distribution medium, is called an 227 | "aggregate" if the compilation and its resulting copyright are not 228 | used to limit the access or legal rights of the compilation's users 229 | beyond what the individual works permit. Inclusion of a covered work 230 | in an aggregate does not cause this License to apply to the other 231 | parts of the aggregate. 232 | 233 | 6. Conveying Non-Source Forms. 234 | 235 | You may convey a covered work in object code form under the terms 236 | of sections 4 and 5, provided that you also convey the 237 | machine-readable Corresponding Source under the terms of this License, 238 | in one of these ways: 239 | 240 | a) Convey the object code in, or embodied in, a physical product 241 | (including a physical distribution medium), accompanied by the 242 | Corresponding Source fixed on a durable physical medium 243 | customarily used for software interchange. 244 | 245 | b) Convey the object code in, or embodied in, a physical product 246 | (including a physical distribution medium), accompanied by a 247 | written offer, valid for at least three years and valid for as 248 | long as you offer spare parts or customer support for that product 249 | model, to give anyone who possesses the object code either (1) a 250 | copy of the Corresponding Source for all the software in the 251 | product that is covered by this License, on a durable physical 252 | medium customarily used for software interchange, for a price no 253 | more than your reasonable cost of physically performing this 254 | conveying of source, or (2) access to copy the 255 | Corresponding Source from a network server at no charge. 256 | 257 | c) Convey individual copies of the object code with a copy of the 258 | written offer to provide the Corresponding Source. This 259 | alternative is allowed only occasionally and noncommercially, and 260 | only if you received the object code with such an offer, in accord 261 | with subsection 6b. 262 | 263 | d) Convey the object code by offering access from a designated 264 | place (gratis or for a charge), and offer equivalent access to the 265 | Corresponding Source in the same way through the same place at no 266 | further charge. You need not require recipients to copy the 267 | Corresponding Source along with the object code. If the place to 268 | copy the object code is a network server, the Corresponding Source 269 | may be on a different server (operated by you or a third party) 270 | that supports equivalent copying facilities, provided you maintain 271 | clear directions next to the object code saying where to find the 272 | Corresponding Source. Regardless of what server hosts the 273 | Corresponding Source, you remain obligated to ensure that it is 274 | available for as long as needed to satisfy these requirements. 275 | 276 | e) Convey the object code using peer-to-peer transmission, provided 277 | you inform other peers where the object code and Corresponding 278 | Source of the work are being offered to the general public at no 279 | charge under subsection 6d. 280 | 281 | A separable portion of the object code, whose source code is excluded 282 | from the Corresponding Source as a System Library, need not be 283 | included in conveying the object code work. 284 | 285 | A "User Product" is either (1) a "consumer product", which means any 286 | tangible personal property which is normally used for personal, family, 287 | or household purposes, or (2) anything designed or sold for incorporation 288 | into a dwelling. In determining whether a product is a consumer product, 289 | doubtful cases shall be resolved in favor of coverage. For a particular 290 | product received by a particular user, "normally used" refers to a 291 | typical or common use of that class of product, regardless of the status 292 | of the particular user or of the way in which the particular user 293 | actually uses, or expects or is expected to use, the product. A product 294 | is a consumer product regardless of whether the product has substantial 295 | commercial, industrial or non-consumer uses, unless such uses represent 296 | the only significant mode of use of the product. 297 | 298 | "Installation Information" for a User Product means any methods, 299 | procedures, authorization keys, or other information required to install 300 | and execute modified versions of a covered work in that User Product from 301 | a modified version of its Corresponding Source. The information must 302 | suffice to ensure that the continued functioning of the modified object 303 | code is in no case prevented or interfered with solely because 304 | modification has been made. 305 | 306 | If you convey an object code work under this section in, or with, or 307 | specifically for use in, a User Product, and the conveying occurs as 308 | part of a transaction in which the right of possession and use of the 309 | User Product is transferred to the recipient in perpetuity or for a 310 | fixed term (regardless of how the transaction is characterized), the 311 | Corresponding Source conveyed under this section must be accompanied 312 | by the Installation Information. But this requirement does not apply 313 | if neither you nor any third party retains the ability to install 314 | modified object code on the User Product (for example, the work has 315 | been installed in ROM). 316 | 317 | The requirement to provide Installation Information does not include a 318 | requirement to continue to provide support service, warranty, or updates 319 | for a work that has been modified or installed by the recipient, or for 320 | the User Product in which it has been modified or installed. Access to a 321 | network may be denied when the modification itself materially and 322 | adversely affects the operation of the network or violates the rules and 323 | protocols for communication across the network. 324 | 325 | Corresponding Source conveyed, and Installation Information provided, 326 | in accord with this section must be in a format that is publicly 327 | documented (and with an implementation available to the public in 328 | source code form), and must require no special password or key for 329 | unpacking, reading or copying. 330 | 331 | 7. Additional Terms. 332 | 333 | "Additional permissions" are terms that supplement the terms of this 334 | License by making exceptions from one or more of its conditions. 335 | Additional permissions that are applicable to the entire Program shall 336 | be treated as though they were included in this License, to the extent 337 | that they are valid under applicable law. If additional permissions 338 | apply only to part of the Program, that part may be used separately 339 | under those permissions, but the entire Program remains governed by 340 | this License without regard to the additional permissions. 341 | 342 | When you convey a copy of a covered work, you may at your option 343 | remove any additional permissions from that copy, or from any part of 344 | it. (Additional permissions may be written to require their own 345 | removal in certain cases when you modify the work.) You may place 346 | additional permissions on material, added by you to a covered work, 347 | for which you have or can give appropriate copyright permission. 348 | 349 | Notwithstanding any other provision of this License, for material you 350 | add to a covered work, you may (if authorized by the copyright holders of 351 | that material) supplement the terms of this License with terms: 352 | 353 | a) Disclaiming warranty or limiting liability differently from the 354 | terms of sections 15 and 16 of this License; or 355 | 356 | b) Requiring preservation of specified reasonable legal notices or 357 | author attributions in that material or in the Appropriate Legal 358 | Notices displayed by works containing it; or 359 | 360 | c) Prohibiting misrepresentation of the origin of that material, or 361 | requiring that modified versions of such material be marked in 362 | reasonable ways as different from the original version; or 363 | 364 | d) Limiting the use for publicity purposes of names of licensors or 365 | authors of the material; or 366 | 367 | e) Declining to grant rights under trademark law for use of some 368 | trade names, trademarks, or service marks; or 369 | 370 | f) Requiring indemnification of licensors and authors of that 371 | material by anyone who conveys the material (or modified versions of 372 | it) with contractual assumptions of liability to the recipient, for 373 | any liability that these contractual assumptions directly impose on 374 | those licensors and authors. 375 | 376 | All other non-permissive additional terms are considered "further 377 | restrictions" within the meaning of section 10. If the Program as you 378 | received it, or any part of it, contains a notice stating that it is 379 | governed by this License along with a term that is a further 380 | restriction, you may remove that term. If a license document contains 381 | a further restriction but permits relicensing or conveying under this 382 | License, you may add to a covered work material governed by the terms 383 | of that license document, provided that the further restriction does 384 | not survive such relicensing or conveying. 385 | 386 | If you add terms to a covered work in accord with this section, you 387 | must place, in the relevant source files, a statement of the 388 | additional terms that apply to those files, or a notice indicating 389 | where to find the applicable terms. 390 | 391 | Additional terms, permissive or non-permissive, may be stated in the 392 | form of a separately written license, or stated as exceptions; 393 | the above requirements apply either way. 394 | 395 | 8. Termination. 396 | 397 | You may not propagate or modify a covered work except as expressly 398 | provided under this License. Any attempt otherwise to propagate or 399 | modify it is void, and will automatically terminate your rights under 400 | this License (including any patent licenses granted under the third 401 | paragraph of section 11). 402 | 403 | However, if you cease all violation of this License, then your 404 | license from a particular copyright holder is reinstated (a) 405 | provisionally, unless and until the copyright holder explicitly and 406 | finally terminates your license, and (b) permanently, if the copyright 407 | holder fails to notify you of the violation by some reasonable means 408 | prior to 60 days after the cessation. 409 | 410 | Moreover, your license from a particular copyright holder is 411 | reinstated permanently if the copyright holder notifies you of the 412 | violation by some reasonable means, this is the first time you have 413 | received notice of violation of this License (for any work) from that 414 | copyright holder, and you cure the violation prior to 30 days after 415 | your receipt of the notice. 416 | 417 | Termination of your rights under this section does not terminate the 418 | licenses of parties who have received copies or rights from you under 419 | this License. If your rights have been terminated and not permanently 420 | reinstated, you do not qualify to receive new licenses for the same 421 | material under section 10. 422 | 423 | 9. Acceptance Not Required for Having Copies. 424 | 425 | You are not required to accept this License in order to receive or 426 | run a copy of the Program. Ancillary propagation of a covered work 427 | occurring solely as a consequence of using peer-to-peer transmission 428 | to receive a copy likewise does not require acceptance. However, 429 | nothing other than this License grants you permission to propagate or 430 | modify any covered work. These actions infringe copyright if you do 431 | not accept this License. Therefore, by modifying or propagating a 432 | covered work, you indicate your acceptance of this License to do so. 433 | 434 | 10. Automatic Licensing of Downstream Recipients. 435 | 436 | Each time you convey a covered work, the recipient automatically 437 | receives a license from the original licensors, to run, modify and 438 | propagate that work, subject to this License. You are not responsible 439 | for enforcing compliance by third parties with this License. 440 | 441 | An "entity transaction" is a transaction transferring control of an 442 | organization, or substantially all assets of one, or subdividing an 443 | organization, or merging organizations. If propagation of a covered 444 | work results from an entity transaction, each party to that 445 | transaction who receives a copy of the work also receives whatever 446 | licenses to the work the party's predecessor in interest had or could 447 | give under the previous paragraph, plus a right to possession of the 448 | Corresponding Source of the work from the predecessor in interest, if 449 | the predecessor has it or can get it with reasonable efforts. 450 | 451 | You may not impose any further restrictions on the exercise of the 452 | rights granted or affirmed under this License. For example, you may 453 | not impose a license fee, royalty, or other charge for exercise of 454 | rights granted under this License, and you may not initiate litigation 455 | (including a cross-claim or counterclaim in a lawsuit) alleging that 456 | any patent claim is infringed by making, using, selling, offering for 457 | sale, or importing the Program or any portion of it. 458 | 459 | 11. Patents. 460 | 461 | A "contributor" is a copyright holder who authorizes use under this 462 | License of the Program or a work on which the Program is based. The 463 | work thus licensed is called the contributor's "contributor version". 464 | 465 | A contributor's "essential patent claims" are all patent claims 466 | owned or controlled by the contributor, whether already acquired or 467 | hereafter acquired, that would be infringed by some manner, permitted 468 | by this License, of making, using, or selling its contributor version, 469 | but do not include claims that would be infringed only as a 470 | consequence of further modification of the contributor version. For 471 | purposes of this definition, "control" includes the right to grant 472 | patent sublicenses in a manner consistent with the requirements of 473 | this License. 474 | 475 | Each contributor grants you a non-exclusive, worldwide, royalty-free 476 | patent license under the contributor's essential patent claims, to 477 | make, use, sell, offer for sale, import and otherwise run, modify and 478 | propagate the contents of its contributor version. 479 | 480 | In the following three paragraphs, a "patent license" is any express 481 | agreement or commitment, however denominated, not to enforce a patent 482 | (such as an express permission to practice a patent or covenant not to 483 | sue for patent infringement). To "grant" such a patent license to a 484 | party means to make such an agreement or commitment not to enforce a 485 | patent against the party. 486 | 487 | If you convey a covered work, knowingly relying on a patent license, 488 | and the Corresponding Source of the work is not available for anyone 489 | to copy, free of charge and under the terms of this License, through a 490 | publicly available network server or other readily accessible means, 491 | then you must either (1) cause the Corresponding Source to be so 492 | available, or (2) arrange to deprive yourself of the benefit of the 493 | patent license for this particular work, or (3) arrange, in a manner 494 | consistent with the requirements of this License, to extend the patent 495 | license to downstream recipients. "Knowingly relying" means you have 496 | actual knowledge that, but for the patent license, your conveying the 497 | covered work in a country, or your recipient's use of the covered work 498 | in a country, would infringe one or more identifiable patents in that 499 | country that you have reason to believe are valid. 500 | 501 | If, pursuant to or in connection with a single transaction or 502 | arrangement, you convey, or propagate by procuring conveyance of, a 503 | covered work, and grant a patent license to some of the parties 504 | receiving the covered work authorizing them to use, propagate, modify 505 | or convey a specific copy of the covered work, then the patent license 506 | you grant is automatically extended to all recipients of the covered 507 | work and works based on it. 508 | 509 | A patent license is "discriminatory" if it does not include within 510 | the scope of its coverage, prohibits the exercise of, or is 511 | conditioned on the non-exercise of one or more of the rights that are 512 | specifically granted under this License. You may not convey a covered 513 | work if you are a party to an arrangement with a third party that is 514 | in the business of distributing software, under which you make payment 515 | to the third party based on the extent of your activity of conveying 516 | the work, and under which the third party grants, to any of the 517 | parties who would receive the covered work from you, a discriminatory 518 | patent license (a) in connection with copies of the covered work 519 | conveyed by you (or copies made from those copies), or (b) primarily 520 | for and in connection with specific products or compilations that 521 | contain the covered work, unless you entered into that arrangement, 522 | or that patent license was granted, prior to 28 March 2007. 523 | 524 | Nothing in this License shall be construed as excluding or limiting 525 | any implied license or other defenses to infringement that may 526 | otherwise be available to you under applicable patent law. 527 | 528 | 12. No Surrender of Others' Freedom. 529 | 530 | If conditions are imposed on you (whether by court order, agreement or 531 | otherwise) that contradict the conditions of this License, they do not 532 | excuse you from the conditions of this License. If you cannot convey a 533 | covered work so as to satisfy simultaneously your obligations under this 534 | License and any other pertinent obligations, then as a consequence you may 535 | not convey it at all. For example, if you agree to terms that obligate you 536 | to collect a royalty for further conveying from those to whom you convey 537 | the Program, the only way you could satisfy both those terms and this 538 | License would be to refrain entirely from conveying the Program. 539 | 540 | 13. Remote Network Interaction; Use with the GNU General Public License. 541 | 542 | Notwithstanding any other provision of this License, if you modify the 543 | Program, your modified version must prominently offer all users 544 | interacting with it remotely through a computer network (if your version 545 | supports such interaction) an opportunity to receive the Corresponding 546 | Source of your version by providing access to the Corresponding Source 547 | from a network server at no charge, through some standard or customary 548 | means of facilitating copying of software. This Corresponding Source 549 | shall include the Corresponding Source for any work covered by version 3 550 | of the GNU General Public License that is incorporated pursuant to the 551 | following paragraph. 552 | 553 | Notwithstanding any other provision of this License, you have 554 | permission to link or combine any covered work with a work licensed 555 | under version 3 of the GNU General Public License into a single 556 | combined work, and to convey the resulting work. The terms of this 557 | License will continue to apply to the part which is the covered work, 558 | but the work with which it is combined will remain governed by version 559 | 3 of the GNU General Public License. 560 | 561 | 14. Revised Versions of this License. 562 | 563 | The Free Software Foundation may publish revised and/or new versions of 564 | the GNU Affero General Public License from time to time. Such new versions 565 | will be similar in spirit to the present version, but may differ in detail to 566 | address new problems or concerns. 567 | 568 | Each version is given a distinguishing version number. If the 569 | Program specifies that a certain numbered version of the GNU Affero General 570 | Public License "or any later version" applies to it, you have the 571 | option of following the terms and conditions either of that numbered 572 | version or of any later version published by the Free Software 573 | Foundation. If the Program does not specify a version number of the 574 | GNU Affero General Public License, you may choose any version ever published 575 | by the Free Software Foundation. 576 | 577 | If the Program specifies that a proxy can decide which future 578 | versions of the GNU Affero General Public License can be used, that proxy's 579 | public statement of acceptance of a version permanently authorizes you 580 | to choose that version for the Program. 581 | 582 | Later license versions may give you additional or different 583 | permissions. However, no additional obligations are imposed on any 584 | author or copyright holder as a result of your choosing to follow a 585 | later version. 586 | 587 | 15. Disclaimer of Warranty. 588 | 589 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 590 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 591 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 592 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 593 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 594 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 595 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 596 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 597 | 598 | 16. Limitation of Liability. 599 | 600 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 601 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 602 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 603 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 604 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 605 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 606 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 607 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 608 | SUCH DAMAGES. 609 | 610 | 17. Interpretation of Sections 15 and 16. 611 | 612 | If the disclaimer of warranty and limitation of liability provided 613 | above cannot be given local legal effect according to their terms, 614 | reviewing courts shall apply local law that most closely approximates 615 | an absolute waiver of all civil liability in connection with the 616 | Program, unless a warranty or assumption of liability accompanies a 617 | copy of the Program in return for a fee. 618 | 619 | END OF TERMS AND CONDITIONS 620 | 621 | How to Apply These Terms to Your New Programs 622 | 623 | If you develop a new program, and you want it to be of the greatest 624 | possible use to the public, the best way to achieve this is to make it 625 | free software which everyone can redistribute and change under these terms. 626 | 627 | To do so, attach the following notices to the program. It is safest 628 | to attach them to the start of each source file to most effectively 629 | state the exclusion of warranty; and each file should have at least 630 | the "copyright" line and a pointer to where the full notice is found. 631 | 632 | 633 | Copyright (C) 634 | 635 | This program is free software: you can redistribute it and/or modify 636 | it under the terms of the GNU Affero General Public License as published by 637 | the Free Software Foundation, either version 3 of the License, or 638 | (at your option) any later version. 639 | 640 | This program is distributed in the hope that it will be useful, 641 | but WITHOUT ANY WARRANTY; without even the implied warranty of 642 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 643 | GNU Affero General Public License for more details. 644 | 645 | You should have received a copy of the GNU Affero General Public License 646 | along with this program. If not, see . 647 | 648 | Also add information on how to contact you by electronic and paper mail. 649 | 650 | If your software can interact with users remotely through a computer 651 | network, you should also make sure that it provides a way for users to 652 | get its source. For example, if your program is a web application, its 653 | interface could display a "Source" link that leads users to an archive 654 | of the code. There are many ways you could offer source, and different 655 | solutions will be better for different programs; see section 13 for the 656 | specific requirements. 657 | 658 | You should also get your employer (if you work as a programmer) or school, 659 | if any, to sign a "copyright disclaimer" for the program, if necessary. 660 | For more information on this, and how to apply and follow the GNU AGPL, see 661 | . 662 | -------------------------------------------------------------------------------- /hello-world-bot/README.md: -------------------------------------------------------------------------------- 1 | # Tutorial 2 | 3 | This tutorial will show you how easy it is to build a basic "hello world" bot using the Botpress and Messenger modules. This exercise should take you less than 10 minutes. If you have any problems, don't hesitate to talk to us on our [Public Community](https://slack.botpress.io). It will be a pleasure for us to answer your requests. 4 | 5 | ## Table of contents 6 | * [Requirements](#requirements) 7 | * [Step-by-step](#step-by-step) 8 | * [Install Botpress](#install-botpress) 9 | * [Create a new repository](#create-new-repo) 10 | * [Initialize Botpress](#initialize-botpress) 11 | * [Install Botpress modules](#install-botpress-modules) 12 | * [Start Botpress](#start-botpress) 13 | * [Configure Messenger connection settings](#configure-messenger) 14 | * [Verifying your configuration](#verifying-connection) 15 | * [Open your repo in an editor](#open-your-repo) 16 | * [Start coding](#start-coding) 17 | * [Answer a "hello world" user message](#answer-user-message) 18 | * [Answer any other user message](#answer-any-message) 19 | * [Have fun](#have-fun) 20 | * [Community](#community) 21 | * [License](#license) 22 | 23 | ## Requirements 24 | 25 | Botpress requires [node](https://nodejs.org) (version >= 4.2) and uses [npm](https://www.npmjs.com) as package manager. 26 | 27 | ## Step-by-step 28 | 29 | ### 1. Install Botpress 30 | 31 | You first need to have `botpress` installed as a general dependency using `npm`. If `npm` is already installed, you can install Botpress with the following command (make sure to install it globally): 32 | 33 | ``` 34 | npm install -g botpress 35 | ``` 36 | 37 | ### 2. Create a new repository 38 | 39 | Once `botpress` has been installed, you create a new repository and cd into it. 40 | 41 | ```js 42 | mkdir hello-world-bot && cd hello-world-bot // Mac and Linux users 43 | 44 | md hello-world-bot && cd hello-world-bot // Windows users 45 | ``` 46 | 47 | ### 3. Initialize Botpress 48 | 49 | Now, let's use the command line interface of `botpress` to initialize your bot: 50 | 51 | ``` 52 | botpress init 53 | ``` 54 | 55 | ### 4. Install Botpress modules 56 | 57 | In your command line again, you need to install the [botpress-messenger](https://github.com/botpress/botpress-messenger) module to be able to connect your bot to your Facebook page. 58 | 59 | ``` 60 | botpress install messenger 61 | ``` 62 | 63 | ### 5. Start Botpress 64 | 65 | Once everything is installed, you can start your bot and see what it includes. 66 | 67 | ``` 68 | botpress start 69 | ``` 70 | 71 | A local instance of your bot should be running at [http://localhost:3000](http://localhost:3000). From there you can install other modules as desired, but for this tutorial we only need `botpress-messenger` which we have just installed. 72 | 73 | ### 6. Configure Messenger connection settings 74 | 75 | Before starting to code, you need to configure Messenger so it's connected directly to your Facebook page. If this is your first time to configure Messenger, we recommend following our [getting started](https://docs.botpress.io/getting-started.html) guide in the official Botpress documentation. 76 | 77 | 78 | 79 | Briefly, you need to create a [Facebook page](https://www.facebook.com/pages/create) if you don't already have one. You also need to create a new [Messenger app](https://developers.facebook.com/) on Facebook. After that, you can find your **App ID**, **App Secret**, and **Token Access**, and paste them directly into the `botpress-messenger` module settings of the [Botpress user interface](http://localhost:3000/modules/botpress-messenger) running locally. Finally, you only need to activate [ngrok](https://ngrok.com/), and then validate and connect your bot. 80 | 81 | For further information on configuring `botpress-messenger` see the [Getting Started documentation](https://docs.botpress.io/getting-started.html). 82 | 83 | #### Verifying your configuration 84 | 85 | After connecting the Botpress Messenger module with your Facebook Messenger app in the step above, you can verify that everything's working by opening a chat tab on your Facebook page and typing `BOT_LICENSE`. 86 | 87 | The bot should answer your user message, for example with: 88 | 89 | ``` 90 | Bot: motivation-bot 91 | Created by: GB 92 | License: AGPL-3.0 93 | Botpress: 0.0.50 94 | ``` 95 | 96 | **Note**: `BOT_LICENSE` is a Botpress command to display basic information about your bot (name, version, licenses). 97 | 98 | ### 7. Open your repo in an editor 99 | 100 | Once all the setup is done, you are ready to code your bot. You open your repository in your favorite editor (Sublime, Atom, WebStorm, Netbeans, ...). As you can see, some files and directories have already been created when you had previously initialized your repo with `botpress-init`. 101 | 102 | ```js 103 | - botfile.js // your bot's configuration. Botpress uses this 104 | - index.js // your bot's entry point. bot logic goes here 105 | - package.json // regular node package.json file 106 | - LICENSE // your bot license, either AGPLv3 or Botpress License 107 | - .gitignore // ignoring some botpress-created files by default 108 | ``` 109 | 110 | ### 8. Start coding 111 | 112 | Now, open the `index.js` file and write (or paste) these lines of code. This is a simple to do list. 113 | 114 | ```js 115 | module.exports = function(bp) { 116 | bp.middlewares.load() 117 | 118 | /* Things to do: 119 | [ ] Answering to hello world 120 | [ ] Answering to any other message 121 | */ 122 | } 123 | ``` 124 | 125 | **Tip:** When you are coding, using a to do list is good practice because it helps you to stay focused and to know exactly what needs to be done. 126 | 127 | ### 9. Answer a "hello world" user message 128 | 129 | First, we will set up a basic answer to "hello world" from Facebook. You simply write (or paste) these lines into `index.js`. 130 | 131 | ```js 132 | module.exports = function(bp) { 133 | bp.middlewares.load() 134 | 135 | //Catch 'hello world' from 'facebook' 136 | bp.hear({ 137 | platform: 'facebook', 138 | type: 'message', 139 | text: 'hello world' 140 | }, (event, next) => { 141 | const id = event.user.id 142 | const last_name = event.user.last_name 143 | const first_name = event.user.first_name 144 | 145 | const text = 'Congrats ' + first_name + " " + last_name + "! Your first chatbot using Botpress is now alive." 146 | bp.messenger.sendText(id, text) 147 | }) 148 | } 149 | ``` 150 | 151 | We use `hear` which is a built-in function of `bp` to listen on specific `event` conditions. In this case, we are listening on `platform: 'facebook'`, `type: 'message'`, and `text: 'hello world'`. When those conditions are respected, the `callback` function is called and it sends a custom answer to this specific `user`. 152 | 153 | **Note**: You can restart your bot in the command line by running `botpress start` and your bot will now answer to "hello world" when you chat with it directly in Messenger. 154 | 155 | ### 10. Answer any other user message 156 | 157 | From there, your bot now answers to "hello world", but it doesn't answer to anything else. We'll now fix that and add a default answer to other messages. To do it, you only need to `hear` on different conditions. 158 | 159 | ```js 160 | module.exports = function(bp) { 161 | 162 | // ... (Catch 'hello world from 'facebook' code) 163 | 164 | //Catch any 'message' from 'facebook' 165 | bp.hear({ 166 | platform: 'facebook', 167 | type: 'message', 168 | text: /.+/i 169 | }, (event, next) => { 170 | bp.messenger.sendText(event.user.id, "Sorry, I only answer to 'hello world'...") 171 | }) 172 | } 173 | ``` 174 | 175 | As you can see, `hear` supports regex expressions and in our case it's exactly what we want. If you don't have any experience using regex, just notice that `text: /.+/i` will be respected for any text entry. 176 | 177 | ## Have fun 178 | 179 | Building a bot with Botpress is as simple as that! 180 | 181 | Feel free to fork our bot, send pull requests, clone it, send comments, etc. 182 | 183 | ## Community 184 | 185 | Pull requests are welcome! We believe that everyone's contributions will create something big and impactful. 186 | 187 | There's a [Slack community](https://slack.botpress.io) where you are welcome to join us, ask questions, and even help others. 188 | 189 | Get an invite and join us now! 👉[https://slack.botpress.io](https://slack.botpress.io). 190 | 191 | ## License 192 | 193 | `hello-world-bot` is licensed under [AGPL-3.0](/LICENSE). 194 | -------------------------------------------------------------------------------- /hello-world-bot/assets/connexion-settings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/botpress/botpress-examples/73e37c01ec3f6342c827f713f7beb5b086e86f0f/hello-world-bot/assets/connexion-settings.png -------------------------------------------------------------------------------- /hello-world-bot/botfile.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | 3 | /** 4 | * where the content is stored 5 | * you can access this property from `bp.dataLocation` 6 | */ 7 | dataDir: "./data", 8 | 9 | modulesConfigDir: "./modules_config", 10 | disableFileLogs: false, 11 | notification: { 12 | file: 'notifications.json', 13 | maxLength: 50 14 | }, 15 | log: { 16 | file: 'bot.log', 17 | maxSize: 1e6 // 1mb 18 | }, 19 | 20 | /** 21 | * Access control of admin pabel 22 | */ 23 | login: { 24 | enabled: process.env.NODE_ENV === 'production', 25 | tokenExpiry: "6 hours", 26 | password: "password", 27 | maxAttempts: 3, 28 | resetAfter: 5 * 60 * 10000 // 5 minutes 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /hello-world-bot/index.js: -------------------------------------------------------------------------------- 1 | module.exports = function(bp) { 2 | bp.middlewares.load() 3 | 4 | //Catch 'hello world' from 'facebook' 5 | bp.hear({ 6 | platform: 'facebook', 7 | type: 'message', 8 | text: 'hello world' 9 | }, (event, next) => { 10 | const id = event.user.id 11 | const last_name = event.user.last_name 12 | const first_name = event.user.first_name 13 | 14 | const text = 'Congrats ' + first_name + " " + last_name + "! Your first chatbot using Botpress is now working." 15 | bp.messenger.sendText(id, text) 16 | }) 17 | 18 | //Catch any 'message' from 'facebook' 19 | bp.hear({ 20 | platform: 'facebook', 21 | type: 'message', 22 | text: /.+/i 23 | }, (event, next) => { 24 | bp.messenger.sendText(event.user.id, "Sorry, I only answer to 'hello world'...") 25 | }) 26 | } 27 | -------------------------------------------------------------------------------- /hello-world-bot/modules_config/botpress-messenger.json: -------------------------------------------------------------------------------- 1 | {"applicationID":"","accessToken":"","appSecret":"","verifyToken":"6e69021a-8e89-4ca0-88f0-58c4a1bad029","validated":false,"connected":false,"hostname":"","ngrok":false,"displayGetStarted":false,"greetingMessage":"Default greeting message","persistentMenu":false,"persistentMenuItems":[],"automaticallyMarkAsRead":true,"trustedDomains":[],"autoRespondGetStarted":true,"autoResponse":"Hello!","error":null,"homepage":"https://github.com/botpress/botpress-messenger"} -------------------------------------------------------------------------------- /hello-world-bot/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "hello-world-bot", 3 | "version": "0.0.1", 4 | "description": "Tutorial of a simple hello world bot.", 5 | "main": "index.js", 6 | "dependencies": { 7 | "botpress": "0.x", 8 | "botpress-messenger": "^1.0.9" 9 | }, 10 | "scripts": { 11 | "start": "botpress start", 12 | "test": "echo \"Error: no test specified\" && exit 1" 13 | }, 14 | "author": "Botpress", 15 | "license": "AGPL-3.0" 16 | } 17 | -------------------------------------------------------------------------------- /hello-world-rivescript-bot/.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | /logs 3 | *.log 4 | npm-debug.log* 5 | 6 | # Runtime data 7 | pids 8 | *.pid 9 | *.seed 10 | *.pid.lock 11 | 12 | # Directory for instrumented libs generated by jscoverage/JSCover 13 | lib-cov 14 | 15 | # Coverage directory used by tools like istanbul 16 | coverage 17 | 18 | # nyc test coverage 19 | .nyc_output 20 | 21 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 22 | .grunt 23 | 24 | # node-waf configuration 25 | .lock-wscript 26 | 27 | # Compiled binary addons (http://nodejs.org/api/addons.html) 28 | build/Release 29 | 30 | # Dependency directories 31 | node_modules 32 | jspm_packages 33 | 34 | # Optional npm cache directory 35 | .npm 36 | 37 | # Optional eslint cache 38 | .eslintcache 39 | 40 | # Optional REPL history 41 | .node_repl_history 42 | 43 | # Output of 'npm pack' 44 | *.tgz 45 | 46 | # *** Botpress specifics *** 47 | data/* 48 | !data/rivescript/ 49 | -------------------------------------------------------------------------------- /hello-world-rivescript-bot/LICENSE: -------------------------------------------------------------------------------- 1 | GNU AFFERO GENERAL PUBLIC LICENSE 2 | Version 3, 19 November 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU Affero General Public License is a free, copyleft license for 11 | software and other kinds of works, specifically designed to ensure 12 | cooperation with the community in the case of network server software. 13 | 14 | The licenses for most software and other practical works are designed 15 | to take away your freedom to share and change the works. By contrast, 16 | our General Public Licenses are intended to guarantee your freedom to 17 | share and change all versions of a program--to make sure it remains free 18 | software for all its users. 19 | 20 | When we speak of free software, we are referring to freedom, not 21 | price. Our General Public Licenses are designed to make sure that you 22 | have the freedom to distribute copies of free software (and charge for 23 | them if you wish), that you receive source code or can get it if you 24 | want it, that you can change the software or use pieces of it in new 25 | free programs, and that you know you can do these things. 26 | 27 | Developers that use our General Public Licenses protect your rights 28 | with two steps: (1) assert copyright on the software, and (2) offer 29 | you this License which gives you legal permission to copy, distribute 30 | and/or modify the software. 31 | 32 | A secondary benefit of defending all users' freedom is that 33 | improvements made in alternate versions of the program, if they 34 | receive widespread use, become available for other developers to 35 | incorporate. Many developers of free software are heartened and 36 | encouraged by the resulting cooperation. However, in the case of 37 | software used on network servers, this result may fail to come about. 38 | The GNU General Public License permits making a modified version and 39 | letting the public access it on a server without ever releasing its 40 | source code to the public. 41 | 42 | The GNU Affero General Public License is designed specifically to 43 | ensure that, in such cases, the modified source code becomes available 44 | to the community. It requires the operator of a network server to 45 | provide the source code of the modified version running there to the 46 | users of that server. Therefore, public use of a modified version, on 47 | a publicly accessible server, gives the public access to the source 48 | code of the modified version. 49 | 50 | An older license, called the Affero General Public License and 51 | published by Affero, was designed to accomplish similar goals. This is 52 | a different license, not a version of the Affero GPL, but Affero has 53 | released a new version of the Affero GPL which permits relicensing under 54 | this license. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | TERMS AND CONDITIONS 60 | 61 | 0. Definitions. 62 | 63 | "This License" refers to version 3 of the GNU Affero General Public License. 64 | 65 | "Copyright" also means copyright-like laws that apply to other kinds of 66 | works, such as semiconductor masks. 67 | 68 | "The Program" refers to any copyrightable work licensed under this 69 | License. Each licensee is addressed as "you". "Licensees" and 70 | "recipients" may be individuals or organizations. 71 | 72 | To "modify" a work means to copy from or adapt all or part of the work 73 | in a fashion requiring copyright permission, other than the making of an 74 | exact copy. The resulting work is called a "modified version" of the 75 | earlier work or a work "based on" the earlier work. 76 | 77 | A "covered work" means either the unmodified Program or a work based 78 | on the Program. 79 | 80 | To "propagate" a work means to do anything with it that, without 81 | permission, would make you directly or secondarily liable for 82 | infringement under applicable copyright law, except executing it on a 83 | computer or modifying a private copy. Propagation includes copying, 84 | distribution (with or without modification), making available to the 85 | public, and in some countries other activities as well. 86 | 87 | To "convey" a work means any kind of propagation that enables other 88 | parties to make or receive copies. Mere interaction with a user through 89 | a computer network, with no transfer of a copy, is not conveying. 90 | 91 | An interactive user interface displays "Appropriate Legal Notices" 92 | to the extent that it includes a convenient and prominently visible 93 | feature that (1) displays an appropriate copyright notice, and (2) 94 | tells the user that there is no warranty for the work (except to the 95 | extent that warranties are provided), that licensees may convey the 96 | work under this License, and how to view a copy of this License. If 97 | the interface presents a list of user commands or options, such as a 98 | menu, a prominent item in the list meets this criterion. 99 | 100 | 1. Source Code. 101 | 102 | The "source code" for a work means the preferred form of the work 103 | for making modifications to it. "Object code" means any non-source 104 | form of a work. 105 | 106 | A "Standard Interface" means an interface that either is an official 107 | standard defined by a recognized standards body, or, in the case of 108 | interfaces specified for a particular programming language, one that 109 | is widely used among developers working in that language. 110 | 111 | The "System Libraries" of an executable work include anything, other 112 | than the work as a whole, that (a) is included in the normal form of 113 | packaging a Major Component, but which is not part of that Major 114 | Component, and (b) serves only to enable use of the work with that 115 | Major Component, or to implement a Standard Interface for which an 116 | implementation is available to the public in source code form. A 117 | "Major Component", in this context, means a major essential component 118 | (kernel, window system, and so on) of the specific operating system 119 | (if any) on which the executable work runs, or a compiler used to 120 | produce the work, or an object code interpreter used to run it. 121 | 122 | The "Corresponding Source" for a work in object code form means all 123 | the source code needed to generate, install, and (for an executable 124 | work) run the object code and to modify the work, including scripts to 125 | control those activities. However, it does not include the work's 126 | System Libraries, or general-purpose tools or generally available free 127 | programs which are used unmodified in performing those activities but 128 | which are not part of the work. For example, Corresponding Source 129 | includes interface definition files associated with source files for 130 | the work, and the source code for shared libraries and dynamically 131 | linked subprograms that the work is specifically designed to require, 132 | such as by intimate data communication or control flow between those 133 | subprograms and other parts of the work. 134 | 135 | The Corresponding Source need not include anything that users 136 | can regenerate automatically from other parts of the Corresponding 137 | Source. 138 | 139 | The Corresponding Source for a work in source code form is that 140 | same work. 141 | 142 | 2. Basic Permissions. 143 | 144 | All rights granted under this License are granted for the term of 145 | copyright on the Program, and are irrevocable provided the stated 146 | conditions are met. This License explicitly affirms your unlimited 147 | permission to run the unmodified Program. The output from running a 148 | covered work is covered by this License only if the output, given its 149 | content, constitutes a covered work. This License acknowledges your 150 | rights of fair use or other equivalent, as provided by copyright law. 151 | 152 | You may make, run and propagate covered works that you do not 153 | convey, without conditions so long as your license otherwise remains 154 | in force. You may convey covered works to others for the sole purpose 155 | of having them make modifications exclusively for you, or provide you 156 | with facilities for running those works, provided that you comply with 157 | the terms of this License in conveying all material for which you do 158 | not control copyright. Those thus making or running the covered works 159 | for you must do so exclusively on your behalf, under your direction 160 | and control, on terms that prohibit them from making any copies of 161 | your copyrighted material outside their relationship with you. 162 | 163 | Conveying under any other circumstances is permitted solely under 164 | the conditions stated below. Sublicensing is not allowed; section 10 165 | makes it unnecessary. 166 | 167 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 168 | 169 | No covered work shall be deemed part of an effective technological 170 | measure under any applicable law fulfilling obligations under article 171 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 172 | similar laws prohibiting or restricting circumvention of such 173 | measures. 174 | 175 | When you convey a covered work, you waive any legal power to forbid 176 | circumvention of technological measures to the extent such circumvention 177 | is effected by exercising rights under this License with respect to 178 | the covered work, and you disclaim any intention to limit operation or 179 | modification of the work as a means of enforcing, against the work's 180 | users, your or third parties' legal rights to forbid circumvention of 181 | technological measures. 182 | 183 | 4. Conveying Verbatim Copies. 184 | 185 | You may convey verbatim copies of the Program's source code as you 186 | receive it, in any medium, provided that you conspicuously and 187 | appropriately publish on each copy an appropriate copyright notice; 188 | keep intact all notices stating that this License and any 189 | non-permissive terms added in accord with section 7 apply to the code; 190 | keep intact all notices of the absence of any warranty; and give all 191 | recipients a copy of this License along with the Program. 192 | 193 | You may charge any price or no price for each copy that you convey, 194 | and you may offer support or warranty protection for a fee. 195 | 196 | 5. Conveying Modified Source Versions. 197 | 198 | You may convey a work based on the Program, or the modifications to 199 | produce it from the Program, in the form of source code under the 200 | terms of section 4, provided that you also meet all of these conditions: 201 | 202 | a) The work must carry prominent notices stating that you modified 203 | it, and giving a relevant date. 204 | 205 | b) The work must carry prominent notices stating that it is 206 | released under this License and any conditions added under section 207 | 7. This requirement modifies the requirement in section 4 to 208 | "keep intact all notices". 209 | 210 | c) You must license the entire work, as a whole, under this 211 | License to anyone who comes into possession of a copy. This 212 | License will therefore apply, along with any applicable section 7 213 | additional terms, to the whole of the work, and all its parts, 214 | regardless of how they are packaged. This License gives no 215 | permission to license the work in any other way, but it does not 216 | invalidate such permission if you have separately received it. 217 | 218 | d) If the work has interactive user interfaces, each must display 219 | Appropriate Legal Notices; however, if the Program has interactive 220 | interfaces that do not display Appropriate Legal Notices, your 221 | work need not make them do so. 222 | 223 | A compilation of a covered work with other separate and independent 224 | works, which are not by their nature extensions of the covered work, 225 | and which are not combined with it such as to form a larger program, 226 | in or on a volume of a storage or distribution medium, is called an 227 | "aggregate" if the compilation and its resulting copyright are not 228 | used to limit the access or legal rights of the compilation's users 229 | beyond what the individual works permit. Inclusion of a covered work 230 | in an aggregate does not cause this License to apply to the other 231 | parts of the aggregate. 232 | 233 | 6. Conveying Non-Source Forms. 234 | 235 | You may convey a covered work in object code form under the terms 236 | of sections 4 and 5, provided that you also convey the 237 | machine-readable Corresponding Source under the terms of this License, 238 | in one of these ways: 239 | 240 | a) Convey the object code in, or embodied in, a physical product 241 | (including a physical distribution medium), accompanied by the 242 | Corresponding Source fixed on a durable physical medium 243 | customarily used for software interchange. 244 | 245 | b) Convey the object code in, or embodied in, a physical product 246 | (including a physical distribution medium), accompanied by a 247 | written offer, valid for at least three years and valid for as 248 | long as you offer spare parts or customer support for that product 249 | model, to give anyone who possesses the object code either (1) a 250 | copy of the Corresponding Source for all the software in the 251 | product that is covered by this License, on a durable physical 252 | medium customarily used for software interchange, for a price no 253 | more than your reasonable cost of physically performing this 254 | conveying of source, or (2) access to copy the 255 | Corresponding Source from a network server at no charge. 256 | 257 | c) Convey individual copies of the object code with a copy of the 258 | written offer to provide the Corresponding Source. This 259 | alternative is allowed only occasionally and noncommercially, and 260 | only if you received the object code with such an offer, in accord 261 | with subsection 6b. 262 | 263 | d) Convey the object code by offering access from a designated 264 | place (gratis or for a charge), and offer equivalent access to the 265 | Corresponding Source in the same way through the same place at no 266 | further charge. You need not require recipients to copy the 267 | Corresponding Source along with the object code. If the place to 268 | copy the object code is a network server, the Corresponding Source 269 | may be on a different server (operated by you or a third party) 270 | that supports equivalent copying facilities, provided you maintain 271 | clear directions next to the object code saying where to find the 272 | Corresponding Source. Regardless of what server hosts the 273 | Corresponding Source, you remain obligated to ensure that it is 274 | available for as long as needed to satisfy these requirements. 275 | 276 | e) Convey the object code using peer-to-peer transmission, provided 277 | you inform other peers where the object code and Corresponding 278 | Source of the work are being offered to the general public at no 279 | charge under subsection 6d. 280 | 281 | A separable portion of the object code, whose source code is excluded 282 | from the Corresponding Source as a System Library, need not be 283 | included in conveying the object code work. 284 | 285 | A "User Product" is either (1) a "consumer product", which means any 286 | tangible personal property which is normally used for personal, family, 287 | or household purposes, or (2) anything designed or sold for incorporation 288 | into a dwelling. In determining whether a product is a consumer product, 289 | doubtful cases shall be resolved in favor of coverage. For a particular 290 | product received by a particular user, "normally used" refers to a 291 | typical or common use of that class of product, regardless of the status 292 | of the particular user or of the way in which the particular user 293 | actually uses, or expects or is expected to use, the product. A product 294 | is a consumer product regardless of whether the product has substantial 295 | commercial, industrial or non-consumer uses, unless such uses represent 296 | the only significant mode of use of the product. 297 | 298 | "Installation Information" for a User Product means any methods, 299 | procedures, authorization keys, or other information required to install 300 | and execute modified versions of a covered work in that User Product from 301 | a modified version of its Corresponding Source. The information must 302 | suffice to ensure that the continued functioning of the modified object 303 | code is in no case prevented or interfered with solely because 304 | modification has been made. 305 | 306 | If you convey an object code work under this section in, or with, or 307 | specifically for use in, a User Product, and the conveying occurs as 308 | part of a transaction in which the right of possession and use of the 309 | User Product is transferred to the recipient in perpetuity or for a 310 | fixed term (regardless of how the transaction is characterized), the 311 | Corresponding Source conveyed under this section must be accompanied 312 | by the Installation Information. But this requirement does not apply 313 | if neither you nor any third party retains the ability to install 314 | modified object code on the User Product (for example, the work has 315 | been installed in ROM). 316 | 317 | The requirement to provide Installation Information does not include a 318 | requirement to continue to provide support service, warranty, or updates 319 | for a work that has been modified or installed by the recipient, or for 320 | the User Product in which it has been modified or installed. Access to a 321 | network may be denied when the modification itself materially and 322 | adversely affects the operation of the network or violates the rules and 323 | protocols for communication across the network. 324 | 325 | Corresponding Source conveyed, and Installation Information provided, 326 | in accord with this section must be in a format that is publicly 327 | documented (and with an implementation available to the public in 328 | source code form), and must require no special password or key for 329 | unpacking, reading or copying. 330 | 331 | 7. Additional Terms. 332 | 333 | "Additional permissions" are terms that supplement the terms of this 334 | License by making exceptions from one or more of its conditions. 335 | Additional permissions that are applicable to the entire Program shall 336 | be treated as though they were included in this License, to the extent 337 | that they are valid under applicable law. If additional permissions 338 | apply only to part of the Program, that part may be used separately 339 | under those permissions, but the entire Program remains governed by 340 | this License without regard to the additional permissions. 341 | 342 | When you convey a copy of a covered work, you may at your option 343 | remove any additional permissions from that copy, or from any part of 344 | it. (Additional permissions may be written to require their own 345 | removal in certain cases when you modify the work.) You may place 346 | additional permissions on material, added by you to a covered work, 347 | for which you have or can give appropriate copyright permission. 348 | 349 | Notwithstanding any other provision of this License, for material you 350 | add to a covered work, you may (if authorized by the copyright holders of 351 | that material) supplement the terms of this License with terms: 352 | 353 | a) Disclaiming warranty or limiting liability differently from the 354 | terms of sections 15 and 16 of this License; or 355 | 356 | b) Requiring preservation of specified reasonable legal notices or 357 | author attributions in that material or in the Appropriate Legal 358 | Notices displayed by works containing it; or 359 | 360 | c) Prohibiting misrepresentation of the origin of that material, or 361 | requiring that modified versions of such material be marked in 362 | reasonable ways as different from the original version; or 363 | 364 | d) Limiting the use for publicity purposes of names of licensors or 365 | authors of the material; or 366 | 367 | e) Declining to grant rights under trademark law for use of some 368 | trade names, trademarks, or service marks; or 369 | 370 | f) Requiring indemnification of licensors and authors of that 371 | material by anyone who conveys the material (or modified versions of 372 | it) with contractual assumptions of liability to the recipient, for 373 | any liability that these contractual assumptions directly impose on 374 | those licensors and authors. 375 | 376 | All other non-permissive additional terms are considered "further 377 | restrictions" within the meaning of section 10. If the Program as you 378 | received it, or any part of it, contains a notice stating that it is 379 | governed by this License along with a term that is a further 380 | restriction, you may remove that term. If a license document contains 381 | a further restriction but permits relicensing or conveying under this 382 | License, you may add to a covered work material governed by the terms 383 | of that license document, provided that the further restriction does 384 | not survive such relicensing or conveying. 385 | 386 | If you add terms to a covered work in accord with this section, you 387 | must place, in the relevant source files, a statement of the 388 | additional terms that apply to those files, or a notice indicating 389 | where to find the applicable terms. 390 | 391 | Additional terms, permissive or non-permissive, may be stated in the 392 | form of a separately written license, or stated as exceptions; 393 | the above requirements apply either way. 394 | 395 | 8. Termination. 396 | 397 | You may not propagate or modify a covered work except as expressly 398 | provided under this License. Any attempt otherwise to propagate or 399 | modify it is void, and will automatically terminate your rights under 400 | this License (including any patent licenses granted under the third 401 | paragraph of section 11). 402 | 403 | However, if you cease all violation of this License, then your 404 | license from a particular copyright holder is reinstated (a) 405 | provisionally, unless and until the copyright holder explicitly and 406 | finally terminates your license, and (b) permanently, if the copyright 407 | holder fails to notify you of the violation by some reasonable means 408 | prior to 60 days after the cessation. 409 | 410 | Moreover, your license from a particular copyright holder is 411 | reinstated permanently if the copyright holder notifies you of the 412 | violation by some reasonable means, this is the first time you have 413 | received notice of violation of this License (for any work) from that 414 | copyright holder, and you cure the violation prior to 30 days after 415 | your receipt of the notice. 416 | 417 | Termination of your rights under this section does not terminate the 418 | licenses of parties who have received copies or rights from you under 419 | this License. If your rights have been terminated and not permanently 420 | reinstated, you do not qualify to receive new licenses for the same 421 | material under section 10. 422 | 423 | 9. Acceptance Not Required for Having Copies. 424 | 425 | You are not required to accept this License in order to receive or 426 | run a copy of the Program. Ancillary propagation of a covered work 427 | occurring solely as a consequence of using peer-to-peer transmission 428 | to receive a copy likewise does not require acceptance. However, 429 | nothing other than this License grants you permission to propagate or 430 | modify any covered work. These actions infringe copyright if you do 431 | not accept this License. Therefore, by modifying or propagating a 432 | covered work, you indicate your acceptance of this License to do so. 433 | 434 | 10. Automatic Licensing of Downstream Recipients. 435 | 436 | Each time you convey a covered work, the recipient automatically 437 | receives a license from the original licensors, to run, modify and 438 | propagate that work, subject to this License. You are not responsible 439 | for enforcing compliance by third parties with this License. 440 | 441 | An "entity transaction" is a transaction transferring control of an 442 | organization, or substantially all assets of one, or subdividing an 443 | organization, or merging organizations. If propagation of a covered 444 | work results from an entity transaction, each party to that 445 | transaction who receives a copy of the work also receives whatever 446 | licenses to the work the party's predecessor in interest had or could 447 | give under the previous paragraph, plus a right to possession of the 448 | Corresponding Source of the work from the predecessor in interest, if 449 | the predecessor has it or can get it with reasonable efforts. 450 | 451 | You may not impose any further restrictions on the exercise of the 452 | rights granted or affirmed under this License. For example, you may 453 | not impose a license fee, royalty, or other charge for exercise of 454 | rights granted under this License, and you may not initiate litigation 455 | (including a cross-claim or counterclaim in a lawsuit) alleging that 456 | any patent claim is infringed by making, using, selling, offering for 457 | sale, or importing the Program or any portion of it. 458 | 459 | 11. Patents. 460 | 461 | A "contributor" is a copyright holder who authorizes use under this 462 | License of the Program or a work on which the Program is based. The 463 | work thus licensed is called the contributor's "contributor version". 464 | 465 | A contributor's "essential patent claims" are all patent claims 466 | owned or controlled by the contributor, whether already acquired or 467 | hereafter acquired, that would be infringed by some manner, permitted 468 | by this License, of making, using, or selling its contributor version, 469 | but do not include claims that would be infringed only as a 470 | consequence of further modification of the contributor version. For 471 | purposes of this definition, "control" includes the right to grant 472 | patent sublicenses in a manner consistent with the requirements of 473 | this License. 474 | 475 | Each contributor grants you a non-exclusive, worldwide, royalty-free 476 | patent license under the contributor's essential patent claims, to 477 | make, use, sell, offer for sale, import and otherwise run, modify and 478 | propagate the contents of its contributor version. 479 | 480 | In the following three paragraphs, a "patent license" is any express 481 | agreement or commitment, however denominated, not to enforce a patent 482 | (such as an express permission to practice a patent or covenant not to 483 | sue for patent infringement). To "grant" such a patent license to a 484 | party means to make such an agreement or commitment not to enforce a 485 | patent against the party. 486 | 487 | If you convey a covered work, knowingly relying on a patent license, 488 | and the Corresponding Source of the work is not available for anyone 489 | to copy, free of charge and under the terms of this License, through a 490 | publicly available network server or other readily accessible means, 491 | then you must either (1) cause the Corresponding Source to be so 492 | available, or (2) arrange to deprive yourself of the benefit of the 493 | patent license for this particular work, or (3) arrange, in a manner 494 | consistent with the requirements of this License, to extend the patent 495 | license to downstream recipients. "Knowingly relying" means you have 496 | actual knowledge that, but for the patent license, your conveying the 497 | covered work in a country, or your recipient's use of the covered work 498 | in a country, would infringe one or more identifiable patents in that 499 | country that you have reason to believe are valid. 500 | 501 | If, pursuant to or in connection with a single transaction or 502 | arrangement, you convey, or propagate by procuring conveyance of, a 503 | covered work, and grant a patent license to some of the parties 504 | receiving the covered work authorizing them to use, propagate, modify 505 | or convey a specific copy of the covered work, then the patent license 506 | you grant is automatically extended to all recipients of the covered 507 | work and works based on it. 508 | 509 | A patent license is "discriminatory" if it does not include within 510 | the scope of its coverage, prohibits the exercise of, or is 511 | conditioned on the non-exercise of one or more of the rights that are 512 | specifically granted under this License. You may not convey a covered 513 | work if you are a party to an arrangement with a third party that is 514 | in the business of distributing software, under which you make payment 515 | to the third party based on the extent of your activity of conveying 516 | the work, and under which the third party grants, to any of the 517 | parties who would receive the covered work from you, a discriminatory 518 | patent license (a) in connection with copies of the covered work 519 | conveyed by you (or copies made from those copies), or (b) primarily 520 | for and in connection with specific products or compilations that 521 | contain the covered work, unless you entered into that arrangement, 522 | or that patent license was granted, prior to 28 March 2007. 523 | 524 | Nothing in this License shall be construed as excluding or limiting 525 | any implied license or other defenses to infringement that may 526 | otherwise be available to you under applicable patent law. 527 | 528 | 12. No Surrender of Others' Freedom. 529 | 530 | If conditions are imposed on you (whether by court order, agreement or 531 | otherwise) that contradict the conditions of this License, they do not 532 | excuse you from the conditions of this License. If you cannot convey a 533 | covered work so as to satisfy simultaneously your obligations under this 534 | License and any other pertinent obligations, then as a consequence you may 535 | not convey it at all. For example, if you agree to terms that obligate you 536 | to collect a royalty for further conveying from those to whom you convey 537 | the Program, the only way you could satisfy both those terms and this 538 | License would be to refrain entirely from conveying the Program. 539 | 540 | 13. Remote Network Interaction; Use with the GNU General Public License. 541 | 542 | Notwithstanding any other provision of this License, if you modify the 543 | Program, your modified version must prominently offer all users 544 | interacting with it remotely through a computer network (if your version 545 | supports such interaction) an opportunity to receive the Corresponding 546 | Source of your version by providing access to the Corresponding Source 547 | from a network server at no charge, through some standard or customary 548 | means of facilitating copying of software. This Corresponding Source 549 | shall include the Corresponding Source for any work covered by version 3 550 | of the GNU General Public License that is incorporated pursuant to the 551 | following paragraph. 552 | 553 | Notwithstanding any other provision of this License, you have 554 | permission to link or combine any covered work with a work licensed 555 | under version 3 of the GNU General Public License into a single 556 | combined work, and to convey the resulting work. The terms of this 557 | License will continue to apply to the part which is the covered work, 558 | but the work with which it is combined will remain governed by version 559 | 3 of the GNU General Public License. 560 | 561 | 14. Revised Versions of this License. 562 | 563 | The Free Software Foundation may publish revised and/or new versions of 564 | the GNU Affero General Public License from time to time. Such new versions 565 | will be similar in spirit to the present version, but may differ in detail to 566 | address new problems or concerns. 567 | 568 | Each version is given a distinguishing version number. If the 569 | Program specifies that a certain numbered version of the GNU Affero General 570 | Public License "or any later version" applies to it, you have the 571 | option of following the terms and conditions either of that numbered 572 | version or of any later version published by the Free Software 573 | Foundation. If the Program does not specify a version number of the 574 | GNU Affero General Public License, you may choose any version ever published 575 | by the Free Software Foundation. 576 | 577 | If the Program specifies that a proxy can decide which future 578 | versions of the GNU Affero General Public License can be used, that proxy's 579 | public statement of acceptance of a version permanently authorizes you 580 | to choose that version for the Program. 581 | 582 | Later license versions may give you additional or different 583 | permissions. However, no additional obligations are imposed on any 584 | author or copyright holder as a result of your choosing to follow a 585 | later version. 586 | 587 | 15. Disclaimer of Warranty. 588 | 589 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 590 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 591 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 592 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 593 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 594 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 595 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 596 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 597 | 598 | 16. Limitation of Liability. 599 | 600 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 601 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 602 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 603 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 604 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 605 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 606 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 607 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 608 | SUCH DAMAGES. 609 | 610 | 17. Interpretation of Sections 15 and 16. 611 | 612 | If the disclaimer of warranty and limitation of liability provided 613 | above cannot be given local legal effect according to their terms, 614 | reviewing courts shall apply local law that most closely approximates 615 | an absolute waiver of all civil liability in connection with the 616 | Program, unless a warranty or assumption of liability accompanies a 617 | copy of the Program in return for a fee. 618 | 619 | END OF TERMS AND CONDITIONS 620 | 621 | How to Apply These Terms to Your New Programs 622 | 623 | If you develop a new program, and you want it to be of the greatest 624 | possible use to the public, the best way to achieve this is to make it 625 | free software which everyone can redistribute and change under these terms. 626 | 627 | To do so, attach the following notices to the program. It is safest 628 | to attach them to the start of each source file to most effectively 629 | state the exclusion of warranty; and each file should have at least 630 | the "copyright" line and a pointer to where the full notice is found. 631 | 632 | 633 | Copyright (C) 634 | 635 | This program is free software: you can redistribute it and/or modify 636 | it under the terms of the GNU Affero General Public License as published by 637 | the Free Software Foundation, either version 3 of the License, or 638 | (at your option) any later version. 639 | 640 | This program is distributed in the hope that it will be useful, 641 | but WITHOUT ANY WARRANTY; without even the implied warranty of 642 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 643 | GNU Affero General Public License for more details. 644 | 645 | You should have received a copy of the GNU Affero General Public License 646 | along with this program. If not, see . 647 | 648 | Also add information on how to contact you by electronic and paper mail. 649 | 650 | If your software can interact with users remotely through a computer 651 | network, you should also make sure that it provides a way for users to 652 | get its source. For example, if your program is a web application, its 653 | interface could display a "Source" link that leads users to an archive 654 | of the code. There are many ways you could offer source, and different 655 | solutions will be better for different programs; see section 13 for the 656 | specific requirements. 657 | 658 | You should also get your employer (if you work as a programmer) or school, 659 | if any, to sign a "copyright disclaimer" for the program, if necessary. 660 | For more information on this, and how to apply and follow the GNU AGPL, see 661 | . 662 | -------------------------------------------------------------------------------- /hello-world-rivescript-bot/README.md: -------------------------------------------------------------------------------- 1 | # Tutorial 2 | 3 | This tutorial will show you how easy it is to build a "hello world" bot using the Messenger and RiveScript modules. RiveScript is a simple and powerful scripting language for chatbots, and if it's your first time using it, we recommend reading the [official documentation](https://www.rivescript.com/). 4 | 5 | This exercise should take you less than 10 minutes, without writing a single line of code. If you have any problems, don't hesitate to talk to us on our [Public Community](https://slack.botpress.io). It will be a pleasure for us to answer your requests. 6 | 7 | ## Table of contents 8 | * [Requirements](#requirements) 9 | * [Step-by-step](#step-by-step) 10 | * [Install Botpress](#install-botpress) 11 | * [Create a new repository](#create-new-repo) 12 | * [Initialize Botpress](#initialize-botpress) 13 | * [Install Botpress modules](#install-botpress-modules) 14 | * [Start Botpress](#start-botpress) 15 | * [Configure Messenger connection settings](#configure-messenger) 16 | * [Verifying your configuration](#verifying-connection) 17 | * [Answer a "hello world" user statement](#answer-hello-world) 18 | * [Testing your code](#testing-code) 19 | * [Creating or deleting RiveScript files](#creating-rivescript-files) 20 | * [Specify open-ended triggers](#specify-triggers) 21 | * [Have fun](#have-fun) 22 | * [Community](#community) 23 | * [License](#license) 24 | 25 | ## Requirements 26 | 27 | Botpress requires [node](https://nodejs.org) (version >= 4.2) and uses [npm](https://www.npmjs.com) as package manager. 28 | 29 | ## Step-by-step 30 | 31 | ### 1. Install Botpress 32 | 33 | You first need to have `botpress` installed as a general dependency using `npm`. If `npm` is already installed, you can install Botpress with the following command (make sure to install it globally): 34 | 35 | ``` 36 | npm install -g botpress 37 | ``` 38 | 39 | ### 2. Create a new repository 40 | 41 | Once `botpress` has been installed, you create a new repository and cd into it. 42 | 43 | ```js 44 | mkdir hello-world-rivescript-bot && cd hello-world-rivescript-bot // Mac and Linux users 45 | 46 | md hello-world-rivescript-bot && cd hello-world-rivescript-bot // Windows users 47 | ``` 48 | 49 | ### 3. Initialize Botpress 50 | 51 | Now, let's use the command line interface of `botpress` to initialize your bot: 52 | 53 | ``` 54 | botpress init 55 | ``` 56 | 57 | ### 4. Install Botpress modules 58 | 59 | In your command line again, you need to install the [botpress-messenger](https://github.com/botpress/botpress-messenger) module to be able to connect your bot to your Facebook page. Also, you will install the [botpress-rivescript](https://github.com/botpress/botpress-rivescript) module to add some basic interaction. 60 | 61 | ``` 62 | botpress install messenger rivescript 63 | ``` 64 | 65 | ### 5. Start Botpress 66 | 67 | Once everything is installed, you can start your bot and see what it includes. 68 | 69 | ``` 70 | botpress start 71 | ``` 72 | 73 | A local instance of your bot should be running at [http://localhost:3000](http://localhost:3000). From there you can install other modules as desired, but for this tutorial we only need `botpress-messenger` which we have just installed. 74 | 75 | ### 6. Configure Messenger connection settings 76 | 77 | First, you will need to configure Messenger so it's connected directly to your Facebook page. If this is your first time to configure Messenger, we recommend following our [getting started](https://docs.botpress.io/getting-started.html) guide in the official Botpress documentation. 78 | 79 | 80 | 81 | Briefly, you need to create a [Facebook page](https://www.facebook.com/pages/create) if you don't already have one. You also need to create a new [Messenger app](https://developers.facebook.com/) on Facebook. After that, you can find your **App ID**, **App Secret**, and **Token Access**, and paste them directly into the `botpress-messenger` module settings of the [Botpress user interface](http://localhost:3000/modules/botpress-messenger) running locally. Finally, you only need to activate [ngrok](https://ngrok.com/), and then validate and connect your bot. 82 | 83 | For further information on configuring `botpress-messenger` see the [Getting Started documentation](https://docs.botpress.io/getting-started.html). 84 | 85 | #### Verifying your configuration 86 | 87 | After connecting the Botpress Messenger module with your Facebook Messenger app in the step above, you can verify that everything's working by opening a chat tab on your Facebook page and typing `BOT_LICENSE`. 88 | 89 | The bot should answer your user message, for example with: 90 | 91 | ``` 92 | Bot: motivation-bot 93 | Created by: GB 94 | License: AGPL-3.0 95 | Botpress: 0.0.50 96 | ``` 97 | 98 | **Note**: `BOT_LICENSE` is a Botpress command to display basic information about your bot (name, version, licenses). 99 | 100 | ### 7. Answer a "hello world" user statement 101 | 102 | Next, you will add a basic answer to "hello world" in the [RiveScript module](http://localhost:3000/modules/botpress-rivescript) of the Botpress instance running locally. 103 | 104 | When you open the `botpress-rivescript` module, you see the `begin` file prepopulated with sample RiveScript code. Feel free to modify this code to customize the interaction of your chatbot. 105 | 106 | 107 | 108 | In this tutorial, we want to specify the bot's response to a user's "hello world" message (or **trigger** in RiveScript parlance). To do this, you add the following lines to your `begin` file. 109 | 110 | ``` 111 | + hello world 112 | - Botpress Team is happy to know that you have try our bot! 113 | ``` 114 | 115 | Click the Save button to save your code. 116 | 117 | #### Testing your code 118 | 119 | The `rivescript-module` enables you to rapidly test your code directly in Botpress. To do this, click the Go button to display a chat panel, and type your messages in field below. 120 | 121 | Click the Stop button to end testing. 122 | 123 | #### Creating or deleting RiveScript files 124 | 125 | You can create new files by clicking the File button , or delete them by clicking . 126 | 127 | 128 | ### 8. Specify open-ended triggers 129 | 130 | Finally, RiveScript allows you to specify wildcards or open-ended triggers for user messages containing variable data. You can find an example already provided in the `star` file (below), or you can specify your own wildcards. 131 | 132 | ``` 133 | + * 134 | - I'm not sure how to reply to that. I only understand 'hello world'... 135 | - I don't understand what you have said... 136 | - Sorry, I have been built to only answer to 'hello world'. 137 | ``` 138 | 139 | ## Have fun 140 | 141 | Building a bot with the RiveScript module is as simple as that! 142 | 143 | Feel free to fork our bot, send pull requests, clone it, send comments, ... 144 | 145 | ## Community 146 | 147 | Pull requests are welcome! We believe that it takes all of us to create something big and impactful. 148 | 149 | There's a [Slack community](https://slack.botpress.io) where you are welcome to join us, ask questions, and even help others. 150 | 151 | Get an invite and join us now! 👉[https://slack.botpress.io](https://slack.botpress.io). 152 | 153 | ## License 154 | 155 | `hello-world-bot` is licensed under [AGPL-3.0](/LICENSE). -------------------------------------------------------------------------------- /hello-world-rivescript-bot/assets/connexion-settings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/botpress/botpress-examples/73e37c01ec3f6342c827f713f7beb5b086e86f0f/hello-world-rivescript-bot/assets/connexion-settings.png -------------------------------------------------------------------------------- /hello-world-rivescript-bot/assets/delete-file.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/botpress/botpress-examples/73e37c01ec3f6342c827f713f7beb5b086e86f0f/hello-world-rivescript-bot/assets/delete-file.png -------------------------------------------------------------------------------- /hello-world-rivescript-bot/assets/new-file.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/botpress/botpress-examples/73e37c01ec3f6342c827f713f7beb5b086e86f0f/hello-world-rivescript-bot/assets/new-file.png -------------------------------------------------------------------------------- /hello-world-rivescript-bot/assets/rivescript-code.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/botpress/botpress-examples/73e37c01ec3f6342c827f713f7beb5b086e86f0f/hello-world-rivescript-bot/assets/rivescript-code.png -------------------------------------------------------------------------------- /hello-world-rivescript-bot/assets/save-script.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/botpress/botpress-examples/73e37c01ec3f6342c827f713f7beb5b086e86f0f/hello-world-rivescript-bot/assets/save-script.png -------------------------------------------------------------------------------- /hello-world-rivescript-bot/assets/stop.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/botpress/botpress-examples/73e37c01ec3f6342c827f713f7beb5b086e86f0f/hello-world-rivescript-bot/assets/stop.png -------------------------------------------------------------------------------- /hello-world-rivescript-bot/botfile.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | 3 | /** 4 | * where the content is stored 5 | * you can access this property from `bp.dataLocation` 6 | */ 7 | dataDir: "./data", 8 | 9 | modulesConfigDir: "./modules_config", 10 | disableFileLogs: false, 11 | notification: { 12 | file: 'notifications.json', 13 | maxLength: 50 14 | }, 15 | log: { 16 | file: 'bot.log', 17 | maxSize: 1e6 // 1mb 18 | }, 19 | 20 | /** 21 | * Access control of admin pabel 22 | */ 23 | login: { 24 | enabled: process.env.NODE_ENV === 'production', 25 | tokenExpiry: "6 hours", 26 | password: "password", 27 | maxAttempts: 3, 28 | resetAfter: 5 * 60 * 10000 // 5 minutes 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /hello-world-rivescript-bot/data/rivescript/begin.rive: -------------------------------------------------------------------------------- 1 | ! version = 2.0 2 | 3 | + hello world 4 | - Botpress Team is happy to know that you have try our bot! -------------------------------------------------------------------------------- /hello-world-rivescript-bot/data/rivescript/star.rive: -------------------------------------------------------------------------------- 1 | + * 2 | - I'm not sure how to reply to that. I only understand 'hello world'... 3 | - I don't understand what you have said... 4 | - Sorry, I have been built to only answer to 'hello world'. -------------------------------------------------------------------------------- /hello-world-rivescript-bot/index.js: -------------------------------------------------------------------------------- 1 | module.exports = function(bp) { 2 | bp.middlewares.load() 3 | } 4 | -------------------------------------------------------------------------------- /hello-world-rivescript-bot/modules_config/botpress-messenger.json: -------------------------------------------------------------------------------- 1 | {"applicationID":"","accessToken":"","appSecret":"","verifyToken":"be41fbb4-62b0-4b4f-8d21-4dd3b39a6efb","validated":false,"connected":false,"hostname":"","ngrok":false,"displayGetStarted":true,"greetingMessage":"Simple hello world example that only answer to 'hello world'...","persistentMenu":false,"persistentMenuItems":[],"automaticallyMarkAsRead":true,"trustedDomains":[],"autoRespondGetStarted":true,"autoResponse":"Welcome on Botpress!","error":null,"homepage":"https://github.com/botpress/botpress-messenger"} -------------------------------------------------------------------------------- /hello-world-rivescript-bot/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "hello-world", 3 | "version": "1.0.0", 4 | "description": "Botpress example of a simple hello world!", 5 | "main": "index.js", 6 | "dependencies": { 7 | "botpress": "0.x", 8 | "botpress-messenger": "^1.0.8", 9 | "botpress-rivescript": "^1.0.10" 10 | }, 11 | "scripts": { 12 | "start": "botpress start", 13 | "test": "echo \"Error: no test specified\" && exit 1" 14 | }, 15 | "author": "Botpress Team", 16 | "license": "AGPL-3.0" 17 | } 18 | -------------------------------------------------------------------------------- /motivation-bot/.dockerignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | npm-debug.log -------------------------------------------------------------------------------- /motivation-bot/.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | /logs 3 | *.log 4 | npm-debug.log* 5 | 6 | # Runtime data 7 | pids 8 | *.pid 9 | *.seed 10 | *.pid.lock 11 | 12 | # Directory for instrumented libs generated by jscoverage/JSCover 13 | lib-cov 14 | 15 | # Coverage directory used by tools like istanbul 16 | coverage 17 | 18 | # nyc test coverage 19 | .nyc_output 20 | 21 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 22 | .grunt 23 | 24 | # node-waf configuration 25 | .lock-wscript 26 | 27 | # Compiled binary addons (http://nodejs.org/api/addons.html) 28 | build/Release 29 | 30 | # Dependency directories 31 | node_modules 32 | jspm_packages 33 | 34 | # Optional npm cache directory 35 | .npm 36 | 37 | # Optional eslint cache 38 | .eslintcache 39 | 40 | # Optional REPL history 41 | .node_repl_history 42 | 43 | # Output of 'npm pack' 44 | *.tgz 45 | 46 | # *** Botpress specifics *** 47 | data/* 48 | !data/rivescript/ 49 | -------------------------------------------------------------------------------- /motivation-bot/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM node:6.9 2 | 3 | 4 | RUN mkdir -p /usr/src/app 5 | WORKDIR /usr/src/app 6 | COPY package.json /usr/src/app/ 7 | RUN npm install 8 | COPY . /usr/src/app 9 | 10 | EXPOSE 3000 11 | CMD [ "npm", "start" ] -------------------------------------------------------------------------------- /motivation-bot/LICENSE: -------------------------------------------------------------------------------- 1 | GNU AFFERO GENERAL PUBLIC LICENSE 2 | Version 3, 19 November 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU Affero General Public License is a free, copyleft license for 11 | software and other kinds of works, specifically designed to ensure 12 | cooperation with the community in the case of network server software. 13 | 14 | The licenses for most software and other practical works are designed 15 | to take away your freedom to share and change the works. By contrast, 16 | our General Public Licenses are intended to guarantee your freedom to 17 | share and change all versions of a program--to make sure it remains free 18 | software for all its users. 19 | 20 | When we speak of free software, we are referring to freedom, not 21 | price. Our General Public Licenses are designed to make sure that you 22 | have the freedom to distribute copies of free software (and charge for 23 | them if you wish), that you receive source code or can get it if you 24 | want it, that you can change the software or use pieces of it in new 25 | free programs, and that you know you can do these things. 26 | 27 | Developers that use our General Public Licenses protect your rights 28 | with two steps: (1) assert copyright on the software, and (2) offer 29 | you this License which gives you legal permission to copy, distribute 30 | and/or modify the software. 31 | 32 | A secondary benefit of defending all users' freedom is that 33 | improvements made in alternate versions of the program, if they 34 | receive widespread use, become available for other developers to 35 | incorporate. Many developers of free software are heartened and 36 | encouraged by the resulting cooperation. However, in the case of 37 | software used on network servers, this result may fail to come about. 38 | The GNU General Public License permits making a modified version and 39 | letting the public access it on a server without ever releasing its 40 | source code to the public. 41 | 42 | The GNU Affero General Public License is designed specifically to 43 | ensure that, in such cases, the modified source code becomes available 44 | to the community. It requires the operator of a network server to 45 | provide the source code of the modified version running there to the 46 | users of that server. Therefore, public use of a modified version, on 47 | a publicly accessible server, gives the public access to the source 48 | code of the modified version. 49 | 50 | An older license, called the Affero General Public License and 51 | published by Affero, was designed to accomplish similar goals. This is 52 | a different license, not a version of the Affero GPL, but Affero has 53 | released a new version of the Affero GPL which permits relicensing under 54 | this license. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | TERMS AND CONDITIONS 60 | 61 | 0. Definitions. 62 | 63 | "This License" refers to version 3 of the GNU Affero General Public License. 64 | 65 | "Copyright" also means copyright-like laws that apply to other kinds of 66 | works, such as semiconductor masks. 67 | 68 | "The Program" refers to any copyrightable work licensed under this 69 | License. Each licensee is addressed as "you". "Licensees" and 70 | "recipients" may be individuals or organizations. 71 | 72 | To "modify" a work means to copy from or adapt all or part of the work 73 | in a fashion requiring copyright permission, other than the making of an 74 | exact copy. The resulting work is called a "modified version" of the 75 | earlier work or a work "based on" the earlier work. 76 | 77 | A "covered work" means either the unmodified Program or a work based 78 | on the Program. 79 | 80 | To "propagate" a work means to do anything with it that, without 81 | permission, would make you directly or secondarily liable for 82 | infringement under applicable copyright law, except executing it on a 83 | computer or modifying a private copy. Propagation includes copying, 84 | distribution (with or without modification), making available to the 85 | public, and in some countries other activities as well. 86 | 87 | To "convey" a work means any kind of propagation that enables other 88 | parties to make or receive copies. Mere interaction with a user through 89 | a computer network, with no transfer of a copy, is not conveying. 90 | 91 | An interactive user interface displays "Appropriate Legal Notices" 92 | to the extent that it includes a convenient and prominently visible 93 | feature that (1) displays an appropriate copyright notice, and (2) 94 | tells the user that there is no warranty for the work (except to the 95 | extent that warranties are provided), that licensees may convey the 96 | work under this License, and how to view a copy of this License. If 97 | the interface presents a list of user commands or options, such as a 98 | menu, a prominent item in the list meets this criterion. 99 | 100 | 1. Source Code. 101 | 102 | The "source code" for a work means the preferred form of the work 103 | for making modifications to it. "Object code" means any non-source 104 | form of a work. 105 | 106 | A "Standard Interface" means an interface that either is an official 107 | standard defined by a recognized standards body, or, in the case of 108 | interfaces specified for a particular programming language, one that 109 | is widely used among developers working in that language. 110 | 111 | The "System Libraries" of an executable work include anything, other 112 | than the work as a whole, that (a) is included in the normal form of 113 | packaging a Major Component, but which is not part of that Major 114 | Component, and (b) serves only to enable use of the work with that 115 | Major Component, or to implement a Standard Interface for which an 116 | implementation is available to the public in source code form. A 117 | "Major Component", in this context, means a major essential component 118 | (kernel, window system, and so on) of the specific operating system 119 | (if any) on which the executable work runs, or a compiler used to 120 | produce the work, or an object code interpreter used to run it. 121 | 122 | The "Corresponding Source" for a work in object code form means all 123 | the source code needed to generate, install, and (for an executable 124 | work) run the object code and to modify the work, including scripts to 125 | control those activities. However, it does not include the work's 126 | System Libraries, or general-purpose tools or generally available free 127 | programs which are used unmodified in performing those activities but 128 | which are not part of the work. For example, Corresponding Source 129 | includes interface definition files associated with source files for 130 | the work, and the source code for shared libraries and dynamically 131 | linked subprograms that the work is specifically designed to require, 132 | such as by intimate data communication or control flow between those 133 | subprograms and other parts of the work. 134 | 135 | The Corresponding Source need not include anything that users 136 | can regenerate automatically from other parts of the Corresponding 137 | Source. 138 | 139 | The Corresponding Source for a work in source code form is that 140 | same work. 141 | 142 | 2. Basic Permissions. 143 | 144 | All rights granted under this License are granted for the term of 145 | copyright on the Program, and are irrevocable provided the stated 146 | conditions are met. This License explicitly affirms your unlimited 147 | permission to run the unmodified Program. The output from running a 148 | covered work is covered by this License only if the output, given its 149 | content, constitutes a covered work. This License acknowledges your 150 | rights of fair use or other equivalent, as provided by copyright law. 151 | 152 | You may make, run and propagate covered works that you do not 153 | convey, without conditions so long as your license otherwise remains 154 | in force. You may convey covered works to others for the sole purpose 155 | of having them make modifications exclusively for you, or provide you 156 | with facilities for running those works, provided that you comply with 157 | the terms of this License in conveying all material for which you do 158 | not control copyright. Those thus making or running the covered works 159 | for you must do so exclusively on your behalf, under your direction 160 | and control, on terms that prohibit them from making any copies of 161 | your copyrighted material outside their relationship with you. 162 | 163 | Conveying under any other circumstances is permitted solely under 164 | the conditions stated below. Sublicensing is not allowed; section 10 165 | makes it unnecessary. 166 | 167 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 168 | 169 | No covered work shall be deemed part of an effective technological 170 | measure under any applicable law fulfilling obligations under article 171 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 172 | similar laws prohibiting or restricting circumvention of such 173 | measures. 174 | 175 | When you convey a covered work, you waive any legal power to forbid 176 | circumvention of technological measures to the extent such circumvention 177 | is effected by exercising rights under this License with respect to 178 | the covered work, and you disclaim any intention to limit operation or 179 | modification of the work as a means of enforcing, against the work's 180 | users, your or third parties' legal rights to forbid circumvention of 181 | technological measures. 182 | 183 | 4. Conveying Verbatim Copies. 184 | 185 | You may convey verbatim copies of the Program's source code as you 186 | receive it, in any medium, provided that you conspicuously and 187 | appropriately publish on each copy an appropriate copyright notice; 188 | keep intact all notices stating that this License and any 189 | non-permissive terms added in accord with section 7 apply to the code; 190 | keep intact all notices of the absence of any warranty; and give all 191 | recipients a copy of this License along with the Program. 192 | 193 | You may charge any price or no price for each copy that you convey, 194 | and you may offer support or warranty protection for a fee. 195 | 196 | 5. Conveying Modified Source Versions. 197 | 198 | You may convey a work based on the Program, or the modifications to 199 | produce it from the Program, in the form of source code under the 200 | terms of section 4, provided that you also meet all of these conditions: 201 | 202 | a) The work must carry prominent notices stating that you modified 203 | it, and giving a relevant date. 204 | 205 | b) The work must carry prominent notices stating that it is 206 | released under this License and any conditions added under section 207 | 7. This requirement modifies the requirement in section 4 to 208 | "keep intact all notices". 209 | 210 | c) You must license the entire work, as a whole, under this 211 | License to anyone who comes into possession of a copy. This 212 | License will therefore apply, along with any applicable section 7 213 | additional terms, to the whole of the work, and all its parts, 214 | regardless of how they are packaged. This License gives no 215 | permission to license the work in any other way, but it does not 216 | invalidate such permission if you have separately received it. 217 | 218 | d) If the work has interactive user interfaces, each must display 219 | Appropriate Legal Notices; however, if the Program has interactive 220 | interfaces that do not display Appropriate Legal Notices, your 221 | work need not make them do so. 222 | 223 | A compilation of a covered work with other separate and independent 224 | works, which are not by their nature extensions of the covered work, 225 | and which are not combined with it such as to form a larger program, 226 | in or on a volume of a storage or distribution medium, is called an 227 | "aggregate" if the compilation and its resulting copyright are not 228 | used to limit the access or legal rights of the compilation's users 229 | beyond what the individual works permit. Inclusion of a covered work 230 | in an aggregate does not cause this License to apply to the other 231 | parts of the aggregate. 232 | 233 | 6. Conveying Non-Source Forms. 234 | 235 | You may convey a covered work in object code form under the terms 236 | of sections 4 and 5, provided that you also convey the 237 | machine-readable Corresponding Source under the terms of this License, 238 | in one of these ways: 239 | 240 | a) Convey the object code in, or embodied in, a physical product 241 | (including a physical distribution medium), accompanied by the 242 | Corresponding Source fixed on a durable physical medium 243 | customarily used for software interchange. 244 | 245 | b) Convey the object code in, or embodied in, a physical product 246 | (including a physical distribution medium), accompanied by a 247 | written offer, valid for at least three years and valid for as 248 | long as you offer spare parts or customer support for that product 249 | model, to give anyone who possesses the object code either (1) a 250 | copy of the Corresponding Source for all the software in the 251 | product that is covered by this License, on a durable physical 252 | medium customarily used for software interchange, for a price no 253 | more than your reasonable cost of physically performing this 254 | conveying of source, or (2) access to copy the 255 | Corresponding Source from a network server at no charge. 256 | 257 | c) Convey individual copies of the object code with a copy of the 258 | written offer to provide the Corresponding Source. This 259 | alternative is allowed only occasionally and noncommercially, and 260 | only if you received the object code with such an offer, in accord 261 | with subsection 6b. 262 | 263 | d) Convey the object code by offering access from a designated 264 | place (gratis or for a charge), and offer equivalent access to the 265 | Corresponding Source in the same way through the same place at no 266 | further charge. You need not require recipients to copy the 267 | Corresponding Source along with the object code. If the place to 268 | copy the object code is a network server, the Corresponding Source 269 | may be on a different server (operated by you or a third party) 270 | that supports equivalent copying facilities, provided you maintain 271 | clear directions next to the object code saying where to find the 272 | Corresponding Source. Regardless of what server hosts the 273 | Corresponding Source, you remain obligated to ensure that it is 274 | available for as long as needed to satisfy these requirements. 275 | 276 | e) Convey the object code using peer-to-peer transmission, provided 277 | you inform other peers where the object code and Corresponding 278 | Source of the work are being offered to the general public at no 279 | charge under subsection 6d. 280 | 281 | A separable portion of the object code, whose source code is excluded 282 | from the Corresponding Source as a System Library, need not be 283 | included in conveying the object code work. 284 | 285 | A "User Product" is either (1) a "consumer product", which means any 286 | tangible personal property which is normally used for personal, family, 287 | or household purposes, or (2) anything designed or sold for incorporation 288 | into a dwelling. In determining whether a product is a consumer product, 289 | doubtful cases shall be resolved in favor of coverage. For a particular 290 | product received by a particular user, "normally used" refers to a 291 | typical or common use of that class of product, regardless of the status 292 | of the particular user or of the way in which the particular user 293 | actually uses, or expects or is expected to use, the product. A product 294 | is a consumer product regardless of whether the product has substantial 295 | commercial, industrial or non-consumer uses, unless such uses represent 296 | the only significant mode of use of the product. 297 | 298 | "Installation Information" for a User Product means any methods, 299 | procedures, authorization keys, or other information required to install 300 | and execute modified versions of a covered work in that User Product from 301 | a modified version of its Corresponding Source. The information must 302 | suffice to ensure that the continued functioning of the modified object 303 | code is in no case prevented or interfered with solely because 304 | modification has been made. 305 | 306 | If you convey an object code work under this section in, or with, or 307 | specifically for use in, a User Product, and the conveying occurs as 308 | part of a transaction in which the right of possession and use of the 309 | User Product is transferred to the recipient in perpetuity or for a 310 | fixed term (regardless of how the transaction is characterized), the 311 | Corresponding Source conveyed under this section must be accompanied 312 | by the Installation Information. But this requirement does not apply 313 | if neither you nor any third party retains the ability to install 314 | modified object code on the User Product (for example, the work has 315 | been installed in ROM). 316 | 317 | The requirement to provide Installation Information does not include a 318 | requirement to continue to provide support service, warranty, or updates 319 | for a work that has been modified or installed by the recipient, or for 320 | the User Product in which it has been modified or installed. Access to a 321 | network may be denied when the modification itself materially and 322 | adversely affects the operation of the network or violates the rules and 323 | protocols for communication across the network. 324 | 325 | Corresponding Source conveyed, and Installation Information provided, 326 | in accord with this section must be in a format that is publicly 327 | documented (and with an implementation available to the public in 328 | source code form), and must require no special password or key for 329 | unpacking, reading or copying. 330 | 331 | 7. Additional Terms. 332 | 333 | "Additional permissions" are terms that supplement the terms of this 334 | License by making exceptions from one or more of its conditions. 335 | Additional permissions that are applicable to the entire Program shall 336 | be treated as though they were included in this License, to the extent 337 | that they are valid under applicable law. If additional permissions 338 | apply only to part of the Program, that part may be used separately 339 | under those permissions, but the entire Program remains governed by 340 | this License without regard to the additional permissions. 341 | 342 | When you convey a copy of a covered work, you may at your option 343 | remove any additional permissions from that copy, or from any part of 344 | it. (Additional permissions may be written to require their own 345 | removal in certain cases when you modify the work.) You may place 346 | additional permissions on material, added by you to a covered work, 347 | for which you have or can give appropriate copyright permission. 348 | 349 | Notwithstanding any other provision of this License, for material you 350 | add to a covered work, you may (if authorized by the copyright holders of 351 | that material) supplement the terms of this License with terms: 352 | 353 | a) Disclaiming warranty or limiting liability differently from the 354 | terms of sections 15 and 16 of this License; or 355 | 356 | b) Requiring preservation of specified reasonable legal notices or 357 | author attributions in that material or in the Appropriate Legal 358 | Notices displayed by works containing it; or 359 | 360 | c) Prohibiting misrepresentation of the origin of that material, or 361 | requiring that modified versions of such material be marked in 362 | reasonable ways as different from the original version; or 363 | 364 | d) Limiting the use for publicity purposes of names of licensors or 365 | authors of the material; or 366 | 367 | e) Declining to grant rights under trademark law for use of some 368 | trade names, trademarks, or service marks; or 369 | 370 | f) Requiring indemnification of licensors and authors of that 371 | material by anyone who conveys the material (or modified versions of 372 | it) with contractual assumptions of liability to the recipient, for 373 | any liability that these contractual assumptions directly impose on 374 | those licensors and authors. 375 | 376 | All other non-permissive additional terms are considered "further 377 | restrictions" within the meaning of section 10. If the Program as you 378 | received it, or any part of it, contains a notice stating that it is 379 | governed by this License along with a term that is a further 380 | restriction, you may remove that term. If a license document contains 381 | a further restriction but permits relicensing or conveying under this 382 | License, you may add to a covered work material governed by the terms 383 | of that license document, provided that the further restriction does 384 | not survive such relicensing or conveying. 385 | 386 | If you add terms to a covered work in accord with this section, you 387 | must place, in the relevant source files, a statement of the 388 | additional terms that apply to those files, or a notice indicating 389 | where to find the applicable terms. 390 | 391 | Additional terms, permissive or non-permissive, may be stated in the 392 | form of a separately written license, or stated as exceptions; 393 | the above requirements apply either way. 394 | 395 | 8. Termination. 396 | 397 | You may not propagate or modify a covered work except as expressly 398 | provided under this License. Any attempt otherwise to propagate or 399 | modify it is void, and will automatically terminate your rights under 400 | this License (including any patent licenses granted under the third 401 | paragraph of section 11). 402 | 403 | However, if you cease all violation of this License, then your 404 | license from a particular copyright holder is reinstated (a) 405 | provisionally, unless and until the copyright holder explicitly and 406 | finally terminates your license, and (b) permanently, if the copyright 407 | holder fails to notify you of the violation by some reasonable means 408 | prior to 60 days after the cessation. 409 | 410 | Moreover, your license from a particular copyright holder is 411 | reinstated permanently if the copyright holder notifies you of the 412 | violation by some reasonable means, this is the first time you have 413 | received notice of violation of this License (for any work) from that 414 | copyright holder, and you cure the violation prior to 30 days after 415 | your receipt of the notice. 416 | 417 | Termination of your rights under this section does not terminate the 418 | licenses of parties who have received copies or rights from you under 419 | this License. If your rights have been terminated and not permanently 420 | reinstated, you do not qualify to receive new licenses for the same 421 | material under section 10. 422 | 423 | 9. Acceptance Not Required for Having Copies. 424 | 425 | You are not required to accept this License in order to receive or 426 | run a copy of the Program. Ancillary propagation of a covered work 427 | occurring solely as a consequence of using peer-to-peer transmission 428 | to receive a copy likewise does not require acceptance. However, 429 | nothing other than this License grants you permission to propagate or 430 | modify any covered work. These actions infringe copyright if you do 431 | not accept this License. Therefore, by modifying or propagating a 432 | covered work, you indicate your acceptance of this License to do so. 433 | 434 | 10. Automatic Licensing of Downstream Recipients. 435 | 436 | Each time you convey a covered work, the recipient automatically 437 | receives a license from the original licensors, to run, modify and 438 | propagate that work, subject to this License. You are not responsible 439 | for enforcing compliance by third parties with this License. 440 | 441 | An "entity transaction" is a transaction transferring control of an 442 | organization, or substantially all assets of one, or subdividing an 443 | organization, or merging organizations. If propagation of a covered 444 | work results from an entity transaction, each party to that 445 | transaction who receives a copy of the work also receives whatever 446 | licenses to the work the party's predecessor in interest had or could 447 | give under the previous paragraph, plus a right to possession of the 448 | Corresponding Source of the work from the predecessor in interest, if 449 | the predecessor has it or can get it with reasonable efforts. 450 | 451 | You may not impose any further restrictions on the exercise of the 452 | rights granted or affirmed under this License. For example, you may 453 | not impose a license fee, royalty, or other charge for exercise of 454 | rights granted under this License, and you may not initiate litigation 455 | (including a cross-claim or counterclaim in a lawsuit) alleging that 456 | any patent claim is infringed by making, using, selling, offering for 457 | sale, or importing the Program or any portion of it. 458 | 459 | 11. Patents. 460 | 461 | A "contributor" is a copyright holder who authorizes use under this 462 | License of the Program or a work on which the Program is based. The 463 | work thus licensed is called the contributor's "contributor version". 464 | 465 | A contributor's "essential patent claims" are all patent claims 466 | owned or controlled by the contributor, whether already acquired or 467 | hereafter acquired, that would be infringed by some manner, permitted 468 | by this License, of making, using, or selling its contributor version, 469 | but do not include claims that would be infringed only as a 470 | consequence of further modification of the contributor version. For 471 | purposes of this definition, "control" includes the right to grant 472 | patent sublicenses in a manner consistent with the requirements of 473 | this License. 474 | 475 | Each contributor grants you a non-exclusive, worldwide, royalty-free 476 | patent license under the contributor's essential patent claims, to 477 | make, use, sell, offer for sale, import and otherwise run, modify and 478 | propagate the contents of its contributor version. 479 | 480 | In the following three paragraphs, a "patent license" is any express 481 | agreement or commitment, however denominated, not to enforce a patent 482 | (such as an express permission to practice a patent or covenant not to 483 | sue for patent infringement). To "grant" such a patent license to a 484 | party means to make such an agreement or commitment not to enforce a 485 | patent against the party. 486 | 487 | If you convey a covered work, knowingly relying on a patent license, 488 | and the Corresponding Source of the work is not available for anyone 489 | to copy, free of charge and under the terms of this License, through a 490 | publicly available network server or other readily accessible means, 491 | then you must either (1) cause the Corresponding Source to be so 492 | available, or (2) arrange to deprive yourself of the benefit of the 493 | patent license for this particular work, or (3) arrange, in a manner 494 | consistent with the requirements of this License, to extend the patent 495 | license to downstream recipients. "Knowingly relying" means you have 496 | actual knowledge that, but for the patent license, your conveying the 497 | covered work in a country, or your recipient's use of the covered work 498 | in a country, would infringe one or more identifiable patents in that 499 | country that you have reason to believe are valid. 500 | 501 | If, pursuant to or in connection with a single transaction or 502 | arrangement, you convey, or propagate by procuring conveyance of, a 503 | covered work, and grant a patent license to some of the parties 504 | receiving the covered work authorizing them to use, propagate, modify 505 | or convey a specific copy of the covered work, then the patent license 506 | you grant is automatically extended to all recipients of the covered 507 | work and works based on it. 508 | 509 | A patent license is "discriminatory" if it does not include within 510 | the scope of its coverage, prohibits the exercise of, or is 511 | conditioned on the non-exercise of one or more of the rights that are 512 | specifically granted under this License. You may not convey a covered 513 | work if you are a party to an arrangement with a third party that is 514 | in the business of distributing software, under which you make payment 515 | to the third party based on the extent of your activity of conveying 516 | the work, and under which the third party grants, to any of the 517 | parties who would receive the covered work from you, a discriminatory 518 | patent license (a) in connection with copies of the covered work 519 | conveyed by you (or copies made from those copies), or (b) primarily 520 | for and in connection with specific products or compilations that 521 | contain the covered work, unless you entered into that arrangement, 522 | or that patent license was granted, prior to 28 March 2007. 523 | 524 | Nothing in this License shall be construed as excluding or limiting 525 | any implied license or other defenses to infringement that may 526 | otherwise be available to you under applicable patent law. 527 | 528 | 12. No Surrender of Others' Freedom. 529 | 530 | If conditions are imposed on you (whether by court order, agreement or 531 | otherwise) that contradict the conditions of this License, they do not 532 | excuse you from the conditions of this License. If you cannot convey a 533 | covered work so as to satisfy simultaneously your obligations under this 534 | License and any other pertinent obligations, then as a consequence you may 535 | not convey it at all. For example, if you agree to terms that obligate you 536 | to collect a royalty for further conveying from those to whom you convey 537 | the Program, the only way you could satisfy both those terms and this 538 | License would be to refrain entirely from conveying the Program. 539 | 540 | 13. Remote Network Interaction; Use with the GNU General Public License. 541 | 542 | Notwithstanding any other provision of this License, if you modify the 543 | Program, your modified version must prominently offer all users 544 | interacting with it remotely through a computer network (if your version 545 | supports such interaction) an opportunity to receive the Corresponding 546 | Source of your version by providing access to the Corresponding Source 547 | from a network server at no charge, through some standard or customary 548 | means of facilitating copying of software. This Corresponding Source 549 | shall include the Corresponding Source for any work covered by version 3 550 | of the GNU General Public License that is incorporated pursuant to the 551 | following paragraph. 552 | 553 | Notwithstanding any other provision of this License, you have 554 | permission to link or combine any covered work with a work licensed 555 | under version 3 of the GNU General Public License into a single 556 | combined work, and to convey the resulting work. The terms of this 557 | License will continue to apply to the part which is the covered work, 558 | but the work with which it is combined will remain governed by version 559 | 3 of the GNU General Public License. 560 | 561 | 14. Revised Versions of this License. 562 | 563 | The Free Software Foundation may publish revised and/or new versions of 564 | the GNU Affero General Public License from time to time. Such new versions 565 | will be similar in spirit to the present version, but may differ in detail to 566 | address new problems or concerns. 567 | 568 | Each version is given a distinguishing version number. If the 569 | Program specifies that a certain numbered version of the GNU Affero General 570 | Public License "or any later version" applies to it, you have the 571 | option of following the terms and conditions either of that numbered 572 | version or of any later version published by the Free Software 573 | Foundation. If the Program does not specify a version number of the 574 | GNU Affero General Public License, you may choose any version ever published 575 | by the Free Software Foundation. 576 | 577 | If the Program specifies that a proxy can decide which future 578 | versions of the GNU Affero General Public License can be used, that proxy's 579 | public statement of acceptance of a version permanently authorizes you 580 | to choose that version for the Program. 581 | 582 | Later license versions may give you additional or different 583 | permissions. However, no additional obligations are imposed on any 584 | author or copyright holder as a result of your choosing to follow a 585 | later version. 586 | 587 | 15. Disclaimer of Warranty. 588 | 589 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 590 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 591 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 592 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 593 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 594 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 595 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 596 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 597 | 598 | 16. Limitation of Liability. 599 | 600 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 601 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 602 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 603 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 604 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 605 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 606 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 607 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 608 | SUCH DAMAGES. 609 | 610 | 17. Interpretation of Sections 15 and 16. 611 | 612 | If the disclaimer of warranty and limitation of liability provided 613 | above cannot be given local legal effect according to their terms, 614 | reviewing courts shall apply local law that most closely approximates 615 | an absolute waiver of all civil liability in connection with the 616 | Program, unless a warranty or assumption of liability accompanies a 617 | copy of the Program in return for a fee. 618 | 619 | END OF TERMS AND CONDITIONS 620 | 621 | How to Apply These Terms to Your New Programs 622 | 623 | If you develop a new program, and you want it to be of the greatest 624 | possible use to the public, the best way to achieve this is to make it 625 | free software which everyone can redistribute and change under these terms. 626 | 627 | To do so, attach the following notices to the program. It is safest 628 | to attach them to the start of each source file to most effectively 629 | state the exclusion of warranty; and each file should have at least 630 | the "copyright" line and a pointer to where the full notice is found. 631 | 632 | 633 | Copyright (C) 634 | 635 | This program is free software: you can redistribute it and/or modify 636 | it under the terms of the GNU Affero General Public License as published by 637 | the Free Software Foundation, either version 3 of the License, or 638 | (at your option) any later version. 639 | 640 | This program is distributed in the hope that it will be useful, 641 | but WITHOUT ANY WARRANTY; without even the implied warranty of 642 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 643 | GNU Affero General Public License for more details. 644 | 645 | You should have received a copy of the GNU Affero General Public License 646 | along with this program. If not, see . 647 | 648 | Also add information on how to contact you by electronic and paper mail. 649 | 650 | If your software can interact with users remotely through a computer 651 | network, you should also make sure that it provides a way for users to 652 | get its source. For example, if your program is a web application, its 653 | interface could display a "Source" link that leads users to an archive 654 | of the code. There are many ways you could offer source, and different 655 | solutions will be better for different programs; see section 13 for the 656 | specific requirements. 657 | 658 | You should also get your employer (if you work as a programmer) or school, 659 | if any, to sign a "copyright disclaimer" for the program, if necessary. 660 | For more information on this, and how to apply and follow the GNU AGPL, see 661 | . 662 | -------------------------------------------------------------------------------- /motivation-bot/README.md: -------------------------------------------------------------------------------- 1 | # Tutorial 2 | 3 | This tutorial will show you how easy it is to build a motivation bot using the RiveScript and Messenger modules. For this purpose, we will build a little motivation bot from scratch in about 30 minutes. If you have any problems, do not hesitate to talk to us on our [Slack Community](https://slack.botpress.io). It will be a pleasure for us to answer your requests. 4 | 5 | If you don't want to follow our step-by-step guide below, you can clone this repository and just try it by linking it to a Facebook page [step #6](#messenger). If you clone the repository, don't forget to run `npm install` in the repository. 6 | 7 | ## Table of contents 8 | * [Requirements](#requirements) 9 | * [Step-by-step](#step-by-step) 10 | * [Install Botpress](#install-botpress) 11 | * [Create a new repository](#create-new-repo) 12 | * [Initialize Botpress](#initialize-botpress) 13 | * [Install Botpress modules](#install-botpress-modules) 14 | * [Start Botpress](#start-botpress) 15 | * [Configure Messenger connection settings](#configure-messenger) 16 | * [Verifying your configuration](#verifying-connection) 17 | * [Open your repo in an editor](#open-your-repo) 18 | * [Start coding](#start-coding) 19 | * [Create a basic welcome message in the terminal](#basic-welcome-message) 20 | * [Import npm packages](#import-npm-packages) 21 | * [Choose between three work-life categories](#choose-between-categories) 22 | * [Listen for a particular user message and react](#listen-user-message) 23 | * [Prepare to send the user a video](#prepare-send-video) 24 | * [Listen for chosen work-life category](#listen-categories) 25 | * [Add a default response to user messages](#add-response) 26 | * [Put all the code together](#put-code-together) 27 | * [Set up RiveScript](#set-up-rivescript) 28 | * [RiveScript reference](#rivescript-reference) 29 | * [Have fun](#have-fun) 30 | * [Community](#community) 31 | * [License](#license) 32 | 33 | ## Requirements 34 | 35 | Botpress requires [node](https://nodejs.org) (version >= 4.2) and uses [npm](https://www.npmjs.com) as package manager. 36 | 37 | ## Step-by-step 38 | 39 | ### 1. Install Botpress 40 | 41 | You first need to have `botpress` installed as a general dependency using `npm`. If `npm` is already installed, you can install Botpress with the following command (make sure to install it globally): 42 | 43 | ``` 44 | npm install -g botpress 45 | ``` 46 | 47 | ### 2. Create a new repository 48 | 49 | Once `botpress` has been installed, you create a new repository and cd into it. 50 | 51 | ```js 52 | mkdir motivation-bot && cd motivation-bot // Mac and Linux users 53 | 54 | md motivation-bot && cd motivation-bot // Windows users 55 | ``` 56 | 57 | ### 3. Initialize Botpress 58 | 59 | Now, let's use the command line interface of `botpress` to initialize your bot: 60 | 61 | ``` 62 | botpress init 63 | ``` 64 | 65 | ### 4. Install Botpress modules 66 | 67 | In your command line again, you need to install the [botpress-messenger](https://github.com/botpress/botpress-messenger) module to be able to connect your bot to your Facebook page. Also, you will install the [botpress-rivescript](https://github.com/botpress/botpress-rivescript) module to add some basic interaction. 68 | 69 | ``` 70 | botpress install messenger rivescript 71 | ``` 72 | 73 | ### 5. Start Botpress 74 | 75 | Once everything is installed, you can start your bot and see what it includes. 76 | 77 | ``` 78 | botpress start 79 | ``` 80 | 81 | A local instance of your bot should be running at [http://localhost:3000](http://localhost:3000). From there you can install other modules as desired, but for this tutorial we only need the Messenger and RiveScript modules, which we have just installed. 82 | 83 | ### 6. Configure Messenger connection settings 84 | 85 | Before getting started with coding, you will need to configure Messenger so it's connected directly to your Facebook page. If this is your first time to configure Messenger, we recommend following our [getting started](https://docs.botpress.io/getting-started.html) guide in the official Botpress documentation. 86 | 87 | 88 | 89 | Briefly, you need to create a [Facebook page](https://www.facebook.com/pages/create) if you don't already have one. You also need to create a new [Messenger app](https://developers.facebook.com/) on Facebook. After that, you can find your **App ID**, **App Secret**, and **Token Access**, and paste them directly into the `botpress-messenger` module settings of the [Botpress user interface](http://localhost:3000/modules/botpress-messenger) running locally. Finally, you only need to activate [ngrok](https://ngrok.com/), and then validate and connect your bot. 90 | 91 | For further information on configuring `botpress-messenger` see the [Getting Started documentation](https://docs.botpress.io/getting-started.html). 92 | 93 | #### Verifying your configuration 94 | 95 | After connecting the Botpress Messenger module with your Facebook Messenger app in the step above, you can verify that everything's working by opening a chat tab on your Facebook page and typing `BOT_LICENSE`. 96 | 97 | The bot should answer your user message, for example with: 98 | 99 | ``` 100 | Bot: motivation-bot 101 | Created by: GB 102 | License: AGPL-3.0 103 | Botpress: 0.0.50 104 | ``` 105 | 106 | **Note**: `BOT_LICENSE` is a Botpress command to display basic information about your bot (name, version, licenses). 107 | 108 | ### 7. Open your repo in an editor 109 | 110 | Once all the setup is done, you are ready to code your bot. You open your repository in your favorite editor (Sublime, Atom, WebStorm, Netbeans, ...). As you can see, some files and directories have already been created when you had previously initialized your repo with `botpress-init`. 111 | 112 | ```js 113 | - botfile.js // your bot's configuration. Botpress uses this 114 | - index.js // your bot's entry point. bot logic goes here 115 | - package.json // regular node package.json file 116 | - LICENSE // your bot license, either AGPLv3 or Botpress License 117 | - .gitignore // ignoring some botpress-created files by default 118 | ``` 119 | 120 | ### 8. Start coding 121 | 122 | Now, open the `index.js` file and write (or paste) these lines of code. This is a simple to do list. 123 | 124 | ```js 125 | module.exports = function(bp) { 126 | bp.middlewares.load() 127 | 128 | /* Things to do: 129 | [ ] Basic welcome message 130 | [ ] Choose among 3 categories: WORK, PERSONAL DEVELOPMENT, GYM 131 | [ ] Choose a random video in selected category 132 | [ ] Send video as a card (image, thumbnail, share button) 133 | [ ] Add small talk capabilities 134 | [ ] Catch-all sentences with quick_replies 135 | */ 136 | } 137 | ``` 138 | 139 | **Tip:** When you are coding, using a to do list is good practice because it helps you to stay focused and to know exactly what needs to be done. 140 | 141 | ### 9. Create a basic welcome message in the terminal 142 | 143 | First, we will setup a basic answer to `GET_STARTED` button on Messenger. You simply need to add those lines in `index.js`. 144 | 145 | ```js 146 | bp.hear({ 147 | type: 'postback', 148 | text: 'GET_STARTED' 149 | }, (event, next) => { 150 | const { first_name, last_name } = event.user 151 | bp.logger.info('New user:', first_name, last_name) 152 | }) 153 | ``` 154 | Your first and last name should be displayed in the terminal where you're running Botpress. 155 | 156 | To display the **Get Started** button on Messenger, make sure to delete any existing conversation with your bot in Facebook Messenger. 157 | 158 | **Note**: When you click on **Get Started** button on Messenger it emits a `postback` event and that's what we're listening on here. 159 | 160 | ### 10. Import npm packages 161 | 162 | Now we'll install some useful `npm` packages. In your terminal, you add these wtih the `npm install ` command. 163 | 164 | ```js 165 | npm install bluebird // https://bluebirdjs.com 166 | npm install lodash // https://lodash.com 167 | npm install axios // https://www.npmjs.com/package/axios 168 | ``` 169 | 170 | After installation, import them at the beginning of your `index.js` file. 171 | 172 | ```js 173 | const Promise = require('bluebird') 174 | const _ = require('lodash') 175 | ``` 176 | 177 | ### 11. Choose between three work-life categories 178 | 179 | As you probably noticed, our first welcome message was a bit boring. Let's customize it and add some humor. 180 | 181 | ```js 182 | // ... (imports) 183 | 184 | const pickCategory = { 185 | quick_replies: [ 186 | { 187 | content_type: 'text', 188 | title: '🔥 Work 🔥', 189 | payload: 'GET_VIDEO_WORK' 190 | }, 191 | { 192 | content_type: 'text', 193 | title: '😌 Life Goals 🔥', 194 | payload: 'GET_VIDEO_LIFE' 195 | }, 196 | { 197 | content_type: 'text', 198 | title: '💪 Gym 🔥', 199 | payload: 'GET_VIDEO_GYM' 200 | } 201 | ], 202 | typing: true 203 | } 204 | 205 | module.exports = function(bp) { 206 | 207 | bp.middlewares.load() 208 | 209 | bp.hear({ 210 | type: 'postback', 211 | text: 'GET_STARTED' 212 | }, (event, next) => { 213 | const { first_name, last_name } = event.user 214 | bp.logger.info('New user:', first_name, last_name) 215 | 216 | const WELCOME_SENTENCES = [ 217 | "Hey there buddy pal, so I've heard that you need a little kick in the butt from time to time?", 218 | "Don't worry mate, that's my job and I'll do that for you.", 219 | "But man, I don't talk much.", 220 | "I'm a bit dumb, to be honest. Let's just stick to using buttons, that's going to be easier for the both of us." 221 | ] 222 | 223 | const WELCOME_TEXT_QUICK_REPLY = "THAT BEING SAID, choose a category below and I'll make sure you get pumped up!" 224 | 225 | Promise.mapSeries(WELCOME_SENTENCES, txt => { 226 | bp.messenger.sendText(event.user.id, txt, { typing: true }) 227 | return Promise.delay(4000) 228 | }) 229 | .then(() => { 230 | bp.messenger.sendText(event.user.id, WELCOME_TEXT_QUICK_REPLY, pickCategory) 231 | }) 232 | }) 233 | } 234 | ``` 235 | 236 | In this code, we use `Promise.mapSeries` to send a sequence of text messages with some delay between each. We then send a final message along with some `quick_replies` to ask users to choose which type of video they want to watch (i.e., **Work**, **Life Goals**, or **Gym**). 237 | 238 | After typing or pasting in the code above, make sure to save your changes and restart Botpress (`bp start`) in your terminal. 239 | 240 | ### 12. Listen for a particular user message and react 241 | 242 | Now we'll listen on `quick_reply` to discern which kind of video a user wants. Here is some sample code for listening for one type of video that a user may choose from the `pickCategory` array defined above. 243 | 244 | ```js 245 | bp.hear({ 246 | type: 'quick_reply', 247 | text: 'GET_VIDEO_WORK' 248 | }, (event, next) => { 249 | const PICK_TEXT = "Oh, yeah, work isn't always easy man. Let's fix that right away." 250 | bp.messenger.sendText(event.user.id, PICK_TEXT, { typing: true }) 251 | Promise.delay(3000) 252 | .then(() => { 253 | bp.messenger.sendText(event.user.id, '') 254 | }) 255 | }) 256 | ``` 257 | 258 | Here, we only provide a text answer when the user chooses **Work**. Below, we complete this exercise by providing a random video in place of text. 259 | 260 | ### 13. Prepare to send the user a video 261 | 262 | To access videos from YouTube, you need to create a new file `videos.js` and type (or paste) the code below. 263 | 264 | You also need to import the `axios` and `lodash` packages and create your own `videos` object. The object is a simple map containing multiple links for different categories and implementing the `getYoutubeVideoMetadata` function for grabbing metadata from the YouTube API. 265 | 266 | **Important**: You need to obtain your own `` if you want to grab videos from YouTube (don't forget to enclose your API key in quotes). To do this, you can follow this detailed [guide](https://developers.google.com/youtube/v3/getting-started). 267 | 268 | ```js 269 | const axios = require('axios') 270 | const _ = require('lodash') 271 | 272 | const videos = { 273 | WORK: [ 274 | "DNFtCIzJQ7A", 275 | "g-fGYtagSDY", 276 | "00rPgc0tISM", 277 | "qa9G5EdKiRw", 278 | "3AyH1fBN7ac", 279 | "HQtZ4kud2qA", 280 | "puDQoBPpWyQ", 281 | "A0Scr2TW2ZA", 282 | "oonaeUiKV8Y", 283 | "2zzj4CO9xSw", 284 | "twZgNP8iZBQ", 285 | "8QlvQC4MXxs" 286 | ], 287 | LIFE: [ 288 | "jE-Ajfd51aM", 289 | "6vuetQSwFW8", 290 | "7_R4AsV2fPI", 291 | "njQcOKOpFwk", 292 | "5g0QHTcwP8k", 293 | "t-H7_aAuiC8", 294 | "5e338_RFOr8", 295 | "U3V701IUZ2E", 296 | "ZkabeHig_r4", 297 | "FK16iXPRAjI", 298 | "4pxiU89O1wE", 299 | "2otRxX6y7mQ" 300 | ], 301 | GYM: [ 302 | "Fh-rCrREEgA", 303 | "xoXYe9e01_Y", 304 | "hV63DbQ_qSc", 305 | "YxzQ6umhH4Q", 306 | "lsSC2vx7zFQ", 307 | "63Cv6Jiiink", 308 | "aMGoxlXmA0o", 309 | "at7QvbFy9fM", 310 | "qapsrR8zIJM", 311 | "vnMtpNhcDOE", 312 | "OV6-n5wtCWA", 313 | "lpVRxa9jsrE", 314 | "WDJaJbc9O-4" 315 | ] 316 | } 317 | 318 | const getYoutubeVideoMetadata = (videoId) => { 319 | const YOUTUBE_API_KEY = 320 | const apiUrl = `https://content.googleapis.com/youtube/v3/videos?id=${videoId}&part=snippet&key=${YOUTUBE_API_KEY}` 321 | 322 | return axios.get(apiUrl) 323 | .then(res => { 324 | const video = res.data.items[0].snippet 325 | return { 326 | description: video.description, 327 | thumbnail: (video.thumbnails.high || video.thumbnails.standard).url, 328 | title: video.title, 329 | url: 'https://www.youtube.com/watch?v=' + videoId 330 | } 331 | }) 332 | } 333 | 334 | module.exports = { 335 | getRandomVideo: (category) => { 336 | const videoId = _.sample(videos[category]) 337 | return getYoutubeVideoMetadata(videoId) 338 | } 339 | } 340 | 341 | ``` 342 | 343 | As you can see, `videos.js` only exports the function `getRandomVideo` which returns video metadata (description, thumbnail, title, URL) grabbed from YouTube. 344 | 345 | ### 14. Listen for chosen work-life category 346 | 347 | We now import our `videos.js` file into `index.js` and add possible responses from `TEXT_CATEGORIES` (placing this above our exports statement). We'll also add code for a video response inside the exports statement. 348 | 349 | ```js 350 | // ... (other imports) 351 | const videos = require('./videos') 352 | 353 | // ... (other variables) 354 | 355 | const TEXT_CATEGORIES = { 356 | WORK: [ 357 | "Oh, yeah, work isn't always easy man. Let's fix that right away.", 358 | "Listen to that, I bet you'll get a raise next week 💪" 359 | ], 360 | LIFE: [ 361 | "Take charge of your life NOW" 362 | ], 363 | GYM: [ 364 | "Want muscles?" 365 | ] 366 | } 367 | 368 | module.exports = function(bp) { 369 | 370 | // ... (other functions) 371 | 372 | const hearGetVideo = category => { 373 | bp.hear({ text: 'GET_VIDEO_' + category }, (event, next) => { 374 | console.log('!! I CAUGHT THAT') 375 | const text = _.sample(TEXT_CATEGORIES[category]) 376 | bp.messenger.sendText(event.user.id, text, { typing: true }) 377 | 378 | Promise.delay(1500) 379 | .then(() => videos.getRandomVideo(category)) 380 | .then(meta => { 381 | bp.messenger.sendTemplate(event.user.id, { 382 | template_type: 'generic', 383 | elements: [{ 384 | title: meta.title, 385 | item_url: meta.url, 386 | image_url: meta.thumbnail, 387 | subtitle: meta.description, 388 | buttons: [ 389 | { type: 'web_url', title: '🔥 Watch 🔥', url: meta.url }, 390 | { type: 'element_share' } 391 | ] 392 | }] 393 | }) 394 | }) 395 | }) 396 | } 397 | } 398 | 399 | // Create a listener for each category 400 | _.keys(TEXT_CATEGORIES).forEach(hearGetVideo) 401 | ``` 402 | 403 | ### 15. Add a default response to user messages 404 | 405 | To answer text messages from users, you need to grab them and in our case, we decide to temporarily always answer the same message. By adding these lines to the bottom of `index.js`, a `botDefaultResponse` is created that can be called from anywhere. 406 | 407 | ```js 408 | bp.botDefaultResponse = event => { 409 | const text = event.user.first_name + ", I told you, I'm a bit dumb. I assume you want motivation, cause that's all I'm able to do :)" 410 | bp.messenger.sendText(event.user.id, text, pickCategory) 411 | } 412 | ``` 413 | 414 | ### 16. Put all the code together 415 | 416 | Finally, let's sum up all the code snippets we recently added to `index.js`. After adding this code, restart your bot by running `botpress start`. 417 | 418 | ```js 419 | const Promise = require('bluebird') 420 | const _ = require('lodash') 421 | const videos = require('./videos') 422 | 423 | const TEXT_CATEGORIES = { 424 | WORK: [ 425 | "Oh, yeah, work isn't always easy man. Let's fix that right away.", 426 | "Listen to that, I bet you'll get a raise next week 💪" 427 | ], 428 | LIFE: [ 429 | "Take charge of your life NOW" 430 | ], 431 | GYM: [ 432 | "Want muscles?" 433 | ] 434 | } 435 | 436 | const pickCategory = { 437 | quick_replies: [ 438 | { 439 | content_type: 'text', 440 | title: '🔥 Work 🔥', 441 | payload: 'GET_VIDEO_WORK' 442 | }, 443 | { 444 | content_type: 'text', 445 | title: '😌 Life Goals 🔥', 446 | payload: 'GET_VIDEO_LIFE' 447 | }, 448 | { 449 | content_type: 'text', 450 | title: '💪 Gym 🔥', 451 | payload: 'GET_VIDEO_GYM' 452 | } 453 | ], 454 | typing: true 455 | } 456 | 457 | module.exports = function(bp) { 458 | 459 | bp.middlewares.load() 460 | 461 | bp.hear({ 462 | type: 'postback', 463 | text: 'GET_STARTED' 464 | }, (event, next) => { 465 | const { first_name, last_name } = event.user 466 | bp.logger.info('New user:', first_name, last_name) 467 | 468 | const WELCOME_SENTENCES = [ 469 | "Hey there buddy pal, so I've heard that you need a little kick in the butt from time to time?", 470 | "Don't worry mate, that's my job and I'll do that for you.", 471 | "But man, I don't talk much.", 472 | "I'm a bit dumb, to be honest. Let's just stick to using buttons, that's going to be easier for the both of us." 473 | ] 474 | 475 | const WELCOME_TEXT_QUICK_REPLY = "THAT BEING SAID, choose a category right away and I'll make sure you get pumped up!" 476 | 477 | Promise.mapSeries(WELCOME_SENTENCES, txt => { 478 | bp.messenger.sendText(event.user.id, txt, { typing: true }) 479 | return Promise.delay(4000) 480 | }) 481 | .then(() => { 482 | bp.messenger.sendText(event.user.id, WELCOME_TEXT_QUICK_REPLY, pickCategory) 483 | }) 484 | }) 485 | 486 | const hearGetVideo = category => { 487 | bp.hear({ text: 'GET_VIDEO_' + category }, (event, next) => { 488 | console.log('!! I CAUGHT THAT') 489 | const text = _.sample(TEXT_CATEGORIES[category]) 490 | bp.messenger.sendText(event.user.id, text, { typing: true }) 491 | 492 | Promise.delay(1500) 493 | .then(() => videos.getRandomVideo(category)) 494 | .then(meta => { 495 | bp.messenger.sendTemplate(event.user.id, { 496 | template_type: 'generic', 497 | elements: [{ 498 | title: meta.title, 499 | item_url: meta.url, 500 | image_url: meta.thumbnail, 501 | subtitle: meta.description, 502 | buttons: [ 503 | { type: 'web_url', title: '🔥 Watch 🔥', url: meta.url }, 504 | { type: 'element_share' } 505 | ] 506 | }] 507 | }) 508 | }) 509 | }) 510 | } 511 | 512 | _.keys(TEXT_CATEGORIES).forEach(hearGetVideo) 513 | 514 | bp.botDefaultResponse = event => { 515 | const text = event.user.first_name + ", I told you, I'm a bit dumb. I assume you want motivation, cause that's all I'm able to do :)" 516 | bp.messenger.sendText(event.user.id, text, pickCategory) 517 | } 518 | } 519 | ``` 520 | 521 | ### 16. Set up RiveScript 522 | 523 | In a previous step, we had installed the Botpress RiveScript module. When you open this [module](http://localhost:3000/modules/botpress-rivescript) in the Botpress instance running locally, you see the `begin` file prepopulated with sample RiveScript code. Feel free to modify this code to customize the interaction of your chatbot. 524 | 525 | ``` 526 | // begin 527 | ! version = 2.0 528 | 529 | ! sub i'm = i am 530 | ! sub i'd = i would 531 | ! sub i've = i have 532 | ! sub i'll = i will 533 | ! sub don't = do not 534 | ! sub isn't = is not 535 | ! sub you'd = you would 536 | ! sub you're = you are 537 | ! sub you've = you have 538 | ! sub you'll = you will 539 | ! sub what's = what is 540 | ! sub whats = what is 541 | ! sub what're = what are 542 | ! sub what've = what have 543 | ! sub what'll = what will 544 | ! sub who's = who is 545 | ``` 546 | When you click on the `star` file, you also find sample code. This file allows you to specify wildcard responses or open-ended triggers for user messages containing variable data. 547 | 548 | You can add the following code to `star` to link our `botDefaultResponse` to any unanswered message. The result will be that user messages sent to `botpress-messenger` will be swallowed while `botpress-rivescript` will process them according to its rules. 549 | 550 | ``` 551 | // star 552 | + * 553 | - JS: bp.botDefaultResponse(event) 554 | ``` 555 | 556 | #### RiveScript reference 557 | 558 | For more information you can refer to the official [RiveScript documentation](https://www.rivescript.com/). Botpress also has a [tutorial](https://github.com/botpress/botpress-examples/tree/master/hello-world-rivescript-bot) dedicated to using RiveScript. 559 | 560 | 561 | ## Have fun 562 | 563 | Building a bot with the RiveScript module is as simple as that! 564 | 565 | Feel free to fork our bot, send pull requests, clone it, send comments, ... 566 | 567 | ## Community 568 | 569 | Pull requests are welcome! We believe that it takes all of us to create something big and impactful. 570 | 571 | There's a [Slack community](https://slack.botpress.io) where you are welcome to join us, ask any question and even help others. 572 | 573 | Get an invite and join us now! 👉[https://slack.botpress.io](https://slack.botpress.io). 574 | 575 | ## License 576 | 577 | `motivation-bot` is licensed under [AGPL-3.0](/LICENSE). 578 | -------------------------------------------------------------------------------- /motivation-bot/assets/connexion-settings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/botpress/botpress-examples/73e37c01ec3f6342c827f713f7beb5b086e86f0f/motivation-bot/assets/connexion-settings.png -------------------------------------------------------------------------------- /motivation-bot/botfile.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | 3 | /** 4 | * where the content is stored 5 | * you can access this property from `bp.dataLocation` 6 | */ 7 | dataDir: process.env.BOTPRESS_DATA_DIR || "./data", 8 | port: 3000, 9 | modulesConfigDir: process.env.BOTPRESS_CONFIG_DIR || "./modules_config", 10 | disableFileLogs: false, 11 | notification: { 12 | file: 'notifications.json', 13 | maxLength: 50 14 | }, 15 | log: { 16 | file: 'bot.log', 17 | maxSize: 1e6 // 1mb 18 | }, 19 | 20 | /** 21 | * Access control of admin pabel 22 | */ 23 | login: { 24 | enabled: process.env.NODE_ENV === 'production', 25 | tokenExpiry: "6 hours", 26 | password: process.env.BOTPRESS_PASSWORD || "password", 27 | maxAttempts: 3, 28 | resetAfter: 5 * 60 * 10000 // 5 minutes 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /motivation-bot/data/rivescript/begin.rive: -------------------------------------------------------------------------------- 1 | ! version = 2.0 2 | 3 | // Substitutions 4 | ! sub i'm = i am 5 | ! sub i'd = i would 6 | ! sub i've = i have 7 | ! sub i'll = i will 8 | ! sub don't = do not 9 | ! sub isn't = is not 10 | ! sub you'd = you would 11 | ! sub you're = you are 12 | ! sub you've = you have 13 | ! sub you'll = you will 14 | ! sub what's = what is 15 | ! sub whats = what is 16 | ! sub what're = what are 17 | ! sub what've = what have 18 | ! sub what'll = what will 19 | ! sub who's = who is 20 | -------------------------------------------------------------------------------- /motivation-bot/data/rivescript/star.rive: -------------------------------------------------------------------------------- 1 | + * 2 | - JS: bp.botDefaultResponse(event) -------------------------------------------------------------------------------- /motivation-bot/index.js: -------------------------------------------------------------------------------- 1 | const Promise = require('bluebird') 2 | const _ = require('lodash') 3 | const videos = require('./videos') 4 | const subscription = require('./subscription') 5 | 6 | const TEXT_CATEGORIES = { 7 | WORK: [ 8 | "Hard work beats talent every time", 9 | "The marketplace punishes those that don't work hard", 10 | "You don't get paid for the time, you get paid for the value you bring" 11 | ], 12 | LIFE: [ 13 | "This one is really worth a watch", 14 | "You live only once.. don't mess it up", 15 | "What are your goals?" 16 | ], 17 | GYM: [ 18 | "Listening to that while on the threadmill will result in 20% more results", 19 | "Happy to be your workout mate... Watch this!", 20 | "If you are not pumped up after this video, I really don't know what to do" 21 | ] 22 | } 23 | 24 | const pickCategory = { 25 | quick_replies: [ 26 | { 27 | content_type: 'text', 28 | title: '🔥 Work 🔥', 29 | payload: 'GET_VIDEO_WORK' 30 | }, 31 | { 32 | content_type: 'text', 33 | title: '😌 Life Goals 🔥', 34 | payload: 'GET_VIDEO_LIFE' 35 | }, 36 | { 37 | content_type: 'text', 38 | title: '💪 Gym 🔥', 39 | payload: 'GET_VIDEO_GYM' 40 | } 41 | ], 42 | typing: true 43 | } 44 | 45 | module.exports = function(bp) { 46 | bp.middlewares.load() 47 | subscription(bp) 48 | 49 | bp.hear({ 50 | type: 'postback', 51 | text: 'GET_STARTED' 52 | }, (event, next) => { 53 | const { first_name, last_name } = event.user 54 | bp.logger.info('New user:', first_name, last_name) 55 | 56 | bp.subscription.subscribe(event.user.id, 'daily') 57 | 58 | const WELCOME_SENTENCES = [ 59 | "Hey, so I've heard that you need a little kick in the butt from time to time? Don't worry mate, that's my job and I'll do that for you 👏", 60 | "In exchange I only ask from you that you don't talk to me like I was human.. I'm clearly not! 🤖", 61 | "👉 Let's just stick to using buttons, that's going to be easier for the both of us" 62 | ] 63 | 64 | const WELCOME_TEXT_QUICK_REPLY = "That being said, choose a category right away and I'll make sure you get pumped up!" 65 | 66 | Promise.mapSeries(WELCOME_SENTENCES, txt => { 67 | bp.messenger.sendText(event.user.id, txt, { typing: true }) 68 | return Promise.delay(2000) 69 | }) 70 | .then(() => { 71 | bp.messenger.sendText(event.user.id, WELCOME_TEXT_QUICK_REPLY, pickCategory) 72 | }) 73 | }) 74 | 75 | bp.hear(/TRIGGER_DAILY/i, (event, next) => { 76 | bp.sendDailyVideo(event.user.id) 77 | }) 78 | 79 | const hearGetVideo = category => { 80 | bp.hear({ text: 'GET_VIDEO_' + category }, (event, next) => { 81 | const text = _.sample(TEXT_CATEGORIES[category]) 82 | bp.messenger.sendText(event.user.id, text) 83 | 84 | Promise.delay(1000) 85 | .then(() => bp.sendRandomVideo(event.user.id, category)) 86 | }) 87 | } 88 | 89 | // Create a listener for each categories 90 | _.keys(TEXT_CATEGORIES).forEach(hearGetVideo) 91 | 92 | bp.botDefaultResponse = event => { 93 | const ANSWERS = [ 94 | event.user.first_name + ", I told you, I'm a bit dumb. I assume you want motivation, 'cause that's all I'm able to do :)", 95 | "I don't understand much of what you say " + event.user.first_name, 96 | "I'm only here to give you motivation", 97 | "My creators made me dumb on purpose, they say I shouldn't try to be human-like :s", 98 | "I'm not here to talk " + event.user.first_name + ", I'm here to give you motivation!" 99 | ] 100 | 101 | const text = _.sample(ANSWERS) 102 | bp.messenger.sendText(event.user.id, text, pickCategory) 103 | } 104 | 105 | bp.sendRandomVideo = (userId, category) => { 106 | videos.getRandomVideo(category) 107 | .then(meta => { 108 | bp.messenger.sendTemplate(userId, { 109 | template_type: 'generic', 110 | elements: [{ 111 | title: meta.title, 112 | item_url: meta.url, 113 | image_url: meta.thumbnail, 114 | subtitle: meta.description, 115 | buttons: [ 116 | { 117 | type: 'web_url', 118 | title: '🔥 Watch 🔥', 119 | url: meta.url, 120 | webview_height_ratio: 'full' 121 | }, 122 | { 123 | type: 'postback', 124 | title: '👉 Next video', 125 | payload: 'GET_VIDEO_' + category 126 | }, 127 | { type: 'element_share' } 128 | ] 129 | }] 130 | }) 131 | }) 132 | 133 | const n = _.random(0, 10) 134 | if (n === 5) { // 10% chance of saying this 135 | setTimeout(() => { 136 | bp.messenger.sendText(userId, "PLEASE! If you enjoy the service I am giving you, consider sharing the card below with some of your friends 👇!") 137 | 138 | setTimeout(() => { 139 | bp.messenger.sendTemplate(userId, { 140 | template_type: 'generic', 141 | elements: [{ 142 | title: 'Clicking this button could literally change your life', 143 | item_url: 'https://m.me/boostfuel', 144 | image_url: 'https://s27.postimg.org/dl8i0udqb/motivation_on_demand.png', 145 | buttons: [{ 146 | type: 'web_url', 147 | title: '👏 Make it happen', 148 | url: 'https://m.me/boostfuel' 149 | }, { type: 'element_share' }] 150 | }] 151 | }) 152 | }, 2000) 153 | }, 15 * 1000) 154 | } 155 | } 156 | 157 | bp.sendDailyVideo = (userId) => { 158 | const category = _.sample(_.keys(TEXT_CATEGORIES)) 159 | const text = "Here's your daily motivational video, have an excellent day 😁!" 160 | 161 | bp.messenger.sendText(userId, text) 162 | setTimeout(() => bp.sendRandomVideo(userId, category), 1000) 163 | } 164 | } 165 | -------------------------------------------------------------------------------- /motivation-bot/modules_config/botpress-messenger.json: -------------------------------------------------------------------------------- 1 | {"applicationID":"","accessToken":"","appSecret":"","verifyToken":"b7fbc6be-fbc1-4c91-95fc-42eed23d2794","validated":false,"connected":true,"hostname":"31b1d75c.ngrok.io","ngrok":true,"displayGetStarted":true,"greetingMessage":"🔥 Hey {{user_first_name}}, my name is Boost. I've changed the lives of hundreds of people. \n\nI'm providing people with the motivation they need to:\n- Taking charge of your life\n- Gym & workout motivation\n- Work motivation\n\nDon't you want to be the next one? 💪\n.","persistentMenu":true,"persistentMenuItems":[{"type":"postback","title":"💪 GYM Motivation","payload":"GET_VIDEO_GYM"},{"type":"postback","title":"🔥 WORK Motivation","payload":"GET_VIDEO_WORK"},{"type":"postback","title":"😌 LIFE Motivation","payload":"GET_VIDEO_LIFE"},{"type":"postback","title":"👉 Manage my subscriptions","payload":"MANAGE_SUBSCRIPTIONS"}],"automaticallyMarkAsRead":true,"trustedDomains":["https://www.youtube.com"],"autoRespondGetStarted":false,"autoResponse":"Hello!","error":"","homepage":"https://github.com/botpress/botpress-messenger","message":""} -------------------------------------------------------------------------------- /motivation-bot/modules_config/botpress-subscription.json: -------------------------------------------------------------------------------- 1 | {"manage_keywords":["MANAGE_SUBSCRIPTIONS"],"manage_action":"bp.manageSubscriptions(bp, userId)","manage_type":"javascript"} -------------------------------------------------------------------------------- /motivation-bot/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "motivation-bot", 3 | "version": "0.0.1", 4 | "description": "Tutorial to show users how to build a chatbot easily.", 5 | "main": "index.js", 6 | "dependencies": { 7 | "axios": "^0.15.3", 8 | "bluebird": "^3.4.6", 9 | "botpress": "0.x", 10 | "botpress-analytics": "^1.0.7", 11 | "botpress-broadcast": "^1.0.9", 12 | "botpress-messenger": "^1.0.8", 13 | "botpress-rivescript": "^1.0.10", 14 | "botpress-scheduler": "^1.0.1", 15 | "botpress-subscription": "^1.0.2", 16 | "lodash": "^4.17.2", 17 | "moment": "^2.17.1" 18 | }, 19 | "scripts": { 20 | "start": "botpress start", 21 | "precommit": "node strip_tokens.js", 22 | "test": "echo \"Error: no test specified\" && exit 1" 23 | }, 24 | "author": "Botpress Team", 25 | "license": "AGPL-3.0", 26 | "devDependencies": { 27 | "husky": "^0.12.0" 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /motivation-bot/strip_tokens.js: -------------------------------------------------------------------------------- 1 | const fs = require('fs') 2 | 3 | const configPath = './modules_config/botpress-messenger.json' 4 | 5 | let content = JSON.parse(fs.readFileSync(configPath)) 6 | 7 | content.applicationID = '' 8 | content.accessToken = '' 9 | content.appSecret = '' 10 | content.error = '' 11 | content.message = '' 12 | 13 | fs.writeFileSync(configPath, JSON.stringify(content)) 14 | -------------------------------------------------------------------------------- /motivation-bot/subscription.js: -------------------------------------------------------------------------------- 1 | const axios = require('axios') 2 | const moment = require('moment') 3 | 4 | const manageSubscriptions = (bp, userId) => { 5 | return bp.subscription.isSubscribed(userId, 'daily') 6 | .then(subscribed => { 7 | if (subscribed) { 8 | bp.messenger.sendTemplate(userId, { 9 | template_type: 'button', 10 | text: "You are currently subscribed to receive daily motivational videos at 8AM (your time).", 11 | buttons: [ { type: 'postback', title: 'Unsubscribe', payload: 'UNSUBSCRIBE_DAILY'} ] 12 | }) 13 | } else { 14 | bp.messenger.sendTemplate(userId, { 15 | template_type: 'button', 16 | text: "Click the button below to subscribe to daily motivational videos. You'll receive one every day at 8AM (your time)!", 17 | buttons: [ { type: 'postback', title: 'Subscribe', payload: 'SUBSCRIBE_DAILY'} ] 18 | }) 19 | } 20 | }) 21 | } 22 | 23 | const scheduleBroadcast = (bp, api) => () => { 24 | const tomorrow = moment().add(1, 'day').format('YYYY-MM-DD') 25 | 26 | api.put('botpress-broadcast/broadcasts', { 27 | date: tomorrow, 28 | time: '08:00', 29 | timezone: null, // users timezone 30 | type: 'javascript', 31 | content: "bp.sendDailyVideo(userId)", 32 | filters: ["bp.subscription.isSubscribed(userId, 'daily')"] 33 | }) 34 | .catch(err => { 35 | bp.logger.error(err.response.data) 36 | bp.notifications.send({ 37 | level: 'error', 38 | message: 'Could not schedule broadcast. See logs.' 39 | }) 40 | }) 41 | } 42 | 43 | module.exports = bp => { 44 | const token = bp.security.login('admin', bp.botfile.login.password, '127.0.0.1').token 45 | 46 | const api = axios.create({ 47 | baseURL: 'http://localhost:' + bp.botfile.port + '/api/', 48 | headers: {'Authorization': token} 49 | }) 50 | 51 | bp.scheduleBroadcast = scheduleBroadcast(bp, api) 52 | bp.manageSubscriptions = manageSubscriptions 53 | } 54 | -------------------------------------------------------------------------------- /motivation-bot/videos.js: -------------------------------------------------------------------------------- 1 | const axios = require('axios') 2 | const _ = require('lodash') 3 | 4 | const videos = { 5 | WORK: [ 6 | "DNFtCIzJQ7A", 7 | "g-fGYtagSDY", 8 | "00rPgc0tISM", 9 | "qa9G5EdKiRw", 10 | "3AyH1fBN7ac", 11 | "HQtZ4kud2qA", 12 | "puDQoBPpWyQ", 13 | "A0Scr2TW2ZA", 14 | "2zzj4CO9xSw", 15 | "twZgNP8iZBQ", 16 | "8QlvQC4MXxs", 17 | "PF54jfEFhIM", 18 | "CPQ1budJRIQ", 19 | "_R8gBnhyMSA", 20 | "350F0VsECvo", 21 | "KA-6OwyGGfI", 22 | "Q23Exmnio8s" 23 | ], 24 | LIFE: [ 25 | "6tbHYvH347A", 26 | "6vuetQSwFW8", 27 | "7_R4AsV2fPI", 28 | "njQcOKOpFwk", 29 | "5g0QHTcwP8k", 30 | "t-H7_aAuiC8", 31 | "5e338_RFOr8", 32 | "U3V701IUZ2E", 33 | "ZkabeHig_r4", 34 | "FK16iXPRAjI", 35 | "4pxiU89O1wE", 36 | "2otRxX6y7mQ", 37 | "bGc9mXhdMkw", 38 | "UMF_oJkOZmg", 39 | "cRMogDrHnMQ", 40 | "pfWGoLj1JCM", 41 | "EyhOmBPtGNM", 42 | "5fOiu0OdpoI", 43 | "DNITe9snHqA", 44 | "GtCD6e1fa_I" 45 | ], 46 | GYM: [ 47 | "Fh-rCrREEgA", 48 | "xoXYe9e01_Y", 49 | "hV63DbQ_qSc", 50 | "YxzQ6umhH4Q", 51 | "lsSC2vx7zFQ", 52 | "aMGoxlXmA0o", 53 | "at7QvbFy9fM", 54 | "qapsrR8zIJM", 55 | "vnMtpNhcDOE", 56 | "OV6-n5wtCWA", 57 | "lpVRxa9jsrE", 58 | "7fSLbC-1b0Q", 59 | "n_8ZIYxtPvc", 60 | "j0FFNcIYZMI", 61 | "R1JBQMXbN2k", 62 | "B_3pHAhhdM0" 63 | ] 64 | } 65 | 66 | const getYoutubeVideoMetadata = (videoId) => { 67 | const YOUTUBE_API_KEY = 'AIzaSyAp2kmHzUFdlD1b4N4XR0OhKUWnC_IVaAA' 68 | const apiUrl = `https://content.googleapis.com/youtube/v3/videos?id=${videoId}&part=snippet&key=${YOUTUBE_API_KEY}` 69 | 70 | return axios.get(apiUrl) 71 | .then(res => { 72 | const video = res.data.items[0].snippet 73 | return { 74 | description: video.description, 75 | thumbnail: (video.thumbnails.high || video.thumbnails.standard).url, 76 | title: video.title, 77 | url: 'https://www.youtube.com/embed/' + videoId + '?autoplay=1' 78 | } 79 | }) 80 | } 81 | 82 | module.exports = { 83 | getRandomVideo: (category) => { 84 | if (!category) { 85 | category = _.sample(_.keys(videos)) 86 | } 87 | 88 | const videoId = _.sample(videos[category]) 89 | return getYoutubeVideoMetadata(videoId) 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /wit-bot/.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | /logs 3 | *.log 4 | npm-debug.log* 5 | 6 | # Runtime data 7 | pids 8 | *.pid 9 | *.seed 10 | *.pid.lock 11 | 12 | # Directory for instrumented libs generated by jscoverage/JSCover 13 | lib-cov 14 | 15 | # Coverage directory used by tools like istanbul 16 | coverage 17 | 18 | # nyc test coverage 19 | .nyc_output 20 | 21 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 22 | .grunt 23 | 24 | # node-waf configuration 25 | .lock-wscript 26 | 27 | # Compiled binary addons (http://nodejs.org/api/addons.html) 28 | build/Release 29 | 30 | # Dependency directories 31 | node_modules 32 | jspm_packages 33 | 34 | # Optional npm cache directory 35 | .npm 36 | 37 | # Optional eslint cache 38 | .eslintcache 39 | 40 | # Optional REPL history 41 | .node_repl_history 42 | 43 | # Output of 'npm pack' 44 | *.tgz 45 | 46 | # *** Botpress specifics *** 47 | /data 48 | api_keys 49 | -------------------------------------------------------------------------------- /wit-bot/LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | Copyright © 2007 Free Software Foundation, Inc. 4 | 5 | Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. 6 | 7 | Preamble 8 | The GNU General Public License is a free, copyleft license for software and other kinds of works. 9 | The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. 10 | When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. 11 | To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. 12 | For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. 13 | Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. 14 | For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. 15 | Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. 16 | Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. 17 | The precise terms and conditions for copying, distribution and modification follow. 18 | 19 | TERMS AND CONDITIONS 20 | 21 | 0. Definitions. 22 | “This License” refers to version 3 of the GNU General Public License. 23 | “Copyright” also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. 24 | “The Program” refers to any copyrightable work licensed under this License. Each licensee is addressed as “you”. “Licensees” and “recipients” may be individuals or organizations. 25 | To “modify” a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a “modified version” of the earlier work or a work “based on” the earlier work. 26 | A “covered work” means either the unmodified Program or a work based on the Program. 27 | To “propagate” a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. 28 | To “convey” a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. 29 | An interactive user interface displays “Appropriate Legal Notices” to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 30 | 31 | 1. Source Code. 32 | The “source code” for a work means the preferred form of the work for making modifications to it. “Object code” means any non-source form of a work. 33 | A “Standard Interface” means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. 34 | The “System Libraries” of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A “Major Component”, in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. 35 | The “Corresponding Source” for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. 36 | The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. 37 | The Corresponding Source for a work in source code form is that same work. 38 | 39 | 2. Basic Permissions. 40 | All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. 41 | You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. 42 | Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 43 | 44 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 45 | No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. 46 | When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 47 | 48 | 4. Conveying Verbatim Copies. 49 | You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. 50 | You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 51 | 5. Conveying Modified Source Versions. 52 | You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: 53 | • a) The work must carry prominent notices stating that you modified it, and giving a relevant date. 54 | • b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to “keep intact all notices”. 55 | • c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. 56 | • d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. 57 | A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an “aggregate” if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 58 | 59 | 6. Conveying Non-Source Forms. 60 | You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: 61 | • a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. 62 | • b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. 63 | • c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. 64 | • d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. 65 | • e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. 66 | A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. 67 | A “User Product” is either (1) a “consumer product”, which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, “normally used” refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. 68 | “Installation Information” for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. 69 | If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). 70 | The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. 71 | Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 72 | 73 | 7. Additional Terms. 74 | “Additional permissions” are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. 75 | When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. 76 | Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: 77 | • a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or 78 | • b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or 79 | • c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or 80 | • d) Limiting the use for publicity purposes of names of licensors or authors of the material; or 81 | • e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or 82 | • f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. 83 | All other non-permissive additional terms are considered “further restrictions” within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. 84 | If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. 85 | Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 86 | 87 | 8. Termination. 88 | You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). 89 | However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. 90 | Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. 91 | Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 92 | 93 | 9. Acceptance Not Required for Having Copies. 94 | You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 95 | 96 | 10. Automatic Licensing of Downstream Recipients. 97 | Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. 98 | An “entity transaction” is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. 99 | You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 100 | 101 | 11. Patents. 102 | A “contributor” is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's “contributor version”. 103 | A contributor's “essential patent claims” are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, “control” includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. 104 | Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. 105 | In the following three paragraphs, a “patent license” is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To “grant” such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. 106 | If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. “Knowingly relying” means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. 107 | If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. 108 | A patent license is “discriminatory” if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. 109 | Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 110 | 111 | 12. No Surrender of Others' Freedom. 112 | If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 113 | 114 | 13. Use with the GNU Affero General Public License. 115 | Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 116 | 117 | 14. Revised Versions of this License. 118 | The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. 119 | Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License “or any later version” applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. 120 | If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. 121 | Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 122 | 123 | 15. Disclaimer of Warranty. 124 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 125 | 126 | 16. Limitation of Liability. 127 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 128 | 129 | 17. Interpretation of Sections 15 and 16. 130 | If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. 131 | 132 | END OF TERMS AND CONDITIONS 133 | 134 | How to Apply These Terms to Your New Programs 135 | If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. 136 | To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the “copyright” line and a pointer to where the full notice is found. 137 | The world's first CMS for bots. Create, manage and extend chatbots in seconds. Copyright (C) 2016 Botpress This program is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation, either version 3 of the License, or
 (at your option) any later version.

 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with this program. If not, see . 138 | Also add information on how to contact you by electronic and paper mail. 139 | If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: 140 | Botpress Copyright (C) 2016 Botpress
 This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
 This is free software, and you are welcome to redistribute it
 under certain conditions; type `show c' for details. 141 | The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an “about box”. 142 | You should also get your employer (if you work as a programmer) or school, if any, to sign a “copyright disclaimer” for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . 143 | The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read . 144 | -------------------------------------------------------------------------------- /wit-bot/README.md: -------------------------------------------------------------------------------- 1 | # Tutorial 2 | 3 | This tutorial will show you how easy it is to build a bot using the Messenger and Wit.ai modules. For this purpose, we will build a bot from scratch and we will end up with a simple weather bot in about 30 minutes. If run into problems, do not hesitate to talk to us on our [Slack Community](https://slack.botpress.io); it will be a pleasure for us to answer your requests. 4 | 5 | If you don't want to follow our step-by-step guide, you can clone this repository and just try it by linking it to a Facebook page (via the Messenger module, [Step #6](#configure-messenger)) and your Wit.ai account ([Step #7](#configure-wit)). If you clone this repository, don't forget to run `npm install` in your repository. 6 | 7 | ## Table of contents 8 | * [Requirements](#requirements) 9 | * [Step-by-step](#step-by-step) 10 | * [Install Botpress](#install-botpress) 11 | * [Create a new repository](#create-new-repo) 12 | * [Initialize Botpress](#initialize-botpress) 13 | * [Install Botpress modules](#install-botpress-modules) 14 | * [Start Botpress](#start-botpress) 15 | * [Configure Messenger connection settings](#configure-messenger) 16 | * [Verifying your configuration](#verifying-connection) 17 | * [Configure your Wit.ai account](#configure-wit) 18 | * [Select Wit.ai mode](#select-wit-mode) 19 | * [Create a story](#create-story) 20 | * [Open your repo in an editor](#open-repo-editor) 21 | * [Implement the getWeather() action](#implement-getweather) 22 | * [Chat with your bot](#chat-with-bot) 23 | * [Have fun](#have-fun) 24 | * [Community](#community) 25 | * [License](#license) 26 | 27 | ## Requirements 28 | 29 | Botpress requires [node](https://nodejs.org) (version >= 4.2) and uses [npm](https://www.npmjs.com) as package manager. 30 | 31 | ## Step-by-step 32 | 33 | ### 1. Install Botpress 34 | 35 | You need to have `botpress` installed as a general dependency using `npm`. If it's already done, you only need to install it using the following command (make sure to install it globally). 36 | 37 | ``` 38 | npm install -g botpress 39 | ``` 40 | 41 | ### 2. Create a new repository 42 | 43 | Once `botpress` has been installed, you need to create a new repository and cd into it. 44 | 45 | ```js 46 | mkdir wit-bot && cd wit-bot // Mac and Linux users 47 | 48 | md wit-bot && cd wit-bot // Windows users 49 | ``` 50 | 51 | ### 3. Initialize Botpress 52 | 53 | Now, let's use the command line interface to initialize your bot. You need to run the following command. 54 | 55 | ``` 56 | botpress init 57 | ``` 58 | 59 | ### 4. Install Botpress modules 60 | 61 | Directly in your command line again, you need to install the [botpress-messenger](https://github.com/botpress/botpress-messenger) module to connect your bot to a Facebook page. Also, make sure to install the [botpress-wit](https://github.com/botpress/botpress-wit) module to connect our bot to your Wit.ai account. 62 | 63 | ``` 64 | botpress install messenger wit 65 | ``` 66 | 67 | ### 5. Start Botpress 68 | 69 | Once you have everything installed, you can start your bot and see what it includes. 70 | 71 | ``` 72 | botpress start 73 | ``` 74 | 75 | Go to http://localhost:3000 and from there you can install other modules as desired, but for this tutorial we only need `botpress-messenger` and `botpress-wit` which are supposed to already be installed. 76 | 77 | ### 6. Configure Messenger connection settings 78 | 79 | Before starting to code, you need to configure Messenger so it's connected directly to your Facebook page. If this is your first time to configure Messenger, we recommend following our [getting started guide](https://docs.botpress.io/getting-started.html) in the official Botpress documentation. 80 | 81 | 82 | 83 | Briefly, you only need to create a [Facebook page](https://www.facebook.com/pages/create) if you don't already have one. You also need to create a new [Messenger app](https://developers.facebook.com/) on Facebook. After that, you should find your **App ID**, **App Secret**, and **Token Access**, and paste them directly into the `botpress-messenger` module settings of the [Botpress user interface](http://localhost:3000/modules/botpress-messenger) running locally. Finally, you only need to activate [**ngrok**](https://ngrok.com/), **validate**, and **connect** your bot. 84 | 85 | For further information on configuring `botpress-messenger` see the [Getting Started documentation](https://docs.botpress.io/getting-started.html). 86 | 87 | #### Verifying your configuration 88 | 89 | After connecting the Botpress Messenger module with your Facebook Messenger app in the step above, you can verify that everything's working by opening a chat tab on your Facebook page and typing `BOT_LICENSE`. 90 | 91 | The bot should answer your user message, for example with: 92 | 93 | ``` 94 | Bot: motivation-bot 95 | Created by: GB 96 | License: AGPL-3.0 97 | Botpress: 0.0.50 98 | ``` 99 | 100 | **Note**: `BOT_LICENSE` is a Botpress command to display basic information about your bot (name, version, licenses). 101 | 102 | 103 | ### 7. Configure your Wit.ai account 104 | 105 | The next step is to link your `botpress-wit` module to your Wit.ai account. To do this, you only need to fill the **Access token** field in the user interface of the module. 106 | 107 | 108 | 109 | First, you need to create an account on the [Wit.ai homepage](http://www.wit.ai) if you don't already have one. Once your account is created, you now have to create a new application on Wit.ai. By default however, if you just created your account, an application should automatically be created for you (MyFirstApp). 110 | 111 | Click on **Settings** and then look in the **API Details** panel to copy your `Server Access Token`. 112 | 113 | 114 | 115 | ### 8. Select Wit.ai mode 116 | 117 | Next, you need to switch the mode in the `botpress-wit` module from Understanding to Stories by selecting the **Stories** checkbox. 118 | 119 | 120 | 121 | - Understanding mode will inject understanding metadata inside incoming messages through the Wit.ai middleware. Events will have a wit property populated with the extracted entities and the context. 122 | 123 | - Stories mode will run your Wit.ai stories automatically given that you defined the Actions in botpress. For more information about Actions and how they are run, make sure to read [node-wit's documentation](https://github.com/wit-ai/node-wit). 124 | 125 | ### 9. Create a story 126 | 127 | You will need to create a new story or interaction in your Wit.ai account. We will begin by creating a simple "hello world" story to test if everything works. You can create your own interaction to test the bot if you want to. (Do make sure to click **Save story** when done.) 128 | 129 | 130 | 131 | If everything works fine, your bot should respond appropriately when you type `Hello!` on [Messenger](https://www.messenger.com/) or [Facebook](https://www.facebook.com). 132 | 133 | 134 | 135 | **Note**: From here, if you want to only build a conversation using Wit.ai, you have everything you need without having to have code anything. 136 | 137 | ### 10. Add a weather action 138 | 139 | Now that we have a basic "hello world" conversation, we want to ask about the weather. To do that, we need to add some basic interactions where we ask Wit.ai to call our action `getWeather()`. 140 | 141 | We do this by adding another story or interaction as shown below. Make sure to specify the `wit/location` entity. When entering the **weather** context, you can leave the **context-key** field blank. 142 | 143 | 144 | 145 | ### 11. Open your repo in an editor 146 | 147 | Once you've set up these two interactions in Wit.ai, you need to implement this action in your bot. To do this, open your repository in your code editor (Sublime, Atom, WebStorm, Netbeans, ...). As you can see, some files and directories have already been created when you had previously initialized the repo with `botpress init`: 148 | 149 | ```js 150 | - botfile.js // your bot's configuration 151 | - index.js // your bot's entry point. the bot logic goes here 152 | - package.json // regular node package.json file 153 | - LICENSE // your bot license, either AGPLv3 or Botpress License 154 | - .gitignore // ignore some botpress-created files by default 155 | ``` 156 | 157 | ### 12. Implement the `getWeather()` action 158 | 159 | Now, open `index.js` and write (or paste) the following lines of code. We want to implement `getWeather()` and add `weather` to our `context` object. To do that, we call an external API to get the weather and we return a modified `context` object to Wit.ai. 160 | 161 | ```js 162 | var syncRequest = require('sync-request'); 163 | 164 | const getRequestAPI = (location, units) => { 165 | const OPEN_WEATHER_API_KEY = '' 166 | return "http://api.openweathermap.org/data/2.5/weather?" + 167 | "q=" + location + 168 | "&units=" + units + 169 | "&appid=" + OPEN_WEATHER_API_KEY 170 | } 171 | 172 | module.exports = function(bp) { 173 | bp.middlewares.load() 174 | 175 | // Implement your Actions like this 176 | bp.wit.actions['getWeather'] = request => { 177 | return new Promise((resolve, reject) => { 178 | 179 | // Get location from entities 180 | const location = request.entities.location[0].value 181 | 182 | //Get temperature from API 183 | const requestAPI = getRequestAPI(location, 'metric') 184 | const res = JSON.parse(syncRequest('GET', requestAPI).body); 185 | const temperature = res.main.temp 186 | 187 | request.context.weather = temperature + ' C' 188 | resolve(request.context) 189 | }) 190 | } 191 | 192 | // You need to call this method once you are done implementing the Actions 193 | bp.wit.reinitializeClient() 194 | } 195 | ``` 196 | 197 | **Note 1**: If you want to run this bot, you will need to register with [OpenWeatherMap](http://api.openweathermap.org/) and get your own ``. 198 | 199 | **Note 2**: Make sure the node package `sync-request` is installed before running the above code. 200 | 201 | ### 13. Chat with your bot 202 | 203 | Once everything is done, you should now be able to chat with your bot and ask him about current weather at the location you want. 204 | 205 | 206 | 207 | **Note**: Here we only implemented a basic interaction. But with our `botpress-wit` module you can achieve far more. Now it's your turn to implement your own actions using Wit.ai to build conversations. And in doing so, you will build an **awesome** bot. 208 | 209 | ## Have fun 210 | 211 | Building a bot with botpress is as simple as that! In fact, it took us only a relatively short amount of time to do everything (code and tutorial). 212 | 213 | Feel free to fork our bot, send pull requests, clone it, send comments, etc. 214 | 215 | ## Community 216 | 217 | Pull requests are welcome! We believe that it takes all of us to create something big and impactful. 218 | 219 | There's a [Slack community](https://slack.botpress.io) where you are welcome to join us, ask any question, and even help others. 220 | 221 | Get an invite to join us now! 👉[https://slack.botpress.io](https://slack.botpress.io). 222 | 223 | ## License 224 | 225 | `wit-bot` is licensed under [AGPL-3.0](/LICENSE). -------------------------------------------------------------------------------- /wit-bot/assets/messenger-connexion-settings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/botpress/botpress-examples/73e37c01ec3f6342c827f713f7beb5b086e86f0f/wit-bot/assets/messenger-connexion-settings.png -------------------------------------------------------------------------------- /wit-bot/assets/wit-access-token.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/botpress/botpress-examples/73e37c01ec3f6342c827f713f7beb5b086e86f0f/wit-bot/assets/wit-access-token.png -------------------------------------------------------------------------------- /wit-bot/assets/wit-connexion-settings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/botpress/botpress-examples/73e37c01ec3f6342c827f713f7beb5b086e86f0f/wit-bot/assets/wit-connexion-settings.png -------------------------------------------------------------------------------- /wit-bot/assets/wit-conversation-weather.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/botpress/botpress-examples/73e37c01ec3f6342c827f713f7beb5b086e86f0f/wit-bot/assets/wit-conversation-weather.png -------------------------------------------------------------------------------- /wit-bot/assets/wit-documentation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/botpress/botpress-examples/73e37c01ec3f6342c827f713f7beb5b086e86f0f/wit-bot/assets/wit-documentation.png -------------------------------------------------------------------------------- /wit-bot/assets/wit-hello.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/botpress/botpress-examples/73e37c01ec3f6342c827f713f7beb5b086e86f0f/wit-bot/assets/wit-hello.png -------------------------------------------------------------------------------- /wit-bot/assets/wit-settings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/botpress/botpress-examples/73e37c01ec3f6342c827f713f7beb5b086e86f0f/wit-bot/assets/wit-settings.png -------------------------------------------------------------------------------- /wit-bot/assets/wit-test.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/botpress/botpress-examples/73e37c01ec3f6342c827f713f7beb5b086e86f0f/wit-bot/assets/wit-test.png -------------------------------------------------------------------------------- /wit-bot/assets/wit-weather.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/botpress/botpress-examples/73e37c01ec3f6342c827f713f7beb5b086e86f0f/wit-bot/assets/wit-weather.png -------------------------------------------------------------------------------- /wit-bot/botfile.js: -------------------------------------------------------------------------------- 1 | 2 | module.exports = { 3 | 4 | /** 5 | * where the content is stored 6 | * you can access this property from `bp.dataLocation` 7 | */ 8 | dataDir: process.env.BOTPRESS_DATA_DIR || "./data", 9 | 10 | modulesConfigDir: process.env.BOTPRESS_CONFIG_DIR || "./modules_config", 11 | disableFileLogs: false, 12 | port: process.env.BOTPRESS_PORT || 3000, 13 | notification: { 14 | file: 'notifications.json', 15 | maxLength: 50 16 | }, 17 | log: { 18 | file: 'bot.log', 19 | maxSize: 1e6 // 1mb 20 | }, 21 | 22 | /** 23 | * Access control of admin pabel 24 | */ 25 | login: { 26 | enabled: process.env.NODE_ENV === 'production', 27 | tokenExpiry: "6 hours", 28 | password: process.env.BOTPRESS_PASSWORD || "password", 29 | maxAttempts: 3, 30 | resetAfter: 5 * 60 * 10000 // 5 minutes 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /wit-bot/index.js: -------------------------------------------------------------------------------- 1 | const Promise = require('bluebird') 2 | const axios = require('axios') 3 | 4 | // Get yours here: https://openweathermap.org/appid 5 | const OPEN_WEATHER_API_KEY = process.env.WEATHER_API || '' 6 | 7 | const getLocationWeatherUrl = (location, units) => { 8 | return "http://api.openweathermap.org/data/2.5/weather?" + 9 | "q=" + location + 10 | "&units=" + units + 11 | "&appid=" + OPEN_WEATHER_API_KEY 12 | } 13 | 14 | module.exports = function(bp) { 15 | bp.middlewares.load() 16 | 17 | // Implement your Actions like this 18 | bp.wit.actions['getWeather'] = request => { 19 | // Get location from extracted entities 20 | const location = request.entities.location[0].value 21 | 22 | const url = getLocationWeatherUrl(location, 'metric') 23 | 24 | // Fetch temperature from API 25 | return axios.get(url) 26 | .then(res => { 27 | const temperature = res.data.main.temp 28 | 29 | // setting the temperature in Wit context 30 | request.context.weather = temperature + '°C' 31 | 32 | // return the new context back to Wit 33 | return request.context 34 | }) 35 | } 36 | 37 | // You need to call this method once you are done implementing the Actions 38 | bp.wit.reinitializeClient() 39 | } 40 | -------------------------------------------------------------------------------- /wit-bot/modules_config/botpress-messenger.json: -------------------------------------------------------------------------------- 1 | {"applicationID":"","accessToken":"","appSecret":"","verifyToken":"123456","validated":false,"connected":true,"hostname":"dabdb971.ngrok.io","ngrok":true,"displayGetStarted":false,"greetingMessage":"Default greeting message","persistentMenu":false,"persistentMenuItems":[],"automaticallyMarkAsRead":true,"trustedDomains":[],"autoRespondGetStarted":true,"autoResponse":"Hello!","homepage":"https://github.com/botpress/botpress-examples/wit-bot"} -------------------------------------------------------------------------------- /wit-bot/modules_config/botpress-wit.json: -------------------------------------------------------------------------------- 1 | {"accessToken":"","selectedMode":"stories"} -------------------------------------------------------------------------------- /wit-bot/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "wit-bot", 3 | "version": "0.0.1", 4 | "description": "This is a tutorial to show how to use Wit.ai on Botpress", 5 | "main": "index.js", 6 | "dependencies": { 7 | "axios": "^0.15.3", 8 | "bluebird": "^3.4.6", 9 | "botpress": "0.x", 10 | "botpress-messenger": "^1.0.13", 11 | "botpress-wit": "^1.0.2" 12 | }, 13 | "scripts": { 14 | "start": "botpress start", 15 | "test": "echo \"Error: no test specified\" && exit 1" 16 | }, 17 | "author": "Botpress", 18 | "license": "AGPL-3.0" 19 | } 20 | --------------------------------------------------------------------------------