Leopard Chat Client
  • Quick Start
  • Screenshots
  • Setup
    • Extension Helper
    • Context Variables
      • Greeting Message
      • Channel
      • User's Time Zone
      • Location Context Parameters
    • Build Variables
  • Content Styling
    • CSS Styles
    • Icons
    • Markdown & HTML
  • Components Simple Syntax
  • Components
    • Answer Borders
    • Audio Player
    • Auto Open Leopard with Link
    • Alerts
    • Buttons and Lists
    • Card
    • Response Icons
    • Date & Time Pickers
    • Emergency Button
    • Expensive Operations
    • Field Masks
    • Chat Field Types (Email, Password, Location, Upload)
    • Forms
      • Feedback Form
      • Custom Forms
        • Example Config
        • Postback Object
        • Button Object
        • Field Types
        • Style Object
        • Icons Object
        • Masks
        • Validation
    • Google Map
    • Help Text
    • HTML Modal
    • Hyperlinks
    • Images
      • Image
      • Image Carousel
    • Tables
      • Tables - Simple
      • Tables - Advanced
    • Theme Change
    • Toasts
    • Language Auto Switch
    • Minimize Chat after Delay
    • Multiple Components - Same Response
    • Modal Size & Positioning
    • Open Long Response in Modal
    • Print Icon
    • Prompt Trigger Polling
    • Splitting Answers - Chunks
    • Video Player
  • Administration Area
    • Solution Configuration
    • Demo Mode - iFrames & URLs
    • ASR and TTS
  • Integrations
    • Logging / Reporting
    • Social Authentication
    • Live Chat
  • Embedding / Production
Powered by GitBook
On this page
  • JSON FormData Postback
  • JSON Configuration for Postback Object
  1. Components
  2. Forms
  3. Custom Forms

Postback Object

In a custom form you can control what is posted back to Teneo when the form is successfully validated and submitted.

The data for the form fields is always posted back to Teneo as a URL encoded JSON string. It's value is assigned to a configurable request parameter but the default parameter name is "formData".

To capture the formData in Teneo you must validate that the request parameter exists on an inbound request and if so you should URL decode it's value and then attempt to parse it as JSON.

You can use the following code to retrieve the form data in Teneo:

import groovy.json.JsonSlurper

def formData = engineEnvironment.getParameter("formData"); 
if (formData) { 
    def jsonSlurper = new JsonSlurper()
    formData = jsonSlurper.parseText(URLDecoder.decode(formData))
}
println(formData.someField)

JSON FormData Postback

This will show you an example of the format of the JSON that is returned in formData for each of the available fields.

URLDecoder.decode(formData)

Property

Field

ageRange

Radio

userName

Input Field

bio

Text Area

favoriteRugbyTeam

Select

newsLetter

Switch

musicVolume

Slider

musicRangeVolume

Range Slider

agreedToTerms

Checkbox

skills

Combo Box

{
  "ageRange"          : "18to25",
  "username"          : "jolzee",
  "bio"               : "Bacon ipsum dolor amet rump ham hock sirloin doner fatback beef kielbasa picanha leberkas sausage buffalo capicola. Shoulder tail pancetta tenderloin. ",
  "favoriteRugbyTeam" : "South Africa",
  "newsLetter"        : true,
  "musicVolume"       : 50,
  "musicRangeVolume"  : [ 20, 80 ],
  "agreedToTerms"     : true,
  "skills"            : [ "java" ]
}

JSON Configuration for Postback Object

Property

Required/Optional

Default Value

Type

Notes

formDataUrlParam

optional

formData

String

The form data captured is put into a JSON object, URL encoded and added as a value to a request parameter with this name

userInput

optional

<empty>

String

Some text to enter into the chat after the user clicks submit. This text will be send back to Teneo as user input

confirmationAlert

optional

<empty>

String

If a value is entered then the user will see and information alert in the chat window with the configured message. No alert is shown by default.

{
  "formDataUrlParam"  : "formData",
  "userInput"         : "Thanks, I've completed the form",
  "confirmationAlert" : "Thanks we have received your form"
}
PreviousExample ConfigNextButton Object

Last updated 5 years ago

"postback": {}

See usage here
Confirmation Alert