A chatbot can be an incredibly useful aid to your business and this post will give you all the steps you need to build your own. Using Botpress v12 and Smooch (now known as Sunshine Conversations by Zendesk) We'll show you how to connect to WhatsApp and build a simple Q&A bot that responds to a variety of questions.
Before we begin, you will need to set up and configure several services — these will require a business email and at least 64GB of space on your hard drive.
Begin by navigating to the Botpress v12 Documentation page, and download your preferred version of Botpress.
While Botpress v12 downloads, navigate to the Smooch/Sunshine Conversations sign-up page. Once you complete the sign-up process, you will then have to create an app and give it a name.
By this point, your download of Botpress should have finished. If you downloaded with the 'binary' option, simply extract the contents of the download into a directory of your choice.
The third service we will be using is called Ngrok, which you can download here. Ngrok is a free service that we’ll use to share the Botpress server running on your local machine to the web. Follow the instructions on the site to download and install. You're now ready to start creating your chatbot.
To get started on your chatbot, you need to first open the folder we extracted Botpress v12 to and run the 'bp' file. This will start the bot, which requires the download of some modules. This process takes some time, but should only need to be done once, after which every subsequent launch will be more expedient.
While the Botpress app is setting up, navigate back to your app on Smooch, and select settings. You should see options for naming your bot, giving it a picture, message options, an App ID, and API keys. When you see API keys you should create a new API key.
The Botpress v12 setup should be complete by the time you generate the API key on Smooch. At this point, your console will have told you where to open the Botpress Studio — in our case this was localhost:3000. Navigate to the URL provided in the console and sign-up for your admin account.
Since this is your first time running Botpress, you will see that your workspace has no bots. Select the option to create a bot and give it a name. This will automatically populate the Bot ID field for you. Next, select a Bot Template (such as the 'Learn Botpress Basics' option).
You will see that your workspace now has a bot! Proceed by selecting the bot (click on its name). A bar running vertically, on the left side of the Studio, should draw your attention. The options presented here will be what you work with most while developing your bot. In our case, we will start with the code editor option, which will open a series of directories in the studio and bring us to our next step.
Under Configurations in the code editor, you will see two folders. For now, focus on the Current bot.
Select bot.config.json under Configurations and scroll to 'messaging'. It is here you will be able to add an object 'channels', which will contain an object 'smooch'. In Smooch, create a boolean value called 'enabled' and give it a value of true. You will then need to create 'keyId' and 'secret' strings — which will take the ID and secret from the API key you generated in your Smooch app, respectively.
Once this task is completed, save your bot.config.json and navigate to the Global folder under Configurations to open the botpress.config.json. Look for 'externalUrl', which will be set to an empty string. This is a fairly simple service, so just follow the instructions on the site to expose the port the bot will be running on with Ngrok. After that, return to paste the HTTPS URL into the externalUrl string.
Save the file, restart the server and then open your bot again. Click 'Train Now' in the bottom right corner. You should see 'Ready' where there was once 'Train Now'.
Return to the Smooch app and you should see that webhooks are configured automatically. Navigate back to integrations, select WhatsApp and then connect. Now, choose your integration mode — for the purpose of this guide, 'Sandbox' will work fine.
Select 'Activate Sandbox' and follow the instructions to send a message to the specified number in WhatsApp. After you have successfully connected your Smooch Sandbox for WhatsApp, you should receive a message. Any further messages will be forwarded to the webhook you created.
Now you will be able to talk with your bot!
Now that we have a blank bot, and received a message confirming that our integrations work properly, let’s begin with the bot’s initial response after we say something.
To do this, navigate to Q&A in the Botpress Studio, which will be the fourth option down on the left sidebar menu. You will see a prompt to add a question by tapping the plus sign in the toolbar, go ahead and follow this prompt. This will bring up a screen giving you the option to enter text for both the question and the answer. In our case, we set the question to 'What is your favorite fruit?' With the answer being, 'My favorite fruit is the tomato, which most people mistake for a vegetable!' We can repeat this process a few times, giving it a new question and answer every time.
You will notice at the top right of every new question that it says incomplete. If you hover over this it will tell you that the Q&A will use exact match only. This is because we need to add multiple different ways of asking the question in order to enable and help machine learning for the bot. Go ahead and add several variations on the question to the Q&A, the more you add the better.
Finally, we can have a conversation with our bot, and ask it some simple questions, then get an answer. This should be fairly straightforward, just ask it one of the questions you created, and then receive an answer! Do note, as this is a fairly simple integration, any improper questions asked or messages outside of the parameters configured for this bot will simply be ignored.
In this guide, we covered signing up for the services you need to succeed in creating a chatbot with Botpress v12. This included Smooch, Ngrok, and Botpress itself. We configured our services, integrated them together, and talked with our bot. When talking with the bot we saw how it handles a variety of inputs, and noted how it responds to improper or unspecific input. If you want to build something more robust, calling APIs and working with flows, a good place to start would be our Mars Rover Photography chatbot example. If you want to build beyond WhatsApp and integrate your chatbot with other channels, check out our Botpress v12 Channel Integration playlist on YouTube. Happy Bot Building! :robot:
While it is recommended to read this guide in its entirety, here is a rough summary of the primary steps:
This is a comprehensive article about natural language understanding. How it works, and the different applications it can have for businesses.