GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com โ€” GitHub - dmdin/Dialute: ๐Ÿงถ The fastest way to build an app for SberSalute

BranchesTags
Open more actions menu

Latest commit

 

History

62 Commits
62 Commits

Folders and files

NameName
Last commit message
Last commit date
example
example
 
 
src
src
 
 
.eslintrc
.eslintrc
 
 
.gitignore
.gitignore
 
 
.prettierrc
.prettierrc
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
package.json
package.json
 
 
pnpm-lock.yaml
pnpm-lock.yaml
 
 
tsconfig.json
tsconfig.json
 
 

Repository files navigation

๐Ÿงถ Dialute

The way you will want to create Chat and Canvas Apps for SberSalute. Use the power of generator based scripts and simple interface of the framework. Based on SmartApp API

โš™๏ธ Install

The framework is published in NPM, thus you can simply install it into your existing

$: npm install dialute

The preferred way to initialize the project is to clone needed template and immediately start development.

$: git clone https://github.com/Dikower/dialute-starter-svelte
# or simply
$: npx degit dikower/dialute-starter-svelte

๐Ÿš€ Startup

Dialute uses Express behind to handle requests from SmartMarket. Thanks to the framework, you can skip all boring and routine stuff about parsing request bodies and managing sessions of users and focus on logic and dialog creation using JavaScript Generators. If you are using example or template and familiar with ngrok, just run

# Shell โ„–1
$: npm run dev

#-------------
# Shell โ„–2
$: ngrok http 8000

๐Ÿ’Ž Concept

The generator represents a dialog. When a user sends a message it triggers the update of SberRequest object, that is passed to the generator as reference. That's why you can easily read the updated message from the same variable. On the other hand, yield will return the content, you pass to user, and then will wait until next message to continue executing script. The generator saves context inside, so it helps us to construct state dependent dialog using just plain JavaScript or TypeScript

  • Import the framework starter and SberRequest for type annotation

    import { Dialute, SberRequest } from 'dialute';
  • Write a generator, that describes the dialog. It must have one required argument: SberRequest and one optional argument Context, you can

      // You can use any name for generator you want
      // r: this is a ref for SberRequest, it will be updated after each user message
      // ctx: Optional argument for advanced techniques, you can skip it for now
      // function* script(r: SberRequest, ctx: any) {
      function* script(r: SberRequest) { // Also possible
        while (true) {
          // send the message to user 
          yield 'Hello world from Dialute!';
          // yield r.msg  // This will make echo-bot, that repeats user input
        }
      }
  • Set the entrypoint of dialog and start the server

    // Creates ready to start server from generator
    const d = Dialute.fromEntrypoint(script as GeneratorFunction);
    // Starts listening for requests from SmartMarket
    d.start();
  • Use nodemon in package.json scripts to enable hot reload

    "scripts": {
      "dev": "nodemon --exec npx ts-node src/index.ts",
    }
  • Run ngrok tunnel on port 8000. Paste https link into Webhook field in SmartApp settings.

    $: ngrok http 8000
  • The whole code can be found inside example directory

๐Ÿ“‹ Docs

https://dialute.vercel.app

๐Ÿฅฐ Support

You can always click on the โญ๏ธ of the repo and donate. I will be very glad for any support

"Buy Me A Coffee"

About

๐Ÿงถ The fastest way to build an app for SberSalute

dialute.vercel.app

Topics

dialuteexpressframeworkjssalutesberdevicests

Resources

Readme
GPL-3.0 license
Activity

Stars

2 stars

Watchers

1 watching

Forks

0 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402775 โ€” GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800ร—600. No cookies required.