In this guest post, Will Dawoodi of Init.ai, illustrates how to build advanced conversational apps using Smooch.io.
Our goal at Init.ai is to enable companies to create conversational apps. These conversational apps leverage our proprietary conversational NLP and AI, and are more advanced versions of the current slew of chatbots. To enable these new apps, we need to be able to seamlessly integrate with multiple messaging channels and services- everything from SMS, to Telegram, to Facebook Messenger. Since Facebook announced their Send/Receive API for Messenger last month at F8, we have been looking forward to integrating it into our offering. Smooch is the first messaging service to provide this Facebook integration publicly so we set up a demo application to try out their process.
Smooch.io is the first messaging integrator to provide Facebook integration publicly.
At first, the minimal documentation gave me pause. I hearkened back to studying Mathematics and the high correlation of slim textbooks to more complex subject matters. But I soon realized that the documentation was minimal because Smooch had built a very straightforward API.
Smooch's four step integration could not be easier.
- First we created an application in Smooch. What does this entail? It means interacting with the Smoochbot and then generating the JWT key ID and secret keys. They believe in conversational interactions and actually implemented the tech itself. And that implementation was, again, very smooth.
- Second, we created webhooks via the Smooch REST API to our endpoint URL.
- Third we implemented the webhook endpoint on our side.
- And, fourth, we started posting outbound messages to Smooch’s REST API. This last step is what allows us to receive messages from users, process them, and then reply.
Smooch has also made connecting to Messenger dead simple. Rather than creating a dedicated app on the Messenger platform, Smooch uses OAuth to acquire permission from Facebook to send and receives messages on behalf of a Facebook page you have access to. The result is you can get started with Messenger almost immediately, without having to setup webhooks or even deal with Facebook’s UI.
Overall, the process of hooking up to Facebook Messenger via the Smooch API was very simple. We are working on building a more robust connection to Smooch into Init.ai, since we think it’s a great platform for building conversational apps.
So now that you know how we integrated, let’s talk about some other advantages of using Smooch to build your conversational apps. If you are building a conversational app or chatbot you’ll also benefit from Smooch’s clear scope and trigger model. This model allows you to capture all messages and to separate them into those from app end users and those from the app creator. For our demo app, we only subscribed to messages from the app end user. With this subscription, Smooch calls the webhook on our platform each time a user sends a message. We then add the message to the conversation we store on our side for processing by our conversational NLP and business logic systems, which, in turn, decide how to respond.
We appreciated Smooch’s attention to security in how they treat webhooks. Our internal API is closed, but webhooks are necessarily open, so security is always at the forefront of our minds as well. For each incoming webhook, Smooch passes a shared secret, unique to that webhook, via an HTTP header, so we can verify that it is in fact coming from them.
With Smooch.io, there is no worry over the risk that a webhook came from a third party.
As a trusted platform provider, we are deeply concerned with eliminating any potential for data loss, even for a simple demo app. If a company is chatting with a customer and loses any of that dialogue, the integrity of the app could be compromised. Smooch has a retry mechanism, which means that when they send a request to Init.ai, if for any reason our platform does not accept it, Smooch will re-send it three more times, with increased timeouts in between.
Smooch.io has reduced the probability of data loss and we won’t have to lose sleep over it.
Another advantage to using Smooch is the rich level of information that was contained in the webhook payload. We are able to capture message data, user info, platform and device information with ease. That level of detail helps our system understand user intent and tailor our replies for each platform. For Facebook we are able to send out much richer replies than we would if we were using SMS only. We can also use that information to populate our analytics dashboards.
Now there is one thing Smooch didn’t provide. We use Go within our stack and Smooch is lacking an official Golang client. Not a problem. We built our client for Smooch in Golang. Guess what?
Init.ai will be open sourcing a Smooch.io Go client shortly for others to use!
Note: Special thanks to our developer Denis Zaytsev who did the hard work of the integration while I did the wordsmithing.
If you’re interested in more about conversational interfaces, follow me and Init.ai on Medium and Twitter. And if you’re looking to create a conversational interface for your app, service, or company, check out my company Init.ai.