We use cookies for functional and analytical purposes. Please refer to our Privacy Policy for details.
NEW Try Zapier integration to connect Dasha instantly to thousands of the most popular apps!
Skyrocket your shopping cart conversion rate with a simple conversational AI app
Anzhelika Minina, Citizen Developer
7 minute read
Today we’ll be taking a look at how to create a conversational AI app that calls customers who’ve added an item to the cart but haven’t checked out. This app will be most applicable to online tech stores. Yet by following the logic of this demo, you can easily adjust the conversational flow to fit your business.
Set up your conversational AI workplace
You will need VSCode (Visual Studio Code), NPM, and Node.js, all the latest versions. As the next step, join Dasha developer community so that you can get your API key and be able to get assistance from our developers every step of the way.
To ease your coding process, you’ll need to download the Dasha Studio extension right from the VSCode extensions tab.
Once done, download Dasha Blank Slate App, open the folder in VSCode, and install Dasha CLI (command line interface by typing npm i -g "@dasha.ai/cli" in the VSCode terminal. For more on Dasha CLI usage, refer to this post.
Once done with setting everything up you can move on to the coding part itself.
Get to know what you’ll use to create a cart checkout conversational AI app
There are 3 files you’ll be using: main.dsl, data.json, and index.js. Let’s take a quick look at the functions of these three.
Main.dsl - this is where you’ll write your DashaScript Language code to create the workflow of your conversational AI app. With Dasha Studio extension on and with the directions in this post, it’ll be an easy job for you.
Data.json - this is where you set the intents and entities(AKA NER, AKA Named Entity Recognition). The neural network will use intents and entities you’ll create to learn.
Index.js - it’s the NodeJS file that launches the Dasha SDK. Here you’ll be adding any external functions you deem necessary once adapting the code to your hotel’s needs.
Build your conversational AI app
The most important point to mention is that this app relies heavily on the intents and entities we set in the data.json file. Wherever you see #messageHasIntent(“name of intent”) is what triggers the intent from the data.json file, intents section.
When you open the data.json file, you see the following:
1
{
2
"version": "v2",
3
"intents": {
4
"yes": {
5
"includes": [
6
"yes",
7
"correct",
8
"sure",
9
"absolutely",
10
"yes siree bob",
11
"right",
12
"yep",
13
"you got it",
14
"I would",
15
"yeah",
16
"I would",
17
"I'd like that",
18
"I wouldn't mind",
19
"I would not mind",
20
"sure thing",
21
"yeah",
22
"yea",
23
"certainly",
24
"absolutely",
25
"totally",
26
"mhm"
27
],
28
"excludes": [
29
"fuck off"
30
]
31
},
32
"no": {
33
"includes": [
34
"no",
35
"definitely not",
36
"wrong",
37
"incorrect",
38
"I do not",
39
"I don't",
40
"I would not",
41
"I wouldn't",
42
"nope",
43
"no, I'm okay",
44
"not right now",
45
"not this time",
46
"nah",
47
"not this moment",
48
"not now"
49
],
50
"excludes": [
51
"yes"
52
]
53
},
54
"price_too_high": {
55
"includes": [
56
"cost too much",
57
"price was too high",
58
"the price was too high",
59
"way too high of a price",
60
"cost was too high",
61
"price was too much",
62
"pay that much",
63
"pay so much",
64
"too expensive",
65
"expensive",
66
"price was a deal breaker",
67
"cost too much",
68
"cost way too much",
69
"costs a lot",
70
"couldn't afford",
71
"couldn't afford at this price"
72
]
73
},
74
"free_delivery_sounds_good": {
75
"includes": [
76
"free delivery sounds good",
77
"free delivery sounds lovely",
78
"free delivery sounds fantastic",
79
"free delivery sounds awesome",
80
"free delivery sounds great",
81
"love free delivery",
82
"wouldn't mind a free delivery",
83
"like not having to pay for the delivery",
84
"love not having to pay for the delivery"
85
]
86
},
87
"found_it_elsewhere": {
88
"includes": [
89
"found it elsewhere",
90
"found another place",
91
"found a better place",
92
"found a new place",
93
"found another website",
94
"found a new website",
95
"found a better site",
96
"found a better company",
97
"found it at another company",
98
"founding it at another website"
99
]
100
},
The list of intents goes on and on. You write the intents down yourself based on what you think the user might say or what they have historically said in similar situations.
Entities come into play when you write down #messageHasData(“entity name”) (or #messageGetData(“entity name”). Here’s an example:
1
"entities": {
2
"laptop_model": {
3
"open_set": true,
4
"values": [
5
{
6
"value": "A11",
7
"synonyms": [
8
"A 11",
9
"A eleven",
10
"the A 11 model",
11
"A11 model",
12
"model A11",
13
"2011 model",
14
"year two thousand eleven model"
15
]
16
},
17
{
18
"value": "A12",
19
"synonyms": [
20
"A 12",
21
"A twelve",
22
"A twelve model",
23
"model from two thousand twelve",
24
"the 2012 model",
25
"year 2012 model"
26
]
27
},
28
{
29
"value": "A13",
30
"synonyms": [
31
"A 13",
32
"A thirteen",
33
"A thirteen model",
34
"model from two thousand thirteen",
35
"the 2013 model",
36
"year 2013 model"
37
]
38
},
39
{
40
"value": "A14",
41
"synonyms": [
42
"A 14",
43
"A fourteen",
44
"A fourteen model",
45
"model from two thousand fourteen",
46
"the 2014 model",
47
"year 2014 model"
48
]
49
},
50
{
51
"value": "A15",
52
"synonyms": [
53
"A 15",
54
"A fifteen",
55
"A fifteen model",
56
"model from two thousand fifteen",
57
"two thousand fifteen model",
58
"the 2015 model",
59
"year 2015 model"
60
]
61
}
62
],
63
"includes": [
64
"I'm looking for the (A 14)[laptop_model] model",
65
"I'd like an (A twenty)[laptop_model] model",
66
"I want to get an (A seventeen)[laptop_model] laptop model",
67
"buy the (two thousand fifteen model)[laptop_model]"
68
]
69
}
70
}
71
}
At this point, go to the main.dsl file and delete everything from there. Then, just follow the instructions to create the cart checkout AI app!
Now that you have your main.dsl file empty, it’s time to take a step forward and import the common libraries. Then, set your variables. In this case, we’ll have one input variable, which is the user’s phone number.
Right after that write a start node named root. It’s where you’ll establish a connection with the user’s phone, say the welcome message, and go from there.
After you’ve written out the start node, we can move forward with the nodes and digressions that can appear throughout the conversation with the user. At this point, we want to make sure the user has enough time to talk about their cart checkout. If the call was made at a convenient time and the user lets us know so, we transition to node how_can_i_assist. If Dasha called at an inconvenient time, the conversation will move to the node bye where we thank the user for the time and end the call.
1
// Import the commonReactions library so that you don't have to worry about coding the pre-programmed replies
2
import"commonReactions/all.dsl";
3
context
4
{
5
// Declare the input variable - phone. It's your hotel room phone number and it will be used at the start of the conversation.
6
inputphone: string;
7
// Storage variables. You'll be referring to them across the code.
8
new_model: string="";
9
}
10
// A start node that always has to be written out. Here we declare actions to be performed in the node.
11
startnoderoot
12
{
13
do
14
{
15
#connectSafe($phone); // Establishing a safe connection to the user's phone.
16
#waitForSpeech(1000); // Waiting for 1 second to say the welcome message or to let the user say something
17
#sayText("Hi, this is Dasha with JJC Group. I see you have the latest model of the Pear laptop in your cart and haven't completed the order on our website. Is it a good time to talk?"); // Welcome message
18
wait *; // Wating for the user to reply
19
}
20
transitions// Giving directions to which nodes the conversation will go to
#sayText("Wonderful! This won't take too long. I was just wondering if you have any concerns regarding the purchase of the laptop that's in your cart?");
31
wait*;
32
}
33
transitions
34
{
35
}
36
}
37
nodebye
38
{
39
do
40
{
41
#sayText("Thanks for your time. We're looking forward to you shopping with us! Have a great day. Bye!");
42
exit;
43
}
44
}
If the user decides to continue the conversation regarding their cart checkout, we need to consider the possible reasons why the user hasn’t checked out in the first place. For the purpose of this demo, let’s consider the following reasons:
the price of the wanted item might have been too high;
the item was found elsewhere, where the price/delivery/etc was more appealing;
the user decided he needed to get some other item instead;
they decided to get a different model of the item;
the user might not have had enough money to complete the purchase for various reasons (waiting for a paycheck, not enough money in the bank account, etc);
the delivery price was too high;
the company doesn’t ship to their country;
they might have been simply browsing your website, considering their options.
These are just a few reasons. However, when you adjust this code to your business’s needs, you should thoroughly think about all the possible reasons for your user not going through the funnel till the very end.
Now, let’s take a look at each of these in detail and write down the ways to change the user’s mind and help him decide to go complete the cart checkout process.
Say the user found the price to be too high, in this case scenario we could offer them a discount on the current or the next purchase. If they don’t accept this offer, we can program the conversation to go to the node where we ask if they have any other issues or concerns. If they do accept it, we go to the node complete_purchase.
#sayText("I totally understand your concern and I have a sweet offer for you to consider! How would you feel about a 3 percent discount on this purchase?");
#sayText("Fantastic, glad you liked it! I've added the discount for the purchase to your account, hope you enjoy your shopping experience with us! Bye bye!");
20
exit;
21
}
22
}
Let’s say the user says they’ve found the same item elsewhere. We can ask about what made the user want to look for the item they wanted at another place, and then go from there:
#sayText("Well, that happens! I'm glad you were able to find what you were looking for, even if it wasn't with us. But could I ask you what made you decide to look at another place?");
#sayText("Ah, I understand. JJC group has lots of different options of various laptops you can choose from. I just sent a selection of different laptop models you might like. It's now available on your web account. I hope you like the seleciton and find some options you like most. Does this sound good?");
#sayText("I totally understand your concern. What I can do for you is offer a 5 percent discount on your next purchase. I hope this improves your shopping experience with us! Would you be okay with this future discount?");
#sayText("Gotcha. I hope you enjoy your new purchase! And just as a small gift from us I'd like to offer you a 5 percent discount on all the laptop accessories we have.");
#sayText("I just sent a link to all the similar models we have to your email. You'll find all the features, price, and all the other info you need right there. It's gonna be a pretty useful link for you! Now, do you have any other concerns regarding your purchase?");
#sayText("Is there anything I can do to improve your shopping experience with us or help you in any kind of way?");
46
wait*;
47
}
48
}
49
nodeemail_sent_bye
50
{
51
do
52
{
53
#sayText("Awesome. The email must have reached you by now, so check it out! Thank you for taking the time to talk, have an awesome day! Bye!");
54
exit;
55
}
56
}
57
nodeother_models
58
{
59
do
60
{
61
#sayText("I just sent a link to all the similar models we have to your email. You'll find all the features, price, and all the other info you need right there. It's gonna be a pretty useful link for you! Now, do you have any other concerns regarding your purchase?");
#sayText("We have " + $new_model + " available! I've just added to your cart. And as a small gift I'll added a 3 percent discount coupon to your next purchase. Does this offer sound good to you?");
#sayText("Perfect, I'm glad to hear that! You'll see the laptop added to your cart and also I'm about to send a link to your email which will let you complete the purchase in one click. Thank you for taking the time to talk, have an awesome day! Bye!");
#sayText("We have " + $new_model + " available! I've just added to your cart. And as a small gift I'll added a 3 percent discount coupon to your next purchase. Does this offer sound good to you?");
Note that in this part of the code we have nodes and digressions with the same name. It’s not a mistake - nodes and digressions serve different purposes. Digressions exist to enter the conversation once the conversation goes off on a tangent. You can read more about digressions in this post.
Let’s consider the reason being the user not having enough money to fund complete the cart checkout process:
#sayText("Oh, by the way, there's also a trade in option. You can bring your old laptop to us and have a heavy discount for a new one. Does this sound like a plan?");
#sayText("Absolutely! We do have a trade in option. You can bring your old laptop to us and have a heavy discount for a new one. Does this sound like a plan?");
#sayText("Alright, I've made a note of this. You can come to any convenient location for the trade-in, or send your laptop to us via mail and do the rest online. Is there anything else I can help you with?");
#sayText("As a final offer I would like to give you a 5 percent discount coupon, I just added it to your account. It expires in two weeks so make sure you don't lose the opportunity to use the discount! Thank you for taking the time to chat, bye bye!");
87
exit;
88
}
89
}
The following digressions and nodes follow the same logic at the previous ones, so it will be easy for you to navigate. Let’s now write out the way the conversation should go in case the user has concerns regarding the delivery/shipping:
#sayText("I apologize for the inconvenience! We can think of a way to send you your purchase. We have a USPS delivery option and it does deliver to your country. The delivery costs 57 dollars. How does this sound to you?");
#sayText("Okay! Just to let you know this offer expires in 2 weeks, so make sure you use it before it expires. Is there anything else I could help you with?");
#sayText("Got that. I understand what you mean. We care about our customers having the best experience possible, so I would like to offer you free delivery for your next purchase. How does that sound to you?");
#sayText("Haha okay, that's fine too! Just so you know, we have a big sale coming up, so watch out for an email announcement! Thank you for taking the time to talk, have an awesome day! Bye!");
7
exit;
8
}
9
}
Don’t forget that the user might not be sure about something and have concerns or issues they haven’t spoken about yet:
1
nodeany_other_concern
2
{
3
do
4
{
5
#sayText("Do you have any other concerns regarding completing the purchase?");
6
wait*;
7
}
8
transitions
9
{
10
}
11
}
12
digressionnot_sure
13
{
14
conditions {on#messageHasIntent("unsure");}
15
do
16
{
17
#sayText("In this case, may I ask what are you concerned about?");
18
wait*;
19
}
20
}
Here the transitions section is empty since the nature of the concern could be anything and the conversation would move to one of the digressions from here.
Almost done!
There are going to be times when there’s no way to convince the user to finish the cart checkout process. Let’s account for that with node no_dice_bye:
1
nodeno_dice_bye
2
{
3
do
4
{
5
#sayText("I'm sorry I couldn't be of help to you today. Thank you for taking the time to talk, have an awesome day! Bye!");
6
exit;
7
}
8
}
And done!
I suggest you adjust this conversational AI app to the needs of your business and to the industry your business is in. Don’t forget to join Dasha developer community for guidance throughout this exciting journey. It’s a great community to meet like-minded developers.