Skip to main content
Skip table of contents

How to Create Your First Scripted Chatbot?

Introduction

This guide provides a comprehensive overview of creating and enhancing a Scripted Chatbot using the CM.com platform. By following this documentation, you will learn how to set up a basic chatbot, incorporate advanced features, and integrate web requests to create a fully functional chatbot tailored to your needs.

Part 1: Creating Your First Scripted Chatbot

Overview

A Scripted Chatbot is composed of blocks, each with its own unique functionality. These blocks can be dragged into the canvas to create your desired chatbot flow.

Step-by-Step Instructions

1. Entry Block

  • The Entry Block determines which words or phrases will trigger the chatbot flow.

  • You can configure the following match types:

    • Exact Match: Triggers only when the input matches exactly.

    • Regex Match: Triggers when the input contains a specific pattern (e.g., "hey" matches "hey there").

    • Match All Input: Triggers on any input.

  • Important: If using multiple scripts, ensure the match input script has a lower priority. Do not use both regex and exact matches simultaneously, as this will prevent the chatbot from triggering.

2. Text Block

  • Use the Text Block to send text messages to users.

  • Add text and emojis using the panel on the right.

3. Input Block

  • The Input Block stores user input and assigns it to a variable for later use.

  • Example:

    • Ask for the user's first name.

    • Drag an input block below a text block and set a variable (e.g., firstName).

    • Use the variable in subsequent text blocks by enclosing it in curly brackets (e.g., {{firstName}}).

  • Timeout Flow: Configure a timeout (e.g., 60 seconds). If the user does not respond within this time, the chatbot will activate a timeout flow.

4. Media Block

  • Add media (e.g., images, videos) by hosting the files on a URL and pasting the link into the block.

  • Ensure all media is hosted on a valid URL.

5. Location Block

  • Share locations via WhatsApp using the Location Block.

  • Input coordinates, which can be retrieved from Google Maps.

6. Wait Block

  • Add a Wait Block to mimic natural conversation pauses, giving users time to read messages.

7. Terminate Block

  • The Terminate Block defines the end of the chatbot session and resets the chatbot.

  • After termination, the user's next message will trigger a new flow.

Video

Please watch the instructional video on how to create your first Scripted Chatbot below.

https://vimeo.com/1035240859/68845c5a2a

Part 2: Adding Advanced Features to Your Scripted Chatbot

Overview

Advanced blocks allow you to add logic, interactivity, and dynamic flows to your chatbot. These features enhance the user experience and provide more tailored responses.

Step-by-Step Instructions

1. Logic Block

  • The Logic Block adds decision-making capabilities to your chatbot based on variables.

  • Example:

    • Ask the user for their preferred language (e.g., English or Dutch).

    • Use the Input Block to capture the language and assign it to a variable (e.g., language).

    • Add a Logic Block to check if the variable matches specific values (e.g., language = Dutch).

    • Create separate flows for each language.

2. Reply Buttons and List Pickers

  • Reply Buttons and List Pickers are interactive elements available on WhatsApp.

  • Reply Buttons:

    • Add up to three buttons for users to select from.

    • Configure the header (up to 20 characters) and body content.

    • Link each button to a specific flow.

  • List Pickers:

    • Add up to 11 options in a list format.

    • Include a mandatory button title.

  • Note: These features are not available on Instagram or Facebook Messenger. For these channels, use input and logic steps instead.

3. Position Block

  • The Position Block moves users to a designated point in the flow when activated.

  • This is useful for reusing parts of the flow or redirecting users based on specific conditions.=

Video

Below you can find an instructional video on how to add advanced features to your first Scripted Chatbot.

https://vimeo.com/1036292310/0b87b413c2

Part 3: Integrating Web Requests into Your Scripted Chatbot

Overview

Web requests allow your chatbot to interact with external systems, such as retrieving order statuses, sending data to third-party systems, or communicating with a customer data platform (CDP).

Step-by-Step Instructions

1. Web Request Block

  • Drag the Web Request Block into your chatbot flow.

  • Configure the following settings:

    • Method: Specify the type of API call (e.g., POST or GET).

    • URL: Enter the API endpoint. You can personalize the URL by including variables in double curly brackets (e.g., {{orderID}}).

    • JSON Body: Include the request payload. Use variables for dynamic content.

    • Headers and Query Parameters: Add any required headers or query parameters.

    • Fail Flow: Define a fallback flow in case the API call fails.

2. Response Handling

  • Retrieve data from the API response by specifying:

    • Variable Name: Where the response data will be stored.

    • Selector Field: The field in the response body to extract (e.g., status).

3. CDP Event Block

  • The CDP Event Block is used to send data to the Customer Data Platform.

  • Configure the following:

    • Tenant ID and Event Type ID: Provided by http://CM.com .

    • JSON Body: Include variables formatted in double curly brackets.

  • Note: Setting up CDP integration requires assistance from http://CM.com . Contact your representative for support.

Video

Watch the video below on Integrating Web Requests.

https://vimeo.com/1036324290/ace4d364c6

Part 4: Managing and Reusing Chatbot Scripts

Duplicating a Scripted Chatbot

  • You can duplicate a chatbot by copying its YAML code:

    1. Navigate to the YAML editor (icon in the top-right corner).

    2. Select and copy the entire YAML code.

    3. Create a new script and paste the YAML code to duplicate the flow.

Conclusion

You now have a complete understanding of how to create, enhance, and integrate advanced features into your Scripted Chatbot. From basic blocks to advanced logic and web requests, this guide equips you with the tools to build a powerful chatbot tailored to your needs.

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.