Skip to content

Decision Trees

Decision trees are Daktela's built-in chatbot: they guide the customer through predefined questions and answers, can request data from external APIs and can create tickets β€” all before (or instead of) connecting the customer with an agent.

Decision trees are available for web chat, Facebook Messenger, Instagram DM, SMS, Viber and WhatsApp, and are set up separately for each channel.

Warning

Facebook Messenger, Viber and WhatsApp decision trees are currently in Beta stage.

To set up decision trees, go to Settings β†’ Routings β†’ your channel β†’ Decision trees (e.g. Settings β†’ Routings β†’ Web chats β†’ Decision trees). You will see an overview of your decision trees.

You can view a diagram tree of each decision tree by clicking the grey Tree button in the Actions column.

Click the Title of a decision tree to open its details or click Add new to create a new decision tree. The decision tree editor will open.

Warning

When you are done creating or editing a decision tree, click Save to return to the decision tree overview and make sure to click the Apply configuration changes button in the top right corner.

Apply configuration changes button in the top right corner

For web chats, it will take a few minutes for the changes to take effect on your website. If you want to see them immediately, open your website in a new incognito mode window.


The Decision Tree Editor

The decision tree editor will display a diagram of individual decisions. When creating a new decision tree, you will only see the first step, "Welcome message". Click a decision to select it, then click the edit button on the right hand side:

Selecting and editing a decision in the decision tree editor

The decision details will open.

Fill out the decision Title and Description (optional) in the header, then set up your decision. You can use all available objects – we recommend reading through the templating language documentation.

Drag and drop items from the Actions, Groups and Targets into your decision. We recommend entering a description of each item as you add them.

Actions

Action Description
Request Request data from a URL. Fill out the URL address where your data is stored and name the object that will contain the returned data so you can display it in the conversation.
Send message Send a message in the conversation. Enter a default message and any language variations – in web chat, the customer's language is detected based on the language selected in the connector settings; in other channels it is detected automatically.
Save data Store own data for later usage. Enter your data in Value and enter a key that will load the data under Key name. E.g.: Value: 097HNOU93RNidhfsJ77 Key name: accessToken To use your data in a message or a request, simply enter: {{keyname}} in this example: {{accessToken}}
Create ticket Enter the ticket's Title, select a Category and enter a Comment.

Groups

Type Description
Condition Set up conditional actions. First set up your condition parameters, click Done and then drag and drop actions into the fields in the condition.
Loop Walk through array items. If you use action Target, the loop ends.

Targets

Target

  1. Next destination: select if the target is another decision in the tree (Decision) or a final target such as a queue or a time condition (App).

    If you have selected:

    • Decision – choose a target decision from the drop down list or click the blue plus button to add a new decision. Type the new decision name. You can edit the new target decision in the diagram once you save the current one and return to the decision tree editor.
    • App – select the target type (Automessages, Terminate, Decision tree, Queue, Time condition) and the target. The available target types can differ per channel.
  2. Execution: select whether to go to the target as soon as the customer reaches the decision (Immediately) or whether action from the customer's side is necessary (When client chooses it).

    If you have selected When client chooses it, select your Answer type:

    • Button (web chat, WhatsApp and Facebook Messenger): the customer will use buttons to reply to the bot's questions. Enter the button text in the field below.
    • Generated buttons (web chat, WhatsApp and Facebook Messenger): generate buttons from an external source.
    • Pattern: the customer can type their answer. Enter a pattern in backslashes that the customer's answer must fit to trigger this action. E.g. /[0-9]{6}/ will fit if the customer enters at least a six digit number. See Regular expression syntax for more info.
    • Similar: the customer can type their answer. Enter a list of words that will trigger this action separated by commas.

Warning

If you use Similar or Pattern as an answer in your decision, a "Default answer" radio button will appear next to each answer. Select the answer that should be triggered when the customer's answer does not fit any of the patterns or words.

You can set up language variants in all combinations except Decision-Immediately and Decision-When client chooses it-Generated buttons.

Add another target to set up different targets depending on the customer's answer.

Tip

For practical examples of how to use the different decision tree options, see the Decision tree example below.


Decision Tree Example

This example describes a decision tree where a customer can request a holiday quotation or check the status of their previous request and add more information into it. A web chat routing/connector is created with the Name and Email inputs switched to mandatory and the decision tree is set up as the routing's Next destination.

You can try going through the decision tree yourself at https://miktest.daktela.com/demo/DT.html.

An overview of the decision tree:

Overview of the example decision tree with all its decisions

Welcome Message

In the first decision, the customer decides which branch of the decision tree they will go through. They can click on one of the two buttons set up in the targets.

Step Setup
Send message Hi, have you got a holiday booked or do you want to book a new one?
Target Go to decision: New holiday Execution: After client interaction Answer type: Button Answer: New holiday
Target Go to decision: I have a booking Execution: After client interaction Answer type: Button Answer: I have a booking

New Holiday

In this decision, we will save the web chat's interaction and a user's accessToken and use the data to put together a URL request. The interaction title is the customer's name that they enter before starting the chat, so we will take the name from the response and use it in the message. You can find all the available attributes of the interaction object in the API documentation.

Step Setup Comments
Save data Value: {{lastMessage.interaction}} Key name: chatName We are saving {{lastMessage.interaction}}, which is the title of the chat's interaction in Daktela, e.g. web_608144b8b7c1f169851283. We will use the key name chatName to use the interaction later on.
Save data Value: aaa111bbb222 Key name: accessToken We are saving the user's access token. This will make it easier to use it in subsequent requests. You can find the user's access token in Settings β†’ Users β†’ List of users β†’ User details.
Request URL address: https://miktest.daktela.com/api/v6/activitiesWeb/ {{chatName}}.json?accessToken={{accessToken}} Object: interaction_response We are requesting info about the web chat interaction available at api/v6/activitiesWeb/. {{chatName}} and {{accessToken}} will be replaced by the values set up in the previous two steps, so the actual request sent out will look like this: https://miktest.daktela.com/api/v6/activitiesWeb/ web_608144b8b7c1f169851283.json?accessToken=aaa111bbb222 We have named the response received interaction_response. We will use the response in the next step.
Send message OK {{interaction_response.result.title}}, where would you like to go? The title of the interaction is the customer's name that they enter before starting the chat. This way, we can send a personalised message to the customer. The message will be displayed e.g. as OK John, where would you like to go?
Request URL address: https://miktest.daktela.com/api/v6/formFields/destination_option.json?accessToken={{accessToken}} Object: destination_list We are requesting a list of select box options in the custom field "Destination options" available at api/v6/formFields/. These can be set up in Settings β†’ Tickets β†’ Categories β†’ Form. The response contains the destinations that are being offered in this web chat. We have named the response received destination_list. We will use the response in the next step to generate buttons.
Target Go to decision: Create new ticket Execution: After client interaction Answer type: Generated buttons Source: {{destination_list.result.items}} Value / Title:{{item.title}} / {{item.title}} The customer can click a button, selecting their holiday destination. The buttons are generated automatically from the list of select box options received in the previous step. Each destination is an item and you can use its properties. The Value part in Value / Title is what the decision tree will send as the web chat message when the customer clicks the corresponding button. The Title part is the button text. In this case, both these variables are the same and just contain the titles of the destinations: Egypt, Morocco, Tunisia.

Create a New Ticket

In this decision, we will use the customer's destination selection from the previous decision to create a new ticket.

Step Setup Comments
Request URL address: (note that the URL is separated into lines for ease of explanation but should be entered as a whole) https://miktest.daktela.com/api/v6/tickets.json? accessToken={{accessToken}}& title={{interaction_response.result.title}}+–+Holiday+request+in+{{lastMessage.text}}& category=categories_6080569f6fc48365002493& priority=LOW& stage=OPEN& customFields[destination_option]={{lastMessage.text}}& customFields[email]={{interaction_response.result.email}}& comment=Customer:+{{interaction_response.result.title}}+Destination:+ {{lastMessage.text}}.+Contact:+{{interaction_response.result.email}}.& _method=POST Object: new_ticket We are using the POST method (at the end of the request) so we will be creating a new entry in the list of tickets available at api/v6/tickets.json. - The access token is the one saved in the decision New holiday above. - The title of the ticket will be "customer's name" – Holiday request in "selected destination" – both from New holiday above. - To set the ticket category, we are sending the category's unique name (mandatory field). - We are setting the ticket's priority to LOW (mandatory field). - The text of the previous message – the selected destination – will be written into the custom field Destination. - The email address the customer entered, taken from the interaction_response object from the decision New holiday above, will be written into the custom field Email. - A comment will be created, taking data from the interaction_response object from the decision New holiday above, with the text: Customer: "customer's name". Destination: "selected destination". Contact: "customer's email". - Object: we have named the response received new_ticket. We will use it in the next step.
Send message Great choice {{interaction_response.result.title}}! We will get right on it and one of our reps will be in touch soon. Here is the info you need: Ticket number: {{new_ticket.result.name}}. Destination: {{new_ticket.result.customFields.destination_option[0]}}. Stage: {{new_ticket.result.stage}}. Last edit: {{new_ticket.result.edited}}. A message summarises the ticket created in the previous step, giving the customer some of the data received in the new_ticket response.
Target Next destination: Terminate Execution: Immediately The chat is ended as soon as the customer receives the message from the previous step. You could of course connect them with an agent via a queue if they have any questions or use any of the other possible routing options.

I Have a Booking

If the customer selects I have a booking in the very first decision, they will be taken here.

Step Setup Comments
Save data Value: {{lastMessage.interaction}} Key name:chatName We are saving {{lastMessage.interaction}}, which is the title of the chat's interaction in Daktela, e.g. web_608144b8b7c1f169851283. We will use the key name chatName to use the interaction later on.
Save data Value: aaa111bbb222 Key name:accessToken We are saving the user's access token. This will make it easier to use it in subsequent requests. You can find the user's access token in Settings β†’ Users β†’ List of users β†’ User details.
Request URL address: https://miktest.daktela.com/api/v6/activitiesWeb/ {{chatName}}.json?accessToken={{accessToken}} Object: interaction_response We are requesting info about the web chat interaction available at api/v6/activitiesWeb/. {{chatName}} and {{accessToken}} will be replaced by the values set up in the previous two steps, so the actual request sent out will look like this: https://miktest.daktela.com/api/v6/activitiesWeb/ web_608144b8b7c1f169851283.json?accessToken=aaa111bbb222 We have named the response received interaction_response. We will use it in the next step.
Send message Great {{interaction_response.result.title}}, what's your booking number? The title of the interaction is the customer's name that they enter before starting the chat. This way, we can send a personalised message to the customer. The message will be displayed e.g. as OK John, what's your booking number?
Target Go to decision: Ticket Execution: After client interaction Answer type: Pattern Answer: /[0-9]/ If the customer enters a set of numbers, they will be taken to this target. See Regular expression basics for more info on how to enter patterns.
Target Go to decision: invalid Execution: After client interaction Answer type: Pattern Answer: /.$/* If the customer enters anything but numbers, they will be taken to this target. See Regular expression basics for more info on how to enter patterns. They will get a message that the booking number does not exist and be taken to the beginning of the chat.

Ticket

In this decision, we will try to find the ticket that the customer entered in the previous step and return the ticket details in a message if it is found.

Step Setup Comments
Save data Value: {{lastMessage.text}} Key name: ticketName We are saving the ticket number the customer entered in the previous decision and calling it ticketName.
Request URL address: https://miktest.daktela.com/api/v6/tickets/ {{ticketName}}.json?accessToken={{accessToken}} Object name:check_ticket We are requesting info about the ticket available at api/v6/tickets/. {{ticketName}} is the ticket number saved in the previous step. Object: we have named the response received check_ticket. We will use it in the next step.
Condition If {{check_ticket.result}} ISNOTNULL: - Send message 1 - Send message 2 - Target 1 - Target 2 Else: - Send message 3 - Target 3 If the response to the request in the previous step contains data, 2 messages will be sent and 2 targets created. In any other case, a different message will be sent and target created. See below.
Send message 1 Ticket number: {{check_ticket.result.name}}. Destination: {{check_ticket.result.customFields.destination_option[0]}}. Stage: {{check_ticket.result.stage}}. Last edit: {{check_ticket.result.edited}}. Owner: {{check_ticket.result.user.title}}. Additional requests: {{check_ticket.result.customFields.additional_requests[0]}}. If the ticket number is found, the details about the ticket are sent in a message. They are taken from the check_ticket response.
Send message 2 Would you like to add something to your request?
Target 1 Go to decision: Add request Execution: After client interaction Answer type: Button Answer: Yes The customer will go to the next decision.
Target 2 Next target: Terminate Execution: After client interaction Answer type: Button Answer: No The chat will be ended.
Send message 3 Sorry, we don't have that booking number on file. This message will be sent if the ticket number is not found.
Target 3 Go to decision: I have a booking Execution: Immediately The customer will be taken back to the I have a booking decision where they can enter their booking number again.

Add Request

In this decision, the customer can type what they would like to add to their booking.

Step Setup Comments
Send message What would you like to add to your booking?
Target Go to decision: Add to ticket Execution: After client interaction Answer type: Pattern Answer: /.$/* The customer will be taken to the next step after they type their request.

Add to Ticket

In this decision, the customer's additional request will be added to any previous requests.

Step Setup Comments
Request URL address: https://miktest.daktela.com/api/v6/tickets/{{ticketName}}.json? accessToken={{accessToken}}& customFields[additional_requests]= {{check_ticket.result.customFields.additional_requests[0]}}+ {{lastMessage.text}}&_method=PUT Object: update_ticket We are updating the ticket available at api/v6/tickets/ using the PUT method (at the end of the request). We do not want to overwrite any previous data that was saved in the Additional requests custom field. First, we will enter any data that was already there in the check_ticket response in the Ticket decision – {{check_ticket.result.customFields.additional_requests[0]}}. Then we will enter the new additional request from the previous decision – {{lastMessage.text}}. Object: we have named the response received update_ticket. We will use it in the next step.
Send message Ticket number: {{update_ticket.result.name}}. Destination: {{update_ticket.result.customFields.destination_option[0]}}. Additional requests: {{update_ticket.result.customFields.additional_requests[0]}} Stage: {{update_ticket.result.stage}}. Last edit: {{update_ticket.result.edited}}. Owner: {{update_ticket.result.user.title}}. Again, a summary is sent to the customer using the response from the previous line.
Target Next destination: Terminate Execution: Immediately The chat is ended.