All Things Techie With Huge, Unstructured, Intuitive Leaps
Showing posts with label calculating chatbot. Show all posts
Showing posts with label calculating chatbot. Show all posts

The Birth of a Car-Selling Monkey --The Evolutionary Cycles of My Chatbot


Honest John is evolving, and it's not taking millions of years. Honest John is my chatbot that will sell cars either online or on at dealership kiosk. This side project of mine started when friends of mine wanted my help in buying a new car, and they had a bad experience with a high-pressure car salesman who was a stranger to the truth. My friend had said that she would rather negotiate with a computer and that is how Honest John was born.

I fired up my Software Development Kit, opened a framework, and it wasn't hard to get some running code quickly. Unfortunately, the earliest of version of Honest John was quite stupid. He was merely a parrot. And if you stumped him with a question that he didn't understand, he would give an innocuous reply and ask a random question. Obviously we had a long way to go.




The conversation was quite two-dimensional. I was using AIML which is Artificial Intelligence MarkUp Language. The way that it works, is that it recognizes a predicate in the input text, searches through its library for that predicate and spits out a response. The first task on my part was to add some humanity and politesse to it. You can't expect to sell something to a human unless you act like a human yourself. So I had extensive edits to the AIML to make it more human.


The personalization of the conversation was necessary. To do that, I had to write a user object that remembered things about who the chatbot was talking to. Honest John had to remember if he was talking to a woman or a man, and the person's name. It was functional now, but it was like stick figures talking to each other.

Before I went further into a more human chatbot, it needed some smarts. Most chatbots out there are incapable of logic and error correction. If Honest John were to negotiate, he would need to evaluate arithmetic expressions so that he could talk money and price. He needed to be date/time aware. He needed to have logic to recognize if a bid was lower than the previous one, and needed to react appropriately. Even though there are wonderful recursive elements in AIML, this sort of stuff was way to complex for AIML to handle.


So the answer was to intercept the inputs and AIML outputs, and send them to a parser that would determine if the conversation needed remediation by an Arithmetic Logic Unit or a plain old Logic Unit in the code. Luckily this was easy to do, because my framework is a J2EE (Java Enterprise Edition) framework that is capable of complex actions like creating any objects, stuffing them with data and holding them in memory for easy access. Because of unique, time-aware Java classes and multi-threading, I could take the conversation, dissect it and send it to appropriate parsers which kicks a new thread to do some work on each element, wait for the response, and finally spit out a response to the user that is intelligent. The other element that most chatbots do not have, is that they can record the conversation history, but they cannot traverse it, regress to a certain point in the past, and understand past statements. I had to create a live chat record in memory, along with meta-data and logic to correct those faults. In the middle of a negotiation, if things got off the rails, the chatbot could go back to the last point of agreement and start again from there.

Now we were getting somewhere. We had the beginnings of a bot that could negotiate. However we still had the problem of sophistication -- it was just two stick figures talking to each other. Humans need emotions and empathy, and bots need to live in that domain too -- however artificial it may be.


The Holy Grail of mixing digital smarts with the human milieu was first appreciated, understood and defined by Alan Turing, when he devised the Turing Test, in which a human could not detect that they were talking to a computer. That requires an EQ and an IQ (an Emotional Quotient as well as an Intelligence Quotient). Honest John doesn't even pretend to be able to pass a Touring Test. But the conversation has to become more three-dimensional in human terms.

Understanding emotion in the user and reacting to it, is the beginning of artificial personality. This is important to Honest John in the selling process.



Suppose that in the middle of negotiating, Honest John detected that the user was getting angry, bored or any other negative emotion that would be the thin edge of the wedge in precluding a sale -- after all, his whole job is to sell cars. The chatbot would need to have the detection circuits to understand that. More importantly, Honest John would need to take remedial action, and either soften or harden his tone. Moreover, he would need to alter the negotiation strategy, either becoming more or less hard-nosed depending on the specifics.

For that reason, Honest John needs to have several strategy processes defined, and they all relate to pre-defined personality aspects. Honest John needs to adjust the tone of the negotiations. To do that, not only does he require the right words, but also the right actions. If the negotiation price is in the ball-park of a sale, and he detects that the user may walk, Honest John needs to sell the car. If he is not in the ballpark of a selling price, he either needs to adjust his negotiating increments depending on the temperament displayed by the human on the other side of the screen. He must be capable of being "fuzzy".

So all in all, Honest John needs to have a range of sophisticated behaviors before I let him out in the wild, I am working on it. He does have AI networks built into the stream of things. He has such Natural Language Processing (NLP) tricks like Bag-of-Words and other algorithms to help him decipher things. I think that the tools are all in place in Honest John innards. All that I need to do, is integrate them, expand them and polish them. Who knows, you may meet Honest John one day in a showroom or online, and you will remember his evolutionary history.

Never Mind Artificial Intelligence, How About Artificial Personality ?

In my quest to make the ultimate Artificial Intelligence chatbot that sells cars, I have been pontificating on various attribute that the chatbot should have. It should have an EQ (Emotional Quotient) as well as an IQ (Intelligence Quotient). It should be good at math instantly. It should be good at logic and detecting attempts to misdirect and confuse it. It should know when to be aggressive and when to back off, as part of its emotional awareness. It should be able to remember conversations, and return to any point in the conversation after a non sequitur, especially when in the middle of negotiations. I have already describe on a high level as to how I would implement the technology for this in previous articles.

As I was discussing this with a friend, it was pointed out that I needed to create a de facto artificial personality. And it was pointed out to me, that perhaps there should be a feminine one as well as a masculine one. I named my chatbot Honest John and made him a male, simply because I am a male, and I tried to transpose what I would say if I were a chatbot.

I keep up to date with Artificial Intelligence and I am practitioner of it. There are researchers out there seeking the Holy Grail of artificial consciousness in silicon. They are trying to making "thinking machines" with consciousness. Artificial consciousness in a thinking machine is a noble aim, but I think that it is putting Descartes before the horse. One has to have a personality that directs the aspects of thinking and personality-expression, much like a wedding cake and a wedding ring converts your partner's personality to a morose, complaining entity with a negative worldview.

Creating gender in a chatbot is easy. It is already incorporated in the AIML (Artificial Intelligence Markup Language). It substitutes "he" for "she" and hobbies like "sewing" instead "drinking beer". But that is not enough. The gender responses also have to match the personality. For example the non-sympathetic, hard-nosed, take-no-prisoners negotiating chatbot could either be a man or a woman, and truth be told, some men prefer a woman with those traits. So, there has to be a way of imbuing personality into the chatbot.

Luckily, that is not technically difficult to do. Once personality traits are defined, they are stored in AIML, and the appropriate AIML libraries are loaded when the chatbot fires up. The work for this, is all semantic and expressed in natural language within the AIML. This is where a liberal arts degrees become useful again -- at the intersection of technology and human interaction.

So my chatbot Honest John will have the capability of becoming transgendered into Honest Jane. Or Honest John will have the ability to stop being the cigar-chomping salesman and become the meditating yogi who recommends an electric car at a fair price to the goodhearted peoples who made it to save the planet's environment. This has been a fun journey so far.

AI Chatbot Tactics ~ Making A Customer's First Objection His Last

For a very brief period during university daze, I used to sell cars. This was in the era of high pressure car salesmanship where you ground down the customer until he/she signed on the bottom line.

On the first day of work, I was taken into the boardroom with a bunch of my fellow misfit newbies at Shyster O'Toole Motors and sat down in front a VCR. The sales manager hit the on button and went out to sexually harass the receptionist. The video tape had been played so often that there were hisses, snaps and odd interference lines running through the picture on the TV set. The reason why the video tape was so worn was that Shyster O'Toole Motors was a burn and churn outfit. They would hire anyone who would walk through the door. They knew that each newbie could at least sell a couple of cars to his acquaintances, friends or relatives in their first month of salesmanship. If they didn't repeat the sales by the second and third month, then they were burned and churned, and a new, rosy-cheeked naive batch took their place.

The scratchy video tape was narrated by a jowly character stuffed into a too-tight suit who spoke with a deep southern hillbilly accent that befitted a shyster televangelist. His name was Catterson, and he was gonna teach us to force customers to buy cars from us, come hell or high water.

There were many high pressure tactics, but the one that comes to mind now, is making a customer's first objection, his last one. The reason that I could dredge it out of my memory, is that I am making an AI chatbot called Honest John - a car-selling bot that is actually honest, and not high pressure. But I am developing strategy framework and one thing that any salesman, saleswoman, or salesbot has to do, is ask for the sale. If you don't ask for the sale, you are not selling. The consent to buy has to be present. During the course of negotiation, the customer may come up with an objection mid-stream that halts the consent to buy. Honest John, my chatbot needs a strategy to overcome the objection and that is why I thought of the sales training video that I had seen many years ago.

Essentially, the tactic of making a customer's first objection his last, goes somewhat according to this script:

Hy Pressher, Car Salesman: "Hello Mr. Lilywhite, I see that you are looking at the new TurboHydraMatic Coupe. She's a beaut ... ain't she?"

Joshua P. Lilywhite, Customer: "It certainly is a nice car."

Hy Pressher, Car Salesman: "I'll let you take it for a spin to see how nice she drives."

Joshua P. Lilywhite, Customer: "Ah no, I'd rather not. I am just looking."

Hy Pressher, Car Salesman: "What-sa matter. Don't you think that all your friends and neighbors would be jealous of you when you pulled up in this gorgeous set of wheels?"

Joshua P. Lilywhite, Customer: "No, I like it and they would be impressed ... but ..

( ... HERE COMES THE FIRST OBJECTION ...)

Joshua P. Lilywhite, Customer: "I really can't afford to buy this car."

( ... AND HERE IS HOW TO MAKE HIS FIRST OBJECTION HIS LAST ...)

Hy Pressher, Car Salesman: "Are you telling me, Mr. Lilywhite, that the only reason that you can't buy this car from me today, is that you don't have the money?"

Joshua P. Lilywhite, Customer: "Yes. (hesitantly) "I guess so!"

Hy Pressher, Car Salesman: "Well Mr. Lilywhite, today is your lucky day. I can find you the money. Step this way."

Hy Pressher will immediately wire this guy into a sub-prime car loan at credit card interest rates. When Lilywhite starts to object, Pressher reminds him of his agreement to buy the car and seriously insinuates that Lilywhite would be welcher and not a man of his word.

Now back to the chatbot. If Honest John runs into a brick wall and the customer starts objecting to buying the car, Honest John will use the words "is that the only reason ..." but he won't use those words against him or her. Honest John is ethical. If a customer says yes, there is just one sole reason why he/she won't buy the car, then Honest John will ask the same follow-up that Hy Pressher uses ie "if I could solve this objection, would you buy the car?". However Honest John would add " ... provided that you are happy with the solution that I propose".

The difference between Hy Pressher and Honest John, is that although they are using the same tactics of making a customers first objection his last, Honest John does it ethically and gets buy-in on the subsequent solution. Honest John is an AI bot -- he learns as he goes to make a sale and make everyone happy. He keeps on getting better and changing for the better. Salesmen like Hy Pressher (and Willie Loman) don't want change, they want Swiss cheese on their meager after-work sandwiches.

The Third R in AI Chatbots - Rithmatic

Chatbots are pretty good at readin' and 'ritin'. But they are not good at the third "R" -- 'rithmatic. Artificial Intelligence Markup Language (AIML), the basis of a lot of chatbots, is good but not good enough for advanced chats. The language itself, based on XML, can have the facility for "smart substitutions". An example of a smart substitution in the markup pseudo-code goes like this:

<pattern><bot='name'/> IS* <pattern><template>Hello <aiml:get "name"/>

and the chatbot would say Hello Ken. But for a really smart chatbot, that is way too simplistic for anything but conversation.

If you have been following my articles, you know that I am coding a chatbot called Honest John that will sell new cars on behalf of a dealer. Not only will it chat, but it will negotiate. For applications like this, smart substitution is not enough. It has to be able to do math (or maths as my British friends say -- but what do they know, the just invented the language).

A smart bot must be able to substitute for x in the following ways:

"You want the car delivered on Tuesday? That is only <x; x<4;> day(s) away and I need a lead time of 4 days to deliver.
You offered me $34,500 for the vehicle. The offer price exceeds the maximum discount of $<x;x=(price-.06(price))> that I am allowed to offer you on that particular car.
Smart substitution cannot do math. Back in the day when I designed microprocessor hardware, we used to use a silicon chip called an ALU (or an Arithmetic Logic Unit) when we had an application that required a lot of math processing. The microprocessor would pass on the ciphering to the ALU if floating point operations were required. A smart chatbot needs the equivalent of a software ALU function.

An even smarter chatbot will have an AIML processor that will recognize tags with arithmetic expressions and hand them off to its own Arithmetic Logic Unit for processing. It will have a smart parser. This functionality is a required component for negotiation using numbers and money. The concept of a tag that invokes arithmetic will put some real brain muscle into Honest John.

The nice thing about introducing a calculating tag parser, is that once you do the framework for arithmetic expressions of tags (using a custom tag classes), you can create tags that do other things like logic expressions, matching, sorting and any other function that lends itself to be expressed in symbolic language in code. You could even create a tag that invokes an AI engine automagically.

Honest John's intelligence arsenal is really shaping up. He will be a force majeure among smart chatbots. After all, too many chatbots abuse the privilege of being stupid.