Building a banking voice bot with Dialogflow and KOOKOO.
Building a banking voice bot with Dialogflow and KOOKOO.
Dialogflow allows you to “Build natural and rich conversational experiences”. KOOKOO provides you a telephony interface. So I thought why not mix the two and see if we can create a phone based voice bot. Following are the steps to create a quick banking voice bot.
- Login to Dialogflow and choose prebuilt agents.
2. Select Banking agent and click import.
3. Check the imported agent. You can type some query like “Transfer $1500 from my checking to my savings account”. Dialogflow will give you the cURL command to get the response for this query. Copy the curl command. You will need it to invoke from KOOKOO.
4. The Dialogflow piece is done. Now onto the KOOKOO code. The code is simple. The flow is a simple request response model like Twilio.
When a phone call comes, KOOKOO intimates your application. You can say, “Welcome, how can I help you?” using the <playtext> tag. Then use the <recognize>
<?phpfunction getFlow($access_token,$message,$sid) { $headers = array( 'Content-Type: application/json', sprintf('Authorization: Bearer %s', $access_token) );/*get the url and parameters from the copy cURL in Dialogflow*/
$curl = curl_init("https://api.dialogflow.com/v1/query?v=xxxxxxx&query=".urlencode($message)."&lang=en&sessionId=".urlencode($sid)."&timezone=Asia/Kolkata");
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($curl);
return $result;}
$sid=1;$message="Check my credit card balance";$api_key="xxxxxxxxxx";
$resp=json_decode(getFlow($api_key,$message,$sid));echo "<playtext>".$resp->result->fulfillment->speech."</playtext>";
?>
That’s it. In 15 mins you have your base framework for building your own banking voice bot accessible from any phone. You can try out this demo by calling +91–40–3024–7082(It’s not much. Just the default bot from Dialogflow. You can ask it queries like, “When is my payment due date?”, “Transfer $100 from my checking to my savings account.”, “Where was my last deposit from?”, “How much money did I spend on Amazon?” etc).
Similarly you can create a food delivery voice bot, coffee shop bot, dining out bot, restaurant booking bot etc. Just check out all the pre built agents on Dialogflow or build your own agent. You can also replace the Dialoflow bot engine with Microsoft bot framework or any other of the bot frameworks available.
Please leave comments below if you have any queries. In the next story, I will discuss how to make your FAQs voice compatible.