📃
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
  • Use formats
  • Quick response
  • Carousel
  • Display an image
  • Send text with buttons
  • Webview
  • Show a video
  • Send a contact

Was this helpful?

  1. ConverseScript Syntax
  2. The decorators

Use @Format

Use formats

Quick response

Show quick answers like this:

@Event('start')
start() {
    @Format('quickReplies', ['yes', 'no'])
    > Continue ?
    Prompt()
    > Ok !
}

Carousel

Here's how to display a carousel:

@Event('start')
start() {
    @Format('carousel', [
        {
            title: 'TITLE',
            subtitle: 'SUBTITLE',
            image: 'URL_IMAGE',
            buttons: [
                {
                    url: 'URL',
                    title: 'TITLE BUTTON'
                }
            ]
        }
    ])
    > Continue ?
}

Display an image

@Event('start')
start() {
    @Format('image', 'http://url.com/image.png')
    > Nice picture !
}

Send text with buttons

@Event('start')
start() {
    @Format('buttons', [
        {
            title: 'An url',
            url: 'https://google.fr'
        },
        {
            type: 'postback',
            title: 'Postback'
        }
    ])
    > Buttons
}

Webview

  1. Create an webviews folder at the root of the project

  2. Put an HTML file (eg webviews/map.html)

@Event('start')
start() {
    @Format('webview', {
        url: '/webview/map.html', // required
        button: 'View map', // for other platforms,
        fbHeight: 'full', // compact, tall or full (only for Messenger)
        height: 600 // in pixels, only for chatbox
    })
    > Ok, here is the webview
}

Share button

On Facebook Messenger, NewBot ChatBox and Twitter, we can share content with the following code

@Event('start')
start() {
    @Format('buttons', [
        {
           type: 'share'
        }
    ])
    > Buttons
}

On Twitter

On Twitter, let's add the tweet property:

@Event('start')
start() {
    @Format('buttons', [
        {
           type: 'share',
           tweet: {
               text: 'Partagez-moi',
               url: 'https://newbot.io'
               via: '@me',
               hashtags: ['one', 'two']
           }
       }
    ])
    > Share
}
  • tweet.text (required): Text in the tweet

  • tweet.url (optional): Url to share

  • tweet.via (optional): User Profile to Share

  • tweet.hashtags (optional): Embed Hashtags

Show a video

@Event('start')
start() {
    @Format('video', 'http://url.com/video.mp4')
    > Nice video !
}

Send a contact

@Event('start')
start() {
    @Format('contact', '0123456789', 'Sam R')
    > Here is my friend !
}
PreviousUse @ActionNextUse @Intent

Last updated 3 years ago

Was this helpful?