Building bots for SAP Jam, just got easier!
This week SAP Conversational AI (SAP CAI, formerly Recast.AI), released a new bot connector for SAP Jam Collaboration. In my last blog post “Bots have arrived at SAP Jam”, I discussed what an SAP Jam Bot is, and what features are required to make them possible. With this release, bots built using SAP CAI can now be published and configured to work inside SAP Jam messages. This makes building SAP Jam bots that understand natural language much easier than it was in the past.
What is SAP Conversational AI / Recast.AI
Like any job involving many moving parts, building bots is not a simple task if you do not have the right tools. In early 2018, SAP completed the acquisition of Recast.AI. Now renamed SAP Conversational AI, SAP CAI is a collaborative end-to-end bot development platform. It has all the technology you need to build, train, host, and connect your bots to your favorite conversational channels like Facebook, Slack, or Skype. Powered by machine learning, they have a Conversational API that allows developers to expose natural language interfaces to your bots. Once deployed, the platform provides bot analytics that allows you to measure the success of your bots and tweak their training to better serve your customers and use cases.
As a product manager, I don’t get to write much code anymore. Even with my diminished technical skills, I was able to quickly build a bot on the platform, add a natural language understanding, and publish it to work in a developer instance of SAP Jam. This was a simple ‘hello world’ bot that told me jokes after a little prompting. Obviously, building critical business processes into your bot will take much longer, but my example shows that the tooling to allow developers to integrate natural language into SAP Jam messages is ready and easy to use.
Building bots is a four-part process in SAP CAI as you can see from the tabs in the above screenshot. Once the bot has been trained, built and coded, developers can now “connect” to SAP Jam as a supported channel. Bots built on this platform can now be easily configured to work with SAP Jam Collaboration with just the click of a button.
To learn more about SAP CAI connectors see https://recast.ai/bot-connector
The road ahead with chatbots and conversational interfaces
The SAP Jam team is exploring new bots to compliment the use cases and needs of our customers. In the near future, you are likely to see conversational interfaces that support many of the scenarios that are common in SAP Jam today. We are already seeing our customers drive some of this innovation.
Bringing AI and natural language processing through bots to SAP Jam Collaboration is beginning to paying huge dividends to SAP Learning Hub. SAP Learning Hub powered by SAP Jam Collaboration uses SAP Leonardo Machine Learning to power bots that answer forum questions and save huge amounts of time for their trainers and group administrators by answering frequently asked questions.
You don’t need to go far to see how bots are changing the way we interact with applications and software. With the addition of the SAP Jam connector for SAP CAI it has now become so much easier for developers and partners to provide bots and conversational interfaces that help people get work done.
For those who are interested in getting their hands dirty and building their first SAP Jam messages bot, see the tutorial below. Estimated time to finish 45 minutes.
Building a HelloWorld bot for SAP Jam messages – A step by step walkthrough
Step 1. Get administrative access to your SAP Jam tenant.
If you don’t have an SAP Jam Collaboration tenant you get a developer edition instance in SAP Cloud Platform. Follow this blog.
Step 2. Create an account on Recast.ai, its free.
Step 3. In Recast create a new Bot by pressing the “New Bot” button.
Step 4. Press the “Create a complete chatbot” option.
Step 5. Select the predefined skill of “Greetings”. There are so many available skills to choose from that help make your job easier, but for the sake of this demo we will just select “Greetings”
Step 6. Give your chatbot a name, and choose to mark it as public or private.
Step 7. Press the “CREATE A BOT” button.
As this point, you have a chatbot that understands to simple “intents”. This means that if you talk to the bot it understands when a user tries to greet it and it understands when a user tries to say goodbye to it.
The default logic of the bot will respond with its own greeting if you greet it, and it will respond by saying goodbye if you if you say goodbye to it. This is where I suggest you play with the bot and test it out. You can greet it in hundreds of different ways and it will generally understand your intent, and respond accordingly.
If you see that it responds with both a greeting and farewell message, this means you have probably confused it, so it answers back with both intents.
Step 8. Press the “CHAT WITH YOUR BOT” button on the bottom right-hand side of the screen.
Step 9. In the chat box try all the different ways you can think of to say hello to your bot. If the bot responds twice, you have confused it.
Step 10. Test the NLP APIs understanding of 1990s slang.
It took me a while to confuse the Bot with an English greeting that it didn’t already understand but I was finally able to find a greeting it didn’t know. When I was in high school my friends and I sometimes used the slang, ‘sup’ as a shortened version of “what’s up”. Recast already knows that “what’s up” can be both used as a greeting and as a question. It correctly responded with a 86% confidence when I greeted it with “what’s up”. When I greeted it with “sup”, this is what I got back.
You can see that it responded twice which means it is confused and the default logic for the bot hedges its bet and answers with a greeting and a farewell message.
Step 11. Click on the ‘i’ above the bot chat responses allows you to take a closer look at what happened.
The JSON text above shows the response the Recast NLP API returns to the bot. You can see there are two “intents” returned for the “source” word “sup”. The NLP API response shows that Recast is not sure what to do with “sup”. You can see that it says there is a 50% chance that this is a greeting and a 49% chance this is a “goodbye” intent. In this case, the bot is configured to send both responses.
More configuration in the “Build” tab or customer code can adjust the tolerances to only reply when you are sure of the users intent. Something higher than 90% is likely required for good user experience.
Step 12. Train the chatbot to understand 1990s slang for hello.
Close the chat window and click the “Greetings” intent link. This allows you to see all the existing training that the bot uses to understand incoming greetings. You will see it is very extensive. Click “Add an expression” and type the word “sup”.
Open up the chat panel and try saying “sup” to the bot. You will notice that it now only replies with a greeting and if you inspect the response you will see that the NLP API is 99% sure you are trying to greet the bot.
Step 13. Understanding the Recast tabs
We just finished using the “Train” tab to teach the bot our slang. The “Build” tab allows us to configure and build the basic business rules of the conversation. For example, we could specify that we need to be 95% sure of an intent before the bot responds, or we could configure the words the bot uses to respond to greetings. For details, you can reference the official documentation here: https://recast.ai/docs/build-your-conversation
The code tab provides developers with resources to integrate more complex business logic by calling the APIs directly and host the bot on a server that runs the bot on something like SAP Cloud Platform.
The “Monitor” tab allows you to see analytics on the types of questions people are asking your bot and you can drill down into the success of the skills and intents in responding to those queries.
Step 14. Connect your Bot to SAP Jam messages.
Click on the “Connect” tab, and scroll down until you find “SAP Jam Collaboration”, and click the ‘+’ icon. Click on the “NEW SAP JAM COLLABORATION” text.
A wizard will guide you through connecting your chatbot to your SAP Jam Collaboration tenant. I’m not going to reproduce that here because it is so nicely documented in the wizard. I will give you the short version for those who are familiar with SAP Jam already. You need to give the wizard four pieces of information.
- An Alias UserId
- An OAuth token for that Alias User. Obtained from the Alias user page in SAP Jam.
- A webhook token. You can get this when setting up a webhook. Currently, we only support the “Added to message thread”, “Message received”, and “Message card action received” events.
- The base URL for SAP Jam eg. https://developer.sapjam.com, https://jam4.sapjam.com, or whatever your instance is.
Once you fill in the form and click “Connect”, it gives you a callback URL that you must add to your Webhook. Remember to save your webhook and make sure it is enabled.
If your connection is successful your Push Notification will look like this.
Step 15. Chat with your bot.
Go to SAP Jam and start a new message thread with your alias user. Have fun saying hello and goodbye! That’s it.
Your feedback greatly encouraged.