In Part-1 and Part-2 we created a basic e-comm chatbot and started creating ‘create order’ conversation flow. In this part we will be generating order id and saving the order details in data storage. In next part we will be adding intelligence using LUIS. Complete source code is here.
Following tasks we will complete in this part:
Generate order ID for the order details provided by the user
Create a csv file to save the order details against the user id. (to keep this tutorial simple we r using csv for data storage, replace it with your database).
Create a csv file to store order details:
In the project folder add a new folder. Name it Data. Create a csv file order_dummy.csv with 5 columns — user_id, order_id, creation_date, order_status, order_description.
Create helper functions to manage order data:
Create a new python script orderApp.py in the project folder. We will be adding 3 functions — addOrders, viewOrders, cancelOrder. addOrders function is for adding the order details in csv, viewOrder function is for fetching order details of a given user id and cancel order is to update the order status to cancel for the given user id.
Copy below code in orderApp.py:
Update createorder_dialog to generate order id and save order details:
Open createorder_dialog.py, we will now update summary_step. Add code to generate a new order id. All order id’s will have prefix ‘ord’ followed by 4 digit random number.
Create a pandas dataframe. Add a record with the order details along with user id and order id. also set the order status to “Order Received”. Pass this dataframe to addOrder function of orderApp module.
Add bot response, show the newly generated order id to the user in the bot response.
Below is the updated createorder_dialog.py:
With this we have completed coding required for Part-3. Test your bot using bot frmaework emulator. Follwo the steps givin in Part 1, to run the emulator.
Try similar flow with existing user. Check the data saved in csv file.
Greetings! My gf is working on a chatbot project and is responsible for designing the phrases and its behaviours using the Botpress (https://botpress.com/) platform for WhatsApp API.
Emojis usually appear in any circumstances with a simple copy-paste, but this does not happen when we talk about lists.
I’m posting as images two chatbot examples:
the first one being the Netflix WhatsApp chatbot which has no issues at all while using emojis inside lists.
The second, being her chatbot which simply refuses to display any pasted emojis in listings.
We already tried several things such as using the emoji’s Unicode but no success so far.
Any tips? As described, a simple copy-paste of the emojis themselves work just fine in any part of the bot, such as buttons, regular texts etc.
There’s a lot of analytics platforms that tell you about your bot’s performance, but what about just knowing what your users talk about with your bot? I’d imagine that’s especially useful for more open-ended, intelligent bots. Are there tools that do this well? Why do people not really seem to talk about it (might just be because I’m a novice)?
WhatsApp and Haptik have always believed in the power of messaging. Until now, WhatsApp was looked at as a customer service channel that can be used to resolve customer grievances.
With recent developments, it is clear that WhatsApp wants to enable Commerce for millions of businesses. Big brands are taking Commerce to where their users are engaging the most — WhatsApp. This has led to deeper engagements in a plethora of commerce options available to a user today.
WhatsApp commerce has been the engine behind the growth of many small and large-scale companies. WhatsApp chatbot has evolved into a full-blown channel that brands leverage to sell and transact with their customers, emerging as the most efficient channel to buy and sell digitally.
WhatsApp commerce is designed in such a way that it delivers a more personalized and delightful shopping experience for your customers on WhatsApp. We are confident that the convenience of shopping on WhatsApp chatbot is an experience that your customers will be delighted with.
A glimpse of what the next Commerce revolution looks like
Driving Discovery and Opt-in for WhatsApp
Now that you’re introduced to WhatsApp commerce let’s understand how your brand can get started with a WhatsApp chatbot. The first and most crucial aspect to consider at this stage is driving visibility and discovery. The two key questions to ask here are: How will your customers know that you are available on WhatsApp? How will they opt-in to receive your services over WhatsApp?
A key point to note is that WhatsApp requires a brand to get an opt-in from a user before it can start engaging with them, i.e., the user needs to consent to start a conversation with your business.
Let’s look at some techniques you can use to begin your brand’s conversations with customers on the world’s largest messaging channel.
1. SMS: You already have access to your customer’s phone number. You’re probably sending out SMS campaigns to them. This is a great way to get customer opt-ins.
2. Website: Your website is probably the most critical asset for your business. It’s where customers visit to do business with you. Here are a few sections that can have a customer opt-in banner:
Contact us page
Home page
Header, footer, floating element
Conversation starter button
The easier it is to find an entry point into WhatsApp on a website, the easier it is to start a conversation. Tapping a link or scanning a QR code is faster and easier than manually typing in a phone number.
The more prominent the placement, the more likely people will choose WhatsApp to engage with your business.
3. Telephony: You can leverage opt-in via telephone in two ways:
IVR Deflection: This should be used during peak hours with the highest wait times. Simply add a “move conversation to WhatsApp” option to your IVR menu.
Missed Call: Missed call automation is widespread in India. Hence this is another seamless way to get customer opt-ins. A user can simply give a missed call to your virtual number to get started!
4. Social Media: Your customers are likely using any or all social media channels to stay connected with their friends and family. This provides you an opportunity to get customer opt-ins where they’re spending most of their time. Let’s look at how you can leverage organic and paid social media to drive opt-ins.
Organic social media:
Account bio/description: This placement is permanent and will not get lost in the stream of feed or stories.
In-feed post: You can include the link in social media posts. Organic Instagram posts cannot contain links, so users must dial the number manually. In-feed posts have relatively short, in-feed visibility as they get quickly buried among other posts.
Instagram profile page story highlight: Highly visible, as they are pinned to the top of your business’s profile. Once in the story, users swipe up to start a conversation.
Paid social media:
Facebook & Instagram ads that click to WhatsApp: One tap/click: “Send Message” button will open WhatsApp conversation.
Influencer social media post: If the influencer promotes your business on Facebook, Twitter, LinkedIn, etc., they can use a link. Instagram posts cannot contain links so that influencers can mention the number, and users can dial the number manually.
5. Traditional Advertising:
QR code scan on OOH advertising
Search engine ads
PR/media news article
Now that we’ve understood the different techniques you can use to make customers aware of your WhatsApp presence, let’s look at how you should select the channels that make the most sense. The process of arriving at the solution includes answering four critical questions:
Where should we place entry points?
You should always add entry points to WhatsApp where your customers engage with your brand. E.g., If your target market is young people, ensure that you’re leveraging social media to drive opt-ins.
2. What behavior do we want to encourage?
E.g., If you’re going to answer product questions to close sales, create a “Click to WhatsApp” campaign and entry points on product pages.
3. What call to action should we include?
Always let customers know why they should start a WhatsApp conversation with you. Here are just a few:
Have questions? We have answers! Click to chat.
Can’t decide? Ask us! Message us on WhatsApp at 90009–90009
Need help but hate waiting on hold? Click to message us on WhatsApp.
We strongly recommend A/B testing to determine the best approach for your brand.
Deep links automatically trigger a pre-populated message rather than simply opening a WhatsApp thread. You can use deep links to delight users with context-aware responses that focus on their specific needs.
WhatsApp has made it highly flexible for you to get customer opt-ins. Practically, you can use every communication channel to get customer opt-ins. Now, let’s understand how your brand can leverage marketing notifications to nudge your buyers ahead in the buying journey.
Redefining Customer Engagement with marketing notifications
People want to hear from their favorite brands in more ways across the customer journey. Companies can now send more types of proactive notifications to people that opt-in to receive them. They will now be able to send updates such as:
Product recommendations related to a customer’s previous purchases
Helpful informational alerts and reminders
Relevant offers
Newsletters
Why is this a game-changer for customer engagement?
Expected: People have already opted-in to receive this information from the business over WhatsApp, so they are not surprised when they message them.
Relevant: The messages are personalized to the specific person (Ex: based on recent purchases or recent engagement with the business, personalized content in the message itself).
Timely: People receive these messages when they are relevant.
Marketing notifications are an essential part of the WhatsApp commerce solution. Brands that understand the importance of providing a superior buying experience to their customers will be more likely to leverage these types of notifications to their full potential. Let’s dive into the most exciting aspect of the WhatsApp commerce journey.
The shopping experience on WhatsApp
The eCommerce landscape in India has evolved exponentially. The eCommerce revolution spearheaded by Amazon and Flipkart disrupted how traditional Indian retailers imagined shopping. India’s most prominent retailers had to adapt to the changing needs of their customers. The COVID-19 pandemic has further boosted the demand for quick and convenient shopping experiences.
As the eCommerce industry continues to roar, there has been steady growth in the Conversational Commerce landscape in India. WhatsApp chatbot has become an integral part of every brand’s digital transformation strategy. Let’s look at WhatsApp’s newly launched UI elements that are set to revolutionize shopping.
Multi-product messages
Multi-product messages contain a selection of up to 30 items from a business’ inventory. Allow your users to shop conversationally. Multi-product messages let your user navigate to a specific category. You can also send personalized offers and recommendations to re-order their regular take-out order of fewer than 30 items.
Single-product messages
Single product messages are messages with a single product item from the business’ inventory. The product is displayed in a Product Detail Page (PDP) format.
Single Product Messages are best for guiding customers to one specific item from a business’ inventory.
You can also offer quick responses from a limited set of options, such as:
Responding to a customer’s specific request
Providing a recommendation
Reordering a previous item
Shopping Cart Experience
After viewing products, a customer can add them to their shopping cart and send that cart to a business.
For commerce on WhatsApp, a shopping cart is unique to a person/business chat thread in a specific device and has no expiration date.
Customers can add up to 99 units of each catalog item to a shopping cart, but there is no limit on the number of distinct items added to a cart.
List Messages & Quick Reply Buttons
List Messages presents a choice of up to 10 alternatives for users to pick from in a menu-type view. This makes it easier for people to choose from a list of alternatives.
Customers can now select an option from a list of Quick Reply Buttons rather than type back complete answers from a list of alternatives. This feature makes the entire conversation journey significantly faster. Read more about List Messages & Quick Reply Buttons.
Why You Should Use It
Both Multi and Single Product Messages lend themselves best to user experiences that are simple and personalized, where it’s a better experience to guide the customer to a subset of items most relevant to them, rather than browsing a business’ complete inventory.
For a user speaking on a messaging channel like WhatsApp, Multi-Product Messages & Single Product Messages make the journey of discovery and engagement easier. What’s more, these can be customized to a user’s preference than them having to browse through an entire catalog.
Simple & Efficient
Combining the features with navigation tools like NLP, text search, or List Messages and Reply Buttons to get what the customer is looking for fast.
Personal
It is populated dynamically so it can be personalized to the customer or situation. For example, you can show a Multi-Product Message of a customer’s most frequently ordered items.
Business Outcomes
A performant channel for driving orders, during testing, businesses had an average 7% conversion of Multi-Product Messages sent to carts received. AI-Powered Recommendation Engine
AI-powered Recommendation Engine
Imagine this: The salesperson in your store is trained to judge the visitor’s intent and recommend products based on intent and past visit behavior. Well, we’ve made this a reality. Haptik’s AI-powered recommendation engine increases upsell and cross-sell opportunities by contextually suggesting products your user needs based on their intent and past behavior. Haptik’s Recommendation Engine automatically matches user requirements with your product catalogs, description, customer reviews, and other data to help you convert passive visitors into engaged buyers.
Payment on WhatsApp
The frictionless experience of digital payments has accelerated the adoption of cashless transactions. Right from retail outlets in malls to local Kirana shops, the UPI code scanner sits comfortably at the cash counter of every shop. As your customers have grown accustomed to digital payments, their expectations and demands have increased rapidly.
This is where our 3-click payment experience on WhatsApp chatbot helps. WhatsApp will allow your customers to initiate payments from WhatsApp while on the purchase journey. The best part? They don’t have to navigate between multiple apps. You can also use notifications as payment reminders and ensure a frictionless payment collection process.
Conclusion
WhatsApp commerce is poised to become the biggest game-changer in the eCommerce story of India! Customers don’t have to browse through multiple apps and websites to find what they’re looking for. WhatsApp will become the most important channel when it comes to generating sales and unlocking hyper exponential growth.
Haptik is proud to be the first BSP to launch these new features with JioMart. The use cases that JioMart is driving with WhatsApp commerce are:
Driving conversations with marketing notifications
Sending personalized product recommendations based on customer’s needs & past behavior
Driving orders through interactive messages and a seamless Shopping Cart experience
Haptik has also powered WhatsApp solutions for some of India’s most prominent brands such as Jio, TATA, HDFC, Dream11, OLA, Kotak Mahindra, etc. We’re a recipient of 15 G2 badges and recognized by Gartner and Opus Research. With handling over 4+ Billion interactions, we’re India’s largest Conversational AI company!
Did we mention that we have built the World’s largest WhatsApp chatbot for MyGov India?
So I am trying my best to get into chatbots and use them for my business but I am having a really hard time figuring out what platform to use. There are so many platforms out there and it is incredibly overwhelming.
What I am trying to build:
An SMS, WhatsApp, or Telegram chatbot that interacts with our existing customers to help them create complex orders.The bot would have to get information from our database about that customer and start by presenting them with some of their preferences.
Then the users select the items that they would like to order and make a few customizations.
All of this should be tracked and then presented to them at the end to confirm that we have the right information and when they are ready, they process the order and it is processed on their account. Their inputs would therefore have to make changes in our database and create triggers upon which certain actions would be executed.
I have played around with ManyChats and Landbot but these platforms can’t accommodate the back and forth that we need. Any ideas? Should I just create my own from scratch?
Create chatbot using bot framework sdk and LUIS — Part 2
In part 1 we completed basic structure of the bot service. In Part-2 our bot will give create, view and cancel options to the user.
This is continuation of Part-1. If you are coding along with me then follow this blog otherwise you can also download the completed code from here.
In Part-2 we will cover following:
Our Bot will give Create Order, View Order and Cancel Order options to the user.
We will add sub-dialogs for create, view and cancel.
For create order we will complete the basic flow of conversation.
For create order selection, conversation will be diverted to create order sub-dialog.
Bot will ask user to provide the order details.
Bot will then respond with the same order details (echo) provided by the user.
In the subsequent parts we will save the order details against the user id in a data storage. we will add intelligence to the bot with LUIS service to interpret the order description.
Creating sub-dialogs
Create a new folder in dialogs folder and name it operations. In operations folder create 3 scripts- createorder_dialog.py, vieworder_dialog.py and cancelorder_dialog.py
Let us start with coding createorder_dialog.py. In this part we will add only 2 steps (order_step, summary_step) in the waterfall dialog steps for create order. we will add more steps in the subsequent parts.
In the first step bot asks user to provide his order details. Second step is added to accept the text provided by the user in the context object and echo i.e. respond with the same text as bot’ response. in the next part we will save the order in the data storage. But for now just echo the text.
Add below code in createorder_dialog.py
We will also define the classes vieworder_Dialog and cancelorder_dialog. We will not add any waterfall steps for now. just the basic sturcture.
Now we need to update app.py to create objects of the new dialog classes we have created. These objects will be passed to the main_dialog class.
Below is the updated app.py:
Next we will update main_dialog.py. First update the init function to add parameters to accept objects of the sub-dialog classes. These objects needs to be added as sub-dialog. Call add_dialog method to add these objects in the dialog. In the waterfall conersation flow we will add one more step act_step after intro_step.
update intro_step to give Create order, View order and cancel order options to the user. In act_step add code to read the option selected by the user. Depending on users selection divert the dialog to createorder_dialog, vieworder_dialog or cancelorder_dialog.
Update main_dialog.py:
We have completed coding required for Part-2. In the next part we will add code to save order details provided by the user in a data storage. In the subsequent parts we will add more intelligence to the Bot to read and interpret the order details.
Now test the bot using Bot framework emulator. instructions for using emulator is already given in Part-1.
Create chatbot using bot framework sdk and LUIS — Part 1
We will create a simple e-commerce chatbot using Microsoft bot framework SDK in python. Our bot agent is a Bakery Shop agent. Users can request the bot to create an order , view orders and cancel order.
Source code for the bot is available here. You can download the code from the git directly or you can follow this blog to code along with me.
We will develop the bot in multiple parts.
Part 1 — Below mentioned conversation flow we will complete in part 1:
bot will welcome and greet the user [this will be implemented using an adaptive card]
Bot will ask the user whether he is an existing user or a new user [using option buttons]
If user responds as new user then a new user id will be generated and displayed to the user as response
If the user’s response is “Existing user” then Bot will prompt user to provide his user id.
User id provided by the user will be saved in the context object.
Tools and Libraries used:
VS Code as development environment
Bot Framework SDK python libraries for designing the flow for conversation
LUIS App for adding intelligence to the bot.
Bot Framework Emulator to test the bot
Create a bot service:
Open your working directory in VS Code. Create python script files config.py and app.py.
In config.py add below code to save the port number, microsoft app id and password in the configuration attributes. Microsoft app id and password are required for Bot framework SDK.
PORT = 3978
Now in app.py. We will create the basic structure of the bot service. copy the below code in app.py.
In the above code we are importing libraries required for bot framework. Pip install these libraries. We have created the main bot message handler method “messages”.
Now the service is ready, we will create the bot response.
First create a class to save the context values related to the user like user id which we would preserve to use throughout the conversation.
In the main project folder create a new python script user_details.py, create a class with an attribute user_id. We will add more attributes as we proceed.
Adding helper classes:
We will now create few helper classes. Create a new folder in the main project and name it as “helpers”. Add __init__.py, activity_helper.py and dialog_helper.py. Base code of activity_helper.py and dialog_helper.py are taken from bot-builder samples provided by microsoft. Activities are the main objects of bot framework that drives the bot.
add below code in __init__.py
__all__=["activity_helper", "dialog_helper"]
Copy below code in activity_helper.py:
Copy below code in dialog_helper.py. Object of UserDetails class is initialised here and None is set as user_id.
Base code is taken from bot-builder samples . Create a new folder with the name bots in the main folder. Add 3 files “__init__.py”, “dialog_and_welcome_bot.py” and “dialog_bot.py”
In __init__.py add below code.
from .dialog_bot import DialogBot
from .dialog_and_welcome_bot import DialogAndWelcomeBot
__all__ = ["DialogBot", "DialogAndWelcomeBot"]
Base code of dialog_and_welcome_bot.py is taken from bot-builder samples. Code is updated to use an adaptive card as response. First we will add an adaptive card. Create a folder in the main project and name it as cards. Add the json for the adaptive card in this folder. You can use the json script given below or can create your own adaptive card by visiting https://adaptivecards.io/designer/.
Add below code in dialog_and_welcome_bot.py.
Now we will add code in dialog_bot.py. This will be accessed from app.py. DialogBot object initialization expects a parameter dialog object. We will next define this class.Add below code in dialog_bot.py:
Now we have basic structure ready. We have to tell the bot what to response and how to drive the conversation. For that we will be using Bot Framework’s waterfall method of defining conversation flow. For now we will create 2 dialog flows one to handle cancel and help and the second one will be the main conversation. We will add more dialogs as we proceed.
Creating Dialogs:
Create a new folder dialogs. Add 3 files — __init__.py, cancel_and_help_dialog.py and main_dialog.py.
Code for __init__.py:
Code for cancel_and_help_dialog.py:
Next we have to code main_dialog.py. In this script we will add code for the main converstaion flow. We will add 4 steps in the waterfall flow. In first step we will ask user if he is an existing user or a new user. In second step we will take the user’s response. If user selects “new user” option then we will generate a user id (using random function). For existing user we will ask user to provide the user id. In third step we will read the user id provided by the user and save it in the context object. In the fourth step we will just loop the conversation.
Copy below code in main_dialog.py:
Now we have to update app.py. We will add code to initialize bot adaptor. We will also initialize dialog classes. And as a first bot response, object of DialogAndWelcomeBot class from module dialog_and_welcome_bot.py will be invoked.
We will now need to add adapter_with_error_handler.py. copy the below code to handle any error from adaptor.
With this we have completed the coding required for Part-1. We will all code for create order in the next part.
I started to explore chatbot design two weeks ago and decided go with Rasa for my first chatbot development. As a leading open source chatbot platform, Rasa recently upgraded from 2.x to 3.x. While users are encouraged to upgrade to the latest version, I encountered some hiccups during installation and fortunately all got resolved through Rasa forum and googling. In this article, I am going to guide you through the installation process step by step, and also include all the tricks leading towards running your first chatbot example on macOS.
TLDR: Hiccups I encountered and how to fix them
Problem 1: ImportError when running “rasa init” after successfully installed Rasa 3.0
ImportError in sanic package
Solution: downgrade sanic to 21.9.3 via running “pip3 install sanic==21.9.3”. Credit to nik202 on Rasa community forum.
Problem 2: Trying to install Rasa X on my local machine to enable conversation driven development, but encountered a series of errors during installation (see my post on rasa forum for details).
Solution: Basically, Rasa X is designed for server deployment. If you are new to chatbot, I’d recommend to test your chatbot logics in command lines or use other front end deployment on a single machine. I’ve tried the Chatbot Widget from git, and it works perfectly for single machine deployment.
Problem 3: After running “rasa init” and training the first model, you may want to modify the example moodbot and test your own logic. How to ensure all the logics comply to Rasa underlying training mechanism and train your own model?
Solution: Here are some commands you want to run:
– rasa data validate: to ensure no conflicts in the stories and domain file
– rasa train: to train your own model
– rasa shell — debug: test the responses while you can track the states of the intent prediction and entity values
Problem 4: After modified the stories and intents, and trained a few models, the responses started to divert from the design. For example, the response should be text but it always showed buttons in the previous design.
Solution: Try to delete the old models and run “rasa train” again.
If you are new to python or Rasa, the steps below could help lead to your first chatbot running on a single machine. The commands used in the follwing steps are slightly different from Rasa installation page or their Youtube installation guide, and I am listing the ones worked for me.
Step 1: Check your python version — 3.7 or 3.8 supported
It is recommended to install and run Rasa in a virtual environment with python 3.7 or 3.8. You can jump to Step 3 if you already have python 3.7/3.8 and virtualenv installed.
Otherwise, you need to first install python via pip or the binary file from python Download page. I will recommend using the binary file if you are new to python. After downloading, just double click on the .pkg file and follow the installation wizard.
Step 1.1: Install Python 3.7 or 3.8
Installation Wizard of Python 3.8.1
I’ve followed the youtube guide and installed python 3.7.9. Once installation is done, you can check the python version in terminal by running the command below.
Step 2: Install virtualenv and create a virtual environment
Install virtualenv: run “pip3 install virtualenv”
Create a project directory if it does not exist: run “mkdir rasa-init-demo”
Create a virtual environment in the project directory by running:
– cd rasa-init-demo
– virtualenv venv
activate venv: run “source venv/bin/activate”. To exist the virtual environemnt later, run “deactivate”
“(venv)” would appear after activation
Step 3: Install Rasa Open Source in venv and initialize an example project
install Rasa in venv: run “pip3 install rasa”. Note that Rasa X is not supported with Rasa 3.0, so you need to downgrade to Rasa 2.8.x (e.g.: “pip3 install rasa==2.8.13)if planning to run with Rasa X.
initialize the first Rasa bot: run “rasa init”
optional: downgrade sanic if encoutered any ImportError: run “pip3 install sanic==21.9.3”. Then rerun “rasa init”
At this point, we should see the welcome message and guiding questions in the terminal. As a new user, one may proceed with “Yes” for the two questions and start training an initial model (mood bot). In case you prefer to pause here and train the model with your own data, you may reponse “N” to the second question. You can start to modify the data, action and config file, and train your own model later.
I will continue with the modification and creation of your own bot in next post.