Teneo Web Chat

Teneo Web Chat is a chat widget that can be embedded in websites. It has built-in support for various message types like buttons, quick replies, images, audio, videos, and cards, and the powerful JavaScript API allows for easy live chat integration and extendability.

Example of the main chat window

Core features

  • Supports various message types, like cards, images, buttons, quick replies, etc.
  • Lightweight
  • Easy to embed in websites
  • Extendable through a powerful Javascript API
  • Works on all major browsers like Chrome, Edge, Firefox, Internet Explorer 11, Opera, and Safari
  • Works on mobile devices
  • Accessible (WCAG ready)
  • Available in multiple languages, easy to localize
  • Open source, you can find the source code on Github

Setting up Teneo Web Chat

Giving Teneo Web Chat a try

Once you've published your bot, you can interact with it using Teneo Web Chat. On your bots page you will find a list of all solutions for your team. Clicking the Teneo Web Chat button of your published bot opens a new tab with an example page containing Teneo Web Chat. Because the example page does not require a login, you can share it with your colleagues.

Adding Teneo Web Chat to your site

To add the web chat UI to your site, proceed as follows:

Download teneo-web-chat.js

Download the file teneo-web-chat.js from the latest release on Github and add it to your site.

Update pages

Add the following code before the closing tag to each page where you want the web chat window to appear.

<!-- Teneo Web Chat start -->
<div id="teneo-web-chat"></div>
<script src="/path/to/teneo-web-chat.js"></script>
<script>
  window.onload = function () {
    if (
      window.TeneoWebChat &&
        typeof window.TeneoWebChat.initialize === 'function'
    ) {
      var element = document.getElementById('teneo-web-chat');
      const teneoProps = {
        'teneoEngineUrl': 'https://some.teneo/engine-instance/',
      }
      window.TeneoWebChat.initialize(element,teneoProps);
    }
  }
</script>
<!-- Teneo Web Chat end -->

When adding the script to your site, note the following:

  • Make sure /path/to/teneo-web-chat.js is replaced with the correct path.
  • Make sure https://some.teneo/engine-instance/ is updated to match the URL of your engine.

Embedding Teneo Web Chat using an iFrame

An alternative way of adding Teneo Web Chat to your site, is by embedding Teneo Web Chat in an iFrame. That will also enable you to support cross-domain browsing for Teneo Web Chat. You can find a repository with more details and example code here: Teneo Web Chat cross-domain example.

Configuration settings

When initializing Teneo Web Chat, an object containing configuration settings needs to be passed on. In the code above, the object is called teneoProps. The following settings are supported:

Property Type Description
teneoEngineUrl string Mandatory. The URL of the Teneo Engine.
title string Optional. Title shown in the header. If empty or not provided, 'Teneo Web Chat' is used.
titleIconUrl string Optional. URL to a custom icon (with a size of 24x24 pixels). Both 'plain' URL's and data URL's are supported. If empty or not provided, the default icon is used.
showCloseButton boolean Optional. If true, a close button is shown next to the minimize button. When clicked, the chat window is closed, the chat history deleted and the engine session is ended.
closeIconUrl string Optional. URL to a custom close icon (with a size of 32x32 pixels). Both 'plain' URL's and data URL's are supported. If empty or not provided, the default icon is used.
minimizeIconUrl string Optional. URL to a custom minimize icon (with a size of 32x32 pixels). Both 'plain' URL's and data URL's are supported. If empty or not provided, the default icon is used.
launchIconUrl string Optional. URL to a custom launch icon (with a size of 26x26 pixels). Both 'plain' URL's and data URL's are supported. If empty or not provided, the default icon is used.
sendIconUrl string Optional. URL to a custom send icon (with a size of 20x20 pixels). Both 'plain' URL's and data URL's are supported. If empty or not provided, the default icon is used.
botAvatarUrl string Optional. URL to a custom bot avatar (with a size of 34x34 pixels) shown next to messages with author 'bot'. Both 'plain' URL's and data URL's are supported. If empty or not provided, no avatar will be shown.
userAvatarUrl string Optional. URL to a custom user avatar (with a size of 34x34 pixels) shown next to messages with author user. Both 'plain' URL's and data URL's are supported. If empty or not provided, no avatar will be shown.
agentAvatarUrl string Optional. URL to a custom agent avatar (with a size of 34x34 pixels) shown next to messages with author agent. Both 'plain' URL's and data URL's are supported. If empty or not provided, no avatar will be shown.
teneoEngineParams object Optional. Key-value pairs of input parameters that should be included in requests to the Teneo Engine. Both the keys and the values in the map should be strings.
locale string Optional. Locale that should be used for labels and text, like the placeholder text in the input box. If no locale is provided, en is used. Teneo Web Chat is available in following languages:
  • da (Danish)
  • de (German)
  • en (English)
  • en-GB (English UK)
  • es (Spanish)
  • fr (French)
  • id (Indonesian)
  • it (Italian)
  • ja (Japanese)
  • nl (Dutch)
  • pt (Portuguese)
  • sv (Swedish)
  • tr (Turkish)
  • zh-CN (Chinese Simplified)
  • zh-TW (Chinese Traditional)
  • ms (Malaysian)
customLocalizations object Optional. Object containing custom localized strings. See Custom localizations for details.
storage object Optional. Web storage object that should be used to store chat history and session id. If not provided sessionStorage will be used.
showUploadButton boolean Optional. If true, an upload button is shown next to the send button. When clicked, the On upload_button_clicked callback is called.
uploadIconUrl string Optional. URL to a custom upload icon (with a size of 20x20 pixels). Both 'plain' URL's and data URL's are supported. If empty or not provided, the default icon is used.
showAsrButton boolean Optional. If true, an Automatic Speech Recognition button is shown to the right of the input box. When clicked, the On asr_button_clicked callback is called. If no callback is registered for the event, it will use the native functionality tied to a Microsoft Cognitive Services Account. See msCognitiveSubscriptionKey and msCognitiveRegion below.
asrIconUrl string Optional. URL to a custom ASR icon (with a size of 20x20 pixels). Both 'plain' URL's and data URL's are supported. If empty or not provided, the default icon is used.
showTtsButton boolean Optional. If true, an Text To Speech button is shown to the right of the input box. When clicked, the On tts_button_clicked callback is called. If no callback is registered for the event, it will use the native functionality tied to a Microsoft Cognitive Services Account. See msCognitiveSubscriptionKey and msCognitiveRegion below.
ttsIconUrl string Optional. URL to a custom TTS icon (with a size of 20x20 pixels). Both 'plain' URL's and data URL's are supported. If empty or not provided, the default icon is used.
ttsActive boolean Optional. If true, the Text To Speech functionality will be active at the beginning of the session, ensuring the welcome message is read out loud.
msCognitiveSubscriptionKey string Optional. If supplied and there is no registered callback for either the ASR or the TTS button, it will use this subscription key to generate authentication tokens for Microsoft's Cognitive Services. Must be supplied in conjunction with msCognitiveRegion. Bear in mind that most Cognitive services, including Microsoft's require a secure context to work (https).
msCognitiveRegion string Optional. If supplied and there is no registered callback for either the ASR or the TTS button, it will use this region string to use Microsoft's Cognitive Services. Must be supplied in conjunction with msCognitiveSubscriptionKey.
msVoice string Optional. If no value is supplied it will use the default voice for the language as defined be Microsoft's Cognitive Services. For a complete list of available voice, click here. If used, it must be in conjunction with msCognitiveSubscriptionKey and msCognitiveRegion.
autoRedirect boolean Optional. Defaults to true. If true it will trigger automatic navigation to the URL defined in the Output Hyperlink field of an Output Node in Studio. If set to false it will render a Link Preview instead. See the Link Preview message type for more details.

Message types

Teneo Web Chat offers various message types that can be 'attached' to the bot's answer text. This is achieved by adding an output parameter teneowebclient with JSON specific for the message type. For more details on how to populate output parameters, see: Populate output parameters in the 'Build your bot' section.

The following message types are supported:

Image

Example of an image in the converstation

Engine JSON

To add an image, the JSON that should be included in the teneowebclient output parameter looks as follows:

{
    "type": "image",
    "image_url": "https://url.to/an/image.png",
    "thumbnail_url": "https://url.to/a/thumbnail.png",
    "alt": "This is an image"
}

Notes:

  • If only the image_url is present, the image will be shown in the chat history as a thumbnail and the image can be clicked to enlarge it
  • If only the thumbnail_url is present, the thumbnail image will be shown in the chat history but it cannot be clicked to enlarge it
  • If both the image-url and the thumbnail_url are present, the thumbnail_url will be used for the thumbnail in the chat history and when clicked the image_url will be used for the enlarged image

Videos

Example of a youtube video in the conversation

Teneo Web Chat supports the following video platforms:

  • YouTube
  • Vimeo
  • Mp4 videos
Engine JSON

In general, the JSON to add a video looks like this:

{
    "type": "[videotype]",
    "video_url": "[url]"
}

The type and URL differ depending on the platform that is used to host the video.

YouTube video

{
    "type": "youtubevideo",
    "video_url": "https://www.youtube.com/embed/123456789"
}

Note that the URL of a YouTube video should start with https://www.youtube.com/embed/.

Vimeo video

{
    "type": "vimeovideo",
    "video_url": "https://player.vimeo.com/video/12345678"
}

Note that the URL of a Vimeo video should start with https://player.vimeo.com/video/.

mp4 video

{
    "type": "filevideo",
    "video_url": "https://url.to/a/video.mp4"
}

Note that the type is filevideo.

Audio

To display an audio player, the JSON that should be included in the teneowebclient output parameter looks as follows:

{
    "type": "audio",
    "audio_url": "https://url.to/audio.mp3"
}

Buttons

Example of buttons in Teneo Web Chat

The title above the buttons is optional. The style attribute in the JSON detemines the colors of the buttons. When clicked, a 'postback' value is sent to engine as a user input. Only buttons in the most recent message can be clicked.

Engine JSON

The JSON that should be included in the teneowebclient output parameter should look as follows:

{
    "type": "buttons",
    "title": "Optional title",
    "button_items": [
        {
            "style": "primary",
            "title": "Primary",
            "postback": "Primary"
        },
        {
            "style": "secondary",
            "title": "Secondary",
            "postback": "Secondary"
        },
        {
            "style": "success",
            "title": "Success",
            "postback": "Success"
        },
        {
            "style": "danger",
            "title": "Danger",
            "postback": "Danger"
        },
        {
            "style": "warning",
            "title": "Warning",
            "postback": "Warning"
        },
        {
            "style": "info",
            "title": "Info",
            "postback": "Info"
        }
    ]
}

If the 'style' of a button is omitted, the primary color is used.

Input parameters

In addition to the above, buttons can contain input parameters that will be included in the request to engine when the user clicks a button. They are defined as follows:

...
    {
        "style": "primary",
        "title": "Primary",
        "postback": "Primary",
        "parameters": {            "button": "primary"        }
    }
...

In the example above, an input parameter button with value primary will be included in the request to engine when the button is clicked. See How to store input parameters for instructions on how to process input parameters in Studio.

Quick replies

Example of quick replies

Quick replies behave the same as buttons, but are pill-shaped. Quick replies don't have a title. The style attribute in the JSON determines the colors of the quick replies. When clicked, a 'postback' value is sent to engine as a user input. Only quick replies in the most recent message can be clicked.

Engine JSON

The JSON that should be included in the teneowebclient output parameter should look as follows:

{
    "type": "quickreply",
    "quick_replies": [
        {
            "style": "primary",
            "title": "Primary",
            "postback": "Primary"
        },
        {
            "style": "secondary",
            "title": "Secondary",
            "postback": "Secondary"
        },
        {
            "style": "success",
            "title": "Success",
            "postback": "Success"
        },
        {
            "style": "danger",
            "title": "Danger",
            "postback": "Danger"
        },
        {
            "style": "warning",
            "title": "Warning",
            "postback": "Warning"
        },
        {
            "style": "info",
            "title": "Info",
            "postback": "Info"
        }
    ]
}

Notes:

  • If the 'style' of a quick reply is omitted, the primary color is used.
  • Just like buttons, quick replies can contain input parameters.

Clickable list

Clickable list example

The title above the list of clickable items is optional. When clicked, a 'postback' value is sent to engine as a user input. Clickable lists don't have a style attribute (like buttons and quick replies). Only clickable lists in the most recent message can be clicked.

Engine JSON

The JSON that should be included in the teneowebclient output parameter should look as follows:

{
    "type": "clickablelist",
    "title": "Optional title",
    "list_items": [
        {
            "title": "One",
            "postback": "One"
        },
        {
            "title": "Two",
            "postback": "Two"
        },
        {
            "title": "Three",
            "postback": "Three"
        },
        {
            "title": "Four",
            "postback": "Four"
        },
        {
            "title": "Five",
            "postback": "Five"
        },
        {
            "title": "Six",
            "postback": "Six"
        }
    ]
}

Note: Just like buttons, clickable lists can contain input parameters.

Link buttons

The title above the link buttons is optional. When clicked, the URL of the link button is opened in the specified target window. Link buttons don't have a style attribute (like buttons and quick replies). Unlike quick replies, they don't expire, but can be clicked even in older messages. They don't return a postback value to engine, but do trigger the On message button clicked event.

Engine JSON

The JSON that should be included in the teneowebclient output parameter looks as follows:

{
    "type": "linkbuttons",
    "title": "Optional title",
    "linkbutton_items": [
        {
            "title": "Link 1",
            "url": "https://url.to/a/page",
            "target": "_blank"
        },
        {
            "title": "Link 2",
            "url": "https://url.to/another/page",
            "target": "_blank"
        },
        {
            "title": "Link 3",
            "link": "https://url.to/yet/another/page"
        }
    ]
}

Tables

Table

The title above the table, the header row and the footer row are optional. Accepts only text content in the cells, no HTML or additional message templates can be used. The table will expand the number of cells per row to the number of cells in the longest row.

Engine JSON

The JSON that should be included in the teneowebclient output parameter looks as follows:

{
  "type": "table",
  "title": "Table Title",
  "headers": [
    "Header1",
    "Header2",
    "Header3"
  ],
  "body": [
    [
      "Row1 Cell1",
      "Row1 Cell2",
      "Row1 Cell3"
    ],
    [
      "Row2 Cell1",
      "Row2 Cell2",
      "Row2 Cell3",
      "Row2 Cell4"
    ],
    [
      "Row3 Cell1",
      "Row3 Cell2"
    ],
    [
      "Row4 Cell1",
      "Row4 Cell2",
      "Row4 Cell3"
    ],
    [
      "Row5 Cell1",
      "Row5 Cell2",
      "Row5 Cell3"
    ]
  ],
  "footers": [
    "Footer1",
    "Footer2"
  ]
}

Forms

Form

The form message type allows for information to be gathered from the user during a conversation. Almost all elements that are allowed inside an HTML form are permitted in here, with the exception of Fieldsets and Optgroups. To build a form, an array is passed in the elements key of the JSON (example below).

The following table contains all the possible elements types that can be added to a form, the control elements (submit and cancel), and at least one other element are required. All types can have an attributes field that is an object that contains the HTML attributes that will be assigned to the field, applicable examples in the table below. While the form is active the user input field is disabled and cannot be typed into. All fields which have the required attribute will have a * added to the end of their labels.

Once submitted or cancelled, the collected data (or none) will be sent to the Teneo Engine as a JSON, with an additional boolean field named success added to it. From the solution side you can parse the message received and use the success field to determine whether the form was sent or closed.

Type Fields Comments
title
text
String. The content of the form title.
Optional, only 1 per form.
subtitle
text
String. The content of the form subtitle.
Optional, only 1 per form.
caption
text
String. The content of the form caption.
Optional, only 1 per form.
label
text
String. The content of the label.
Optional, no limit.
These labels can be used to convey information to the user that is not tied to a particular input field, for example, to advice that fields marked with * are required.
These labels look the same as the labels defined as companions for other elements (see input entry).
input
label
String. The text for the form label that has the for attribute pointing to the input element. Includes labels that accompany checkboxes and radio buttons.
attributes
Object.These are the attributes that will be added to the HTML tag, type is not required and will default to text if not supplied. Common Attributes:
type
String. The type of input, use only the ones listed, as using other types such as submit can affect the functionality of the form. It can be one of:
  • text - accepts alphanumeric inputs.
  • button - can be clicked (listeners must be attached with an extension, out of the box they are dummy buttons).
  • radio - only one value can be checked.
  • checkbox - several values can be checked.
  • date - provides a datepicker widget, if browser supports it. If not it will default to a text type field.
  • time - provides a timepicker widget, if browser supports it. If not it will default to a text type field.
  • datetime-local - provides both widgets above, if browser supports it. If not it will default to a text type field.
  • color - provides a colorpicker widget, if browser supports it. If not it will default to a text type field.
  • range - a slider from less to more. Min and max values can be defined with attributes.
  • reset - empties all fields that were filled by the user.
required
Boolean (special). Whether the element is required to submit the form. Any value, including _false_ will make the element required, omit completely if not required.
pattern
Regular Expression. This field can be used to validate the content of a field. Only valid for fields with alphanumeric inputs, ie, types text, email, number, password, search, tel, url. {
title
String. This field is used together with pattern to give the user an error message when the pattern is not matched. {
value
Alpahnumeric.Assigns a value to the field. In radios and checkboxes it will correspond to the box when ticked. In alphanumeric fields, date pickers and color pickers it will prepopulate them. In buttons it will provide the text inside the button.
name
String. This field will can be used to group inputs of types radio together. Radio buttons with the same name can only have one input selected.
Optional, no limit.
Inputs are the main elements used in a form, together with select and textarea. How these elements are rendered depends on the browser the user is on.
textarea
text
String. The value to prepopulate the field with.
label
String. The text for the form label that has the for attribute pointing to the textarea element.
Optional, no limit.
Minimal height possible is two line heights.
select
options
Array of Objects. The content of the options in the select. Each object in the array must contain a text field with the words for the dropdown. Additionally, an attributes object can be passed as in the top-level inputs, see example in JSON below.
label
String. The text for the form label that has the for attribute pointing to the select element.
Optional, no limit.
Minimal height possible is two line heights.
control
action
String. One of submit or cancel. Determines whether the control button will submit or cancel the sending of the form.
text
String. The text for inside of the button.
Required. One of each action per form.
Engine JSON

The JSON that should be included in the teneowebclient output parameter looks as follows:

{
  "type": "form",
  "elements": [
    {
      "type": "title",
      "text": "Form Title"
    },
    {
      "type": "subtitle",
      "text": "Form Subtitle"
    },
    {
      "type": "label",
      "text": "This is an additional label to let people know * means required"
    },
    {
      "type": "input",
      "attributes": {
        "type": "",
        "required": true
      },
      "label": "Text Input Required Example"
    },
    {
      "type": "input",
      "attributes": {
        "type": "text",
        "pattern": "[A-Za-z]{3}",
        "required": true,
        "title": "Three Letters Only"
      },
      "label": "Text Input Validation Pattern Example - 3 letters"
    },
    {
      "type": "label",
      "text": "These inputs are extra buttons that do nothing!"
    },
    {
      "type": "input",
      "attributes": {
        "type": "button",
        "value": "Boink"
      }
    },
    {
      "type": "input",
      "attributes": {
        "type": "button",
        "value": "Doink"
      }
    },
    {
      "type": "label",
      "text": "These inputs are radio buttons"
    },
    {
      "type": "input",
      "attributes": {
        "type": "radio",
        "value": "1",
        "name": "radios"
      },
      "label": "one"
    },
    {
      "type": "input",
      "attributes": {
        "type": "radio",
        "value": "2",
        "name": "radios"
      },
      "label": "two"
    },
    {
      "type": "input",
      "attributes": {
        "type": "radio",
        "value": "3",
        "name": "radios"
      },
      "label": "three"
    },
    {
      "type": "input",
      "attributes": {
        "type": "radio",
        "value": "4",
        "name": "radios"
      },
      "label": "four"
    },
    {
      "type": "input",
      "attributes": {
        "type": "radio",
        "value": "5",
        "name": "radios"
      },
      "label": "five"
    },
    {
      "type": "input",
      "attributes": {
        "type": "radio",
        "value": "6",
        "name": "radios"
      },
      "label": "six"
    },
    {
      "type": "label",
      "text": "These inputs are checkboxes"
    },
    {
      "type": "input",
      "attributes": {
        "type": "checkbox",
        "value": "dog"
      },
      "label": "dog"
    },
    {
      "type": "input",
      "attributes": {
        "type": "checkbox",
        "value": "cat"
      },
      "label": "cat"
    },
    {
      "type": "input",
      "attributes": {
        "type": "checkbox",
        "value": "hamster"
      },
      "label": "hamster"
    },
    {
      "type": "input",
      "attributes": {
        "type": "date"
      },
      "label": "This input is a datepicker!"
    },
    {
      "type": "input",
      "attributes": {
        "type": "time"
      },
      "label": "This input is a timepicker!"
    },
    {
      "type": "input",
      "attributes": {
        "type": "datetime-local"
      },
      "label": "This input is a datetimepicker!"
    },
    {
      "type": "input",
      "attributes": {
        "type": "color"
      },
      "label": "This input is a colorpicker!"
    },
    {
      "type": "input",
      "attributes": {
        "type": "range"
      },
      "label": "This input is a range!"
    },
    {
      "type": "input",
      "attributes": {
        "type": "reset",
        "text": "reset"
      },
      "label": "This input is a reset!"
    },
    {
      "type": "textarea",
      "text": "Prepopulated text in textarea.",
      "label": "Text Area Example"
    },
    {
      "type": "select",
      "label": "Example Select",
      "options": [
        {
          "text": "select one below",
          "attributes": {
            "disabled": true
          }
        },
        {
          "text": "1"
        },
        {
          "text": "2"
        },
        {
          "text": "3"
        }
      ]
    },
    {
      "type": "control",
      "text": "Cancel",
      "action": "cancel"
    },
    {
      "type": "control",
      "text": "OK",
      "action": "submit"
    },
    {
      "type": "caption",
      "text": "form caption"
    }
  ]
}

Cards

Card

The main elements of a card are the image, title, subtitle, and body. All elements are optional, but you should include at least one of them. Card images have a fixed height of 180px and look best when they have a ratio of 3x2.

Engine JSON

The JSON that should be included in the teneowebclient output parameter looks as follows:

{
    "type": "card",
    "image": {
        "image_url": "https://url.to/an/image.png",
        "alt": "This is an image"
    },
    "title": "This is the title",
    "subtitle": "This is the subtitle",
    "text": "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt."
}

In addition to the above, cards can contain a section with buttons, link buttons, or a clickable list.

Card with buttons:

{
    "type": "card",
    "image": {
        "image_url": "https://url.to/an/image.png",
        "alt": "This is an image"
    },
    "title": "This is the title",
    "subtitle": "This is the subtitle",
    "text": "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt.",
    "button_items": [
        {
            "style": "primary",
            "title": "Primary",
            "postback": "Primary"
        },
        {
            "style": "secondary",
            "title": "Secondary",
            "postback": "Secondary"
        },
        {
            "style": "success",
            "title": "Success",
            "postback": "Success"
        }
    ]
}

Card with a clickable list

Card with a clickable list

{
    "type": "card",
    "image": {
        "image_url": "https://url.to/an/image.png",
        "alt": "This is an image"
    },
    "title": "This is the title",
    "subtitle": "This is the subtitle",
    "text": "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt.",
    "list_items": [
        {
            "title": "One",
            "postback": "One"
        },
        {
            "title": "Two",
            "postback": "Two"
        },
        {
            "title": "Three",
            "postback": "Three"
        }
    ]
}

Card with link buttons:

Car with link buttons

{
    "type": "card",
    "image": {
        "image_url": "https://url.to/an/image.png",
        "alt": "This is an image"
    },
    "title": "This is the title",
    "subtitle": "This is the subtitle",
    "text": "Lorem ipsum dolor sit amet, consec tetur adipisicing elit.",
    "linkbutton_items": [
        {
            "title": "Card link",
            "url": "https://url.to/a/page"
        },
        {
            "title": "Another link",
            "url": "https://url.to/another/page",
            "target": "_blank"
        }
    ]
}

Previous versions of Teneo Web Chat supported cards with links by providing a list of link_items. These types of links have been deprecated as of version 3.1.0 and will be removed in the next major release of Teneo Web Chat. If your solution uses cards with link_items, please update them to use linkbutton_items instead.

You can group cards into a carousel type message.

Carousel message

The main content elements of a carousel are cards. A carousel can contain up to 10 cards inside of carousel_items.

Engine JSON
{
  "type": "carousel",
  "carousel_items": [
    {
      "type": "card",
      "image": {
        "image_url": "https://as-freaky-styley-714c5e.bots.teneo.ai/teneo_web_chat_tes_3gzgctjx5q84x8fztj2bdzxtrh/images/trees.png",
        "alt": "This is an image"
      },
      "title": "Card 1",
      "text": "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt.",
      "button_items": [
        {
          "title": "One",
          "postback": "One"
        },
        {
          "title": "Two",
          "postback": "Two"
        },
        {
          "title": "Three",
          "postback": "Three"
        }
      ]
    },
    {
      "type": "card",
      "image": {
        "image_url": "https://as-freaky-styley-714c5e.bots.teneo.ai/teneo_web_chat_tes_3gzgctjx5q84x8fztj2bdzxtrh/images/trees.png",
        "alt": "This is an image"
      },
      "title": "Card 2",
      "text": "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt.",
      "list_items": [
        {
          "title": "One",
          "postback": "One"
        },
        {
          "title": "Two",
          "postback": "Two"
        }
      ]
    },
    {
      "type": "card",
      "image": {
        "image_url": "https://as-freaky-styley-714c5e.bots.teneo.ai/teneo_web_chat_tes_3gzgctjx5q84x8fztj2bdzxtrh/images/trees.png",
        "alt": "Trees in a forrest"
      },
      "title": "LinkButton Card",
      "text": "This is the text of the card.",
      "linkbutton_items": [
        {
          "title": "Studio",
          "url": "https://developers.artificial-solutions.com/studio",
          "target": "_blank"
        },
        {
          "title": "Engine",
          "url": "https://developers.artificial-solutions.com/engine",
          "target": "_blank"
        }
      ]
    }
  ]
}

Modal messages appear on top of the chat window and block the user from interacting with the chat window until the modal is dismissed.

Modal message

The main content elements of a modal are an image, a title, and a body. All elements are optional, but you should include at least one of them. Additionally, a modal can contain buttons. Modal images have a maximum height of 100px.

Engine JSON
{ 
    "type": "modal", 
    "image": { 
        "image_url": "https://url.to/an/image.png",
        "alt": "This is an image"
    }, 
    "title": "This is the title", 
    "text": "Lorem ipsum dolor sit amet, consectetur adipisicing elit.", 
    "button_items": [
        { 
            "style": "secondary", 
            "title": "Secondary", 
            "postback": "modal-secondary" 
        }, 
        { 
            "style": "danger", 
            "title": "Danger", 
            "postback": "modal-danger" 
        }
    ] 
}

Link Previews can be used to display a little bit of information to the user about the page they are about to visit. This includes the page title, description, domain, and an image. Due to space limitations, descriptions are limited to 144 characters, but the full text will be made available as a tooltip.

Link Preview message

Link Preview messages can be either generated manually using the JSON below, or they can be rendered automatically by giving the autoRedirect setting a false value. If you don't override the setting, it will default to true, and all links in the Output Hyperlink field of the Output nodes in Studio will automatically redirect the user to the URL defined there.

The data in the Link Preview is gathered from the meta tags of the target page. Due to CORS restrictions, the data from these tags has to be requested from the server side. In order to do so, please include this Groovy script in the Resources -> File area of Studio. Make sure to set the path to /script_lib.

previewproperties

Then under Globals -> Scripts -> Post-processing add the following line of code:

if( _.outputURL){ _.outputURL= PreviewProperties.get( _.outputURL)}

postprocessing

In some cases, the target page doesn't have the necessary meta tags, in which case a localized message is displayed in place of the title or the description. You can learn how to modify this message in the Custom localizations page.

Engine JSON
{
  "type": "linkpreview",
  "title": "Link title",
  "description": "Short text for the preview",
  "url": "https://example.com",
  "image": "https://url.to/an/image.png"
}

System message

System message

Engine JSON
{
    "type": "system",
    "text": "This is a system message."
}

Combo message

You can combine multiple message types in a single bot response by using a 'combo' message.

Combo message showing a card, a text message and buttons

The following message types can be included in a combo message:

  • Buttons
  • Cards
  • Clickable lists
  • Images
  • Link buttons
  • Quick replies
  • Text messages
  • Videos
  • Audio players

You can include as many of these messages as you need in the order you like. Obviously one should take into account that the height of the chat window is limited; when too many messages are added, some of them may scroll out of view.

Engine JSON

The JSON used to create the combo message in the screenshot looks as follows:

{
    "type": "combo",
    "components": [
        {
            "type": "card",
            "image": {
                "image_url": "https://url.to/an/image.png",
                "alt": "This is an image"
            },
            "title": "This is the title",
            "subtitle": "This is the subtitle",
            "text": "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt."
        },
        {
            "type": "text",
            "text": "This is an additional speech bubble shown below the card."
        },
        {
            "type": "buttons",
            "title": "Are you sure?",
            "button_items": [
                {
                    "style": "danger",
                    "title": "Yes",
                    "postback": "Yes"
                },
                {
                    "style": "success",
                    "title": "No",
                    "postback": "No"
                }
            ]
        }
    ]
}

Splitting answers into 'bubbles'

Sometimes you may wish to provide an answer using multiple text bubbles.

Example of multiple answer text bubbles

This can be achieved by including an output parameter called outputTextSegmentIndexes. This output parameter should contain a list of index pairs, to indicate where the output text can be split into separate bubbles. The value of the outputTextSegmentIndexes should be structured like this (linebreaks are added for readability):

[
    [startIndexOfFirstBubble,endIndexOfFirstBubble],
    [startIndexOfSecondBubble,endIndexOfSecondBubble],
    ...
]

For the screenshot above, the following values were used:

Output Text outputTextSegmentIndexes Bubbles
This should appear in the first bubble. This appears in the middle. And this in the last bubble. [[0, 41], [41, 72], [72, 100]] This should appear in the first bubble.
This appears in the middle.
And this in the last bubble.

Post-processing script

There are different ways to generate the value of outputTextSegmentIndexes. The Groovy script below is a global post-processing script that looks for two consecutive pipe symbols || in an output text, uses those to generate the value for outputTextSegmentIndexes, removes the pipe symbols from the answer text, and adds the outputTextSegmentIndexes output parameter.

def outputTextSegmentIndexes = []
def outputTextSegments = _.getOutputText().split(/\|\|/)
if (outputTextSegments.size() > 1) {
    def startIndex = 0
    def cleanedOutputText = ""

    outputTextSegments.each { textSegment ->
        def endIndex = startIndex + textSegment.size()
        if (textSegment) {
                outputTextSegmentIndexes << [startIndex, endIndex]
        }
        startIndex = endIndex
        cleanedOutputText += textSegment
    }
    _.setOutputText(cleanedOutputText)
}

if (outputTextSegmentIndexes) {
    _.putOutputParameter("outputTextSegmentIndexes", "${outputTextSegmentIndexes}")
}

To use the script, proceed as follows:

  1. Copy the script above.
  2. In Teneo Studio, open the 'SOLUTION' tab in the solution's window (if you're not there already).
  3. Select 'Globals' in the purple bar on the left hand side, and then select 'Scripts'.
  4. Select 'Post-processing' and choose 'Edit'.
  5. Paste the script above.
  6. Click 'Save'.

Once added, whenever you add || to an answer text in Teneo Studio, the script will add the output parameter 'outputTextSegmentIndexes' with the proper index values and Teneo Web Chat will divide the text into multiple bubbles.

Note that this script works for both Teneo Web Chat and Microsoft Bot Framework. If this script was already added to post processing, you don't need to add it again.

Javascript API

The functionality provided by Teneo Web Chat can be extended and modified using the Teneo Web Chat JavaScript API. This API allows developers to create extensions that can trigger events in the Teneo Web Chat widget, or subscribe to events that may occur in the chat widget. This lets developers change or extend its behavior in ways that are not provided by the standard configuration.

Extensions can be created using standard JavaScript, without needing to modify the source code of Teneo Web Chat. Full specification of the API can be found here: Teneo Web Chat JavaScript API.

Engine input parameters

Channel

In addition to the input entered by the user, requests to the Teneo Engine also contain an input parameter channel with value teneo-webchat. This allows you to change the behavior of your bot, depending on the channel used. For information on how to retrieve the value of an input parameter in Teneo Studio, see Store input parameters in the 'Build your bot' section.

Extra parameters

An optional map of parameters can be included when Teneo Web Chat is initialized. The keys in this map (and their values) will be included as individual input parameters in all requests to the Teneo Engine.

Cross-Origin Resource Sharing (CORS)

In many cases, the website that is hosting the web chat UI uses a different domain than the domain used by the Teneo Engine. Cross-Origin Resource Sharing (CORS) is a mechanism that uses additional HTTP headers to tell a browser to let a web application running at one origin (domain) have permission to access selected resources from a server at a different origin.

By default the Teneo Engine includes CORS headers in the responses to browser requests coming from any domain. This means any site can add the web chat UI and interact with a Teneo Engine. If you want to restrict your solution to only include CORS headers for specific domains, you can add a file called tieapi_cors_origins.txt to the Teneo Resource Manager in the views folder. The file should contain the list of allowed origin domains (one domain per line: domains should include port numbers if applicable).

Was this page helpful?