📃
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

Was this helpful?

  1. Pre-built function for the widget

Map()

Allows you to transform the elements of an array

Example:

array = [{ name: 'ana', age: 18 }, { name: 'ben': age: 20 }]
newArray = Map(array, {
    title: '@name'
}) 
// output is [{ title: 'ana' }, { title: 'ben' }]

Give the name of the property to be read starting with an @

If you have text after the property, put an @ at the end

Example:

array = [{ name: 'ana', age: 18 }, { name: 'ben': age: 20 }]
newArray = Map(array, {
    title: 'Name is @name@ and age is @age'
}) 

Of course, you can read the properties in depth:

array = [{ address: { city: 'paris', street: 'gambetta' } }]
newArray = Map(array, {
    title: '@address.city'
}) 
PreviousRequest()Next_ (lodash)

Last updated 3 years ago

Was this helpful?