botbook/book/chapter-06-gbapp-reference.md

297 lines
13 KiB
Markdown
Raw Normal View History

2019-03-01 15:34:29 -03:00
# .gbapp Guide
2020-10-02 09:24:18 -03:00
![generalbots-2018](https://user-images.githubusercontent.com/65977273/94922431-949c3900-0490-11eb-800a-6b478d689f2a.png)
2019-03-01 15:34:29 -03:00
## Introduction
.gbapp is the folder extension for the General Bots Application package type.
Anything inside a folder considered a .gbapp will be consumed by the server
like a TypeScript application. This conversational application will contain
the source code for custom dialogs and behaviour for any .gbot that associate
this deployed .gbapp.
A good way to start a .gbapp is to find a NPM package to create a .gbapp that
asks for data and output the result. For example, a temperature package can
be installed via `npm install temperature` and then have its methods
convertToKelvin or convertToCelsius called when user asks for conversion. A
.gbapp can persist and read data from database according to the conversation
session.
2019-03-01 15:34:29 -03:00
## Preparing Environment
2021-07-18 09:33:27 -03:00
General procedures:
1. Get SubscriptionId, username and password;
2. Create AppId and Secret;
3. Deploy General Bots;
4. /setupSecurity to get access to Bot Drive;
5. /publish to publish packages on root bot.
2019-03-01 15:34:29 -03:00
### Windows
2019-11-11 12:24:06 -03:00
#### PowerShell Script
2022-10-19 11:27:29 -03:00
Copy and paste on a PowerShell prompt with elavated privileges and when VSCode is opened just press F5 to run the development server.
Please ensure that Node.js is not installed.
2019-11-11 12:24:06 -03:00
2020-06-11 09:48:42 -03:00
``` powershell
2019-11-11 12:24:06 -03:00
Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
cinst git --confirm
2021-04-23 11:15:03 -03:00
cinst nodejs --confirm --version=14.10.1
2019-11-11 12:24:06 -03:00
cinst vscode --confirm
2022-10-19 11:39:35 -03:00
Install Python: https://www.python.org/downloads/release/python-2718/
2020-04-25 22:48:51 -03:00
npm install windows-build-tools -g
2022-10-17 18:02:57 -03:00
npm install -g node-gyp
2019-11-11 12:24:06 -03:00
&"C:\Program Files\Git\bin\git.exe" clone https://github.com/GeneralBots/BotServer.git
cd BotServer
&"C:\Program Files\Microsoft VS Code\bin\code.cmd" .
```
2020-06-11 09:48:42 -03:00
2021-11-22 08:21:11 -03:00
### Linux (Ubuntu)
2021-11-23 07:38:19 -03:00
Visual Studio Code
2021-11-22 08:22:54 -03:00
```
2021-11-22 08:21:11 -03:00
sudo apt update
sudo apt install software-properties-common apt-transport-https wget
wget -q https://packages.microsoft.com/keys/microsoft.asc -O- | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://packages.microsoft.com/repos/vscode stable main"
sudo apt update
sudo apt install code
2022-07-23 15:47:33 -03:00
2021-11-22 08:22:54 -03:00
```
2021-11-22 08:21:11 -03:00
2021-11-23 08:05:16 -03:00
Node JS 14
2021-11-22 18:58:12 -03:00
```
2021-11-23 08:05:16 -03:00
2021-11-23 07:38:19 -03:00
curl -fsSL https://deb.nodesource.com/setup_14.x | sudo -E bash -
sudo apt-get install -y nodejs
node -v
2021-11-23 08:07:39 -03:00
sudo apt install npm
npm -v
2021-11-22 18:58:12 -03:00
```
2021-11-22 08:21:11 -03:00
2022-10-17 17:55:00 -03:00
Additional Infrastructure
```
sudo apt-get install libxtst-dev
apt-get install libpng-dev
sudo apt-get install python g++ build-essential
2022-10-17 18:02:57 -03:00
npm install -g node-gyp
2022-10-17 17:55:00 -03:00
```
2020-10-05 13:19:25 -03:00
### Commands to check version of Node.js and NPM.
![verificar](https://user-images.githubusercontent.com/65977273/95104867-bace0d00-070c-11eb-9699-66d3b6134ea5.png)
2019-11-11 12:24:06 -03:00
#### Manual steps.
2020-09-23 10:21:13 -03:00
1. Install [Chocolatey](https://chocolatey.org/install), a Windows Package Manager;
2. Install [git]( `https://git-scm.com/` ), a Software Configuration Management (SCM) and TortoiseGit;
2020-06-11 09:48:42 -03:00
3. Install [Node.js](https://npmjs.com/get-npm), a [Runtime system](https://en.wikipedia.org/wiki/Runtime_system);
2019-03-01 15:34:29 -03:00
4. Install Visual Studio Code Insiders, Brackets or Atom as an editor of your choice;
5. Fork the repository by visiting https://github.com/pragmatismo-io/BotServer/fork;
2020-06-11 09:48:42 -03:00
6. Clone the just forked repository by running `git clone <your-forked-repository-url>/BotServer.git` ;
7. Run the bot server by `gbot.cmd` .
2019-03-01 15:34:29 -03:00
2021-11-06 08:51:11 -03:00
#### Common Errors
- The subscription is not registered to use namespace 'Microsoft.Web'. See https://aka.ms/rps-not-found for how to register subscriptions.
-- Enter Azure | <Subscription> | Resource providers | Find Microsoft.Web and check it.
2019-08-21 08:50:47 -03:00
* Required packages
2019-03-01 15:34:29 -03:00
2020-06-11 09:48:42 -03:00
``` cmd
2019-03-01 15:34:29 -03:00
cinst git --confirm
cinst nodejs --confirm
2020-04-25 22:48:51 -03:00
npm install windows-build-tools -g
2020-09-23 10:21:13 -03:00
cinst tortoisegit --confirm
2019-08-21 08:50:47 -03:00
```
* Optional packages
2020-06-11 09:48:42 -03:00
```
2019-03-01 15:34:29 -03:00
cinst 7zip.install --confirm
cinst tortoisegit --confirm
cinst winscp --confirm
cinst sysinternals --confirm
cinst putty --confirm
cinst pandoc --confirm
cinst curl --confirm
cinst micro --confirm
cinst ccleaner --confirm
cinst notepadplusplus --confirm
cinst sql-server-management-studio --confirm
```
2019-08-21 08:50:47 -03:00
* node packages
2020-06-11 09:48:42 -03:00
```
2019-08-21 08:50:47 -03:00
npm install -g npm-check-updates
2020-11-22 12:42:31 -03:00
npm install -g cost-of-modules
2019-08-21 08:50:47 -03:00
```
2021-12-10 15:23:29 -03:00
Linux
```
# MS Remote Desktop Connection (RDP Client)
sudo apt-add-repository ppa:remmina-ppa-team/remmina-next
sudo apt update
sudo apt install remmina remmina-plugin-rdp remmina-plugin-secret
```
2022-01-14 08:46:40 -03:00
# File compression
```
Compressing a directory in Linux:
tar -cvzf my_archive.tar.gz input_dir
Expanding an archive in Linux:
tar -xf my_archive.tar.gz
```
2021-12-10 15:23:29 -03:00
2019-03-01 15:34:29 -03:00
![General Bots Inside Visual Studio Code provides a complete artificial intelligence based conversational platform](https://raw.githubusercontent.com/pragmatismo-io/BotServer/master/docs/images/general-bots-inside-visual-studio-code-provides-a-complete-artificial-intelligence-based-conversational-platform.png)
## Specifications
## Dialogs
The dialog is built by specifing series of methods, disposed as an array as seen
on Figure 1. Each dialog has also an identifier that can be called by several
engines like kb.gbapp, which handles cloud based search for documents and other
knowledge base information and also routes for the natural language processing
(NLP) engine.
2020-06-11 09:48:42 -03:00
``` typescript
2019-03-01 15:34:29 -03:00
static getDialogs(bot: BotAdapter, min: GBMinInstance) {
return [{name:"/convertTemperature", waterfall: [
async step => {
},
async step => {
},
async step => {
}]
},{name:"/convertCurrency", waterfall: [
async step => {
},
async step => {
},
async step => {
}]
}
]
```
*Figure 1 - How to build dialogs in General Bots using TypeScript*
2020-09-30 15:30:38 -03:00
## Fork concept
2020-09-30 15:31:10 -03:00
Is the implementation of new software based on existing software. The branch takes advantage of the data already used in other software to generate a new one.
2020-10-07 10:40:13 -03:00
This in some way contributes to a better understanding of how it works.
2020-09-29 10:16:35 -03:00
## How To...
### Debugging .gbapp deployed on Azure
1. Visit https://<SITENAME>.scm.azurewebsites.net/api/vfs/LogFiles/Application/index.html
2019-03-01 15:34:29 -03:00
## Tooling
### JavaScript
2020-06-11 09:48:42 -03:00
| Título | Endereço |
|---------------------------------------------|---------------------------------------------------------------------------------------------------|
| | https://deeplearnjs.org/ |
| | Oimo.js http://lo-th.github.io/Oimo.js/\#stacking |
| | js-sequence-diagrams: https://bramp.github.io/js-sequence-diagrams/ |
| | http://blog.avenuecode.com/a-library-for-data-visualization-d3.js |
| Chrome inside Node.js | https://github.com/GoogleChrome/puppeteer |
| XLSX loader | https://github.com/mgcrea/node-xlsx |
| Node.js bindings for CNTK | https://github.com/nadavbar/node-cntk |
| API Repository | https://any-api.com/ |
| ORM | |
| Migração de . NET para JavaScript (Node.js) | https://www.reddit.com/r/webdev/comments/2val7s/as_a_net_developer_do_i_need_to_care_about_nodejs |
| Simplified JavaScript Jargon | http://jargon.js.org |
2019-03-01 15:34:29 -03:00
### Packages
2019-03-01 17:41:18 -03:00
| Título | Descrição | URL |
|--------|----------------------------------|------------------------------------|
| MSAL | Microsoft Authentication Library | https://www.npmjs.com/package/msal |
2019-03-01 15:34:29 -03:00
2020-06-11 09:48:42 -03:00
### Visual Studio Code Shotcut keys
2019-03-01 15:34:29 -03:00
2020-06-11 09:48:42 -03:00
| Key | Description |
|--------------------------|-------------------------------------------------------------------------------|
| F8 | Next error. |
2020-10-19 14:10:32 -03:00
| F12 | Go to symbol definition. |
2020-06-11 09:48:42 -03:00
| F5 | Run. |
| CTRL + . | Auto refactoring (Fix). |
| ALT + SHIFT + DOWN ARROW | Duplicate the line code. |
| CTRL + SHIFT + H | Replace all followed by CTRL + ALT + ENTER on replace text box. |
| CTRL + SHIFT + B | Compile inside VSCode, you can also open an external terminal and run tsc -w. |
| CTRL + G | Go to the specified line. |
| CTRL + SHIFT + G | Goes to Git. |
2020-10-16 11:58:46 -03:00
| CTRL + SHIFT+P | Opens the Command Palette |
| CTRL + ALT+UP/DOWN ARROW | Enter the Vertical Selection mode |
| ALT + UP/DOWN ARROW | Move lines |
2019-03-01 15:34:29 -03:00
2020-06-11 09:48:42 -03:00
### Visual Studio Code Extensions
2019-03-01 15:34:29 -03:00
2019-03-01 17:41:18 -03:00
| Title | Description |
|----------------------------------------------|-----------------------------------------------------------------|
| mbinic.tgit-cmds | Set of commands for launching TortoiseGit dialogs |
2019-03-01 15:34:29 -03:00
| tomashubelbauer.vscode-markdown-table-format | Formats MarkDown tables so that all columns have the same width |
2019-03-01 17:41:18 -03:00
| esbenp.prettier-vscode | VS Code plugin for prettier/prettier (wraps at column 80) |
| mikestead.dotenv | .env support |
| abhinavk99.codewall | Description here |
| christian-kohler.npm-intellisense | Description here |
| csholmq.excel-to-markdown-table | Description here |
| davidanson.vscode-markdownlint | Description here |
| eg2.ts-tslint | Description here |
| eg2.vscode-npm-script | Description here |
| esbenp.prettier-vscode | Description here |
| formulahendry.auto-rename-tag- | Description here |
| gruntfuggly.align-mode | Description here |
| jmfirth.vsc-space-block-jumper | Description here |
| kaiwood.indentation-level-movement | Description here |
| mbinic.tgit-cmds | Description here |
| mechatroner.rainbow-csv | Description here |
| mikestead.dotenv | Description here |
| sirtori.indenticator | Description here |
| tandy.color-basic | Description here |
## Common tasks
| Task | Description |
|---------------|-------------------------------------|
| npm update -g | Updates NPM |
| node -v | Checks node version |
| ncu -a | Update all packages in package.json |
2020-11-12 08:47:38 -03:00
## Useful documentation
-https://www.typescriptlang.org/docs/handbook (TypeScript Documentation).