📃
NewBot
  • NewBot, what is it?
  • ConverseScript Syntax
    • Variables
    • Arithmetic
    • Boolean
    • Array and object
    • Entering text and output
    • Magic variables
    • Condition
    • Loop
    • Functions
    • The decorators
      • Use @Condition
      • Use @Action
      • Use @Format
      • Use @Intent
      • Use @Event
  • Prebuilt Formats for Widget
    • Quick Replies
    • Multi Cards
    • Articles
    • Form
  • Pre-built function for the widget
    • Request()
    • Map()
    • _ (lodash)
  • Get Started with Framework
    • Install
    • Main Skill
    • Write the conversational script
  • Use NewBot Framework JS
    • Create a skill (more details)
      • Relationship between skills
      • Use the functions of a child competency
      • Conditional
      • Control access to a skill
    • Create a JavaScript function and trigger it in ConverseScript
    • The constants
    • Write formats
      • Write and use multi-formats
      • Share formats
    • Internationalization (i18n)
    • Set up an NLP system
      • Share the NLP system
      • Use DialogFlow
    • Deploy on the browser
    • Run the chatbot on NodeJS
    • Send data when running the chatbot
    • The middlewares
    • Save the user's progress
    • User object
  • Unit Tests
    • Test a scenario
    • Test variables
    • Spy a function
    • Create a mock
    • Test the events
    • Test the actions
Powered by GitBook
On this page
  • while
  • for ... of

Was this helpful?

  1. ConverseScript Syntax

Loop

while

The writing of a loop is as follows:

@Event('start')
start() {
    nb = 0
    while (nb < 10) {
        > Total : { nb }
        > Give me a number
        Prompt()
        nb += :text
    }
    > Total : { nb }
    > Finish !
}

The scenario will be as follows:

  • [Chatbot] Total: 0

  • [Chatbot] Give me a number

  • [User] 3

  • [Chatbot] Total: 3

  • [Chatbot] Give me a number

  • [User] 4

  • [Chatbot] Total: 7

  • [Chatbot] Give me a number

  • [User] 6

  • [Chatbot] Total: 13

  • [Chatbot] Finish!

for ... of

The for ... of loop allows you to browse a table:

@Event('start')
start() {
    names = ['sam', 'jim']
    for (name of names) {
        > { name }
    }
}

It also works with a string, a number, and an object:

@Event('start')
start() {

    a = 2
    b = 'hey'
    c = { name: 'sam', age: 18 }

    /*
        Result : 0, 1, 2
    */
    for (nb of a) {
        > { nb }
    }

    /*
        Result : 'h', 'e', 'y'
    */
    for (letter of b) {
        > { letter }
    }

    /*
        Result : 'sam', 18
    */
    for (data of c) {
        > { data }
    }
}
PreviousConditionNextFunctions

Last updated 3 years ago

Was this helpful?