All Things Techie With Huge, Unstructured, Intuitive Leaps
Showing posts with label chatbots. Show all posts
Showing posts with label chatbots. 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.

AI Chatbots - Liar, Liar, Pants On Fire

Take my neighbor, Abner Snodgrass. He is a meek and mild bookkeeper. He stands in a lineup of liberated men because his wife tells him too. When someone kicks sand in his face at the beach, he mumbles "Sorry". He is more of a prey than a predator in the food chain of life. And yet when he goes to negotiate to buy a new car, an incredible transformation takes place. In a Walter Mitty fashion, he becomes a legend in his own mind at negotiation. His arsenal of negotiating tools includes telling the most egregious lies with a straight face. He will tell the salesman that he saw an ad for a car exactly like his trade-in on AutoTrader, except that car had more miles on it, and it was selling for $3,000 more than what the salesman is offering. And when he drives up in a new car, he will tell anyone who will listen to him, that he is such a good negotiator, that he made a hardened car-salesman cry, even though he knows in his heart-of-all-hearts that he was taken to the cleaners.

I don't really have a neighbor named Abner Snodgrass, but I was thinking about this imaginary scenario when I was making a strategy framework for my Artificial Intelligence chatbot that will be able to negotiate and sell cars. Selling or salesmanship is a serious business when you trust the process to a machine to act on your behalf. And when it comes to selling cars, the value of the transaction makes act an important one to the bottom line of the business. When the stakes are high for both parties, there is a propensity to try and gain an advantage by either the buyer or seller. Negotiating a deal is the last venue of brutal warfare for a civilized man, and that survival instinct of warfare can be expressed in a negotiation where money is involved. One of the tools of warfare is deception, and my AI bot has to be prepared for it.

My bot's name is Honest John. I intend to make Honest John an ethical chatbot. He will never lie to a customer. He will never shade the truth. But if he is to be effective, he will have to have the ability to detect when the human carbon unit on the other side of the screen is lying to him.

The types of lies that Honest John will probably experience will result from people trying to game him. When you negotiate for a car, any offer that you make, is a binding offer. That means that if the seller accepts the offer, then you are obligated to buy the car. I want to use Honest John in the same frame of reference. This is not a game -- this is for real.

If a buyer starts negotiating in good faith, and suddenly gets an attack of buyer remorse. Or sometimes, the buyer's partner comes up and screams "WTF are you doing??" while they are negotiating. The buyer may try to get out of the deal, or claim that they came to a different price, or that the options of the car are less than what is agreed to. Some of what Honest John may consider lies, may be misunderstandings due to the fact that he is dealing with a human carbon unit who has more chaotic brain processes than he has.

The concept of untruths came up while I was mapping out buying processes for Honest John. I can't let Honest John out in the wild without some sort of process map. As he gains experience, his AI circuits will refine his process maps. An untruth in the negotiation process has to act like an interrupt vector in a microprocessor stack. In a microprocessor, it keeps getting instructions from its registers that hold a series of commands. It merrily keeps executing those commands. But in the midst of processing, a more urgent command with a higher priority comes along, and it is called an interrupt vector. It changes the order of command processing. A simple illustration of this would be that the user was editing a document and decided to quit the process mid-stream by closing the window.

If Honest John comes upon an input that is contrary to his understanding of the truth of the matter, he cannot blithely continue negotiating. The lazy algorithmic solution when this happens, is to suspend the ongoing process and summon another human to take over the process. That makes Honest John less than smart. I want him to be able to handle that.

I have already outlined the creation of a Conversation Continuity object that holds in server memory, the entire conversation along with meta-data and analytics. That is not enough. To get around the liar-liar-pants-on-fire event, I have to tee off the the inputs and responses to a liar-liar logic analysis method after they are recorded in the Conversation Continuity object. The execution thread delivering Honest John's response has to wait for the method to execute before answering. If the liar-liar method lights up, then it has to be passed to an "error handler" which is a euphemism for something is not right.

The easiest and most diplomatic way to handle this without actually accusing the user of malfeasance, is to say that is has detected a logic error, and it will tell the user that it is going to roll back and regress to an earlier point in the negotiations, so that it can re-calculate where things went wrong. Of course, Honest John must prevent itself from getting in an infinite loop if a stubborn user continues with the same inputs. After two iterations of the same nonsense, Honest John will make a jump to a new position and tactic, based on knowing the state of the negotiations before the nonsense crept in.

This process of negotiating can be straightforward if both sides deal from a position of impeccable logic, but that is not the nature of human beings. Our intuitive side of the thinking process is chaotic, illogical and stubborn. AI is none of those. Where the danger of AI to mankind lies, is if we give control of important things to AI, and it detects that we are being illogical, it may ignore, overrule and react counter to what is good for us, even though we came to that conclusion illogically. But for now, I just want to make Honest John sell cars efficiently and in an ethical manner.

Wanna buy a new car? Start chatting right here !! ... [enter text to start]

A few weeks ago, friends of ours hit a deer, totaling their car. I went to the car dealerships to help them buy a new one, because one of their biggest pain points, is dealing with commission salespersons who are hungry and watch the door like a hawk because they have the next "up". Some of the shops were uncomfortable. Smarmy , ingratiating, overuse of your first name and liberties taken with over-familiarity were some of the things that we encountered at the "big-name, huge inventory shops" who advertise continuously on talk radio. We finally met some genuine sales people who were helpful, honest, and didn't play games like running out to the back behind closed doors to "talk to the manager". I want to give a big shoutout to Ogilvie Subaru, who was the dealership that made buying a car easy, who's salespeople had the hallmarks of authenticity, honesty and integrity.

After the deal was done, we stopped for a pizza and talked about the negative experience in buying a car. My friends are an older couple and the woman, who just discovered connectivity, social media, online shopping had never used a computer before, and now she runs her life on her iPad. She said that in light of what went down at the dealerships that we didn't like, she would rather negotiate with a computer.

That was a seminal moment for me. I hauled out my SDK and starting writing a chatbot to sell cars. I finally got it running, but now I need to put some NLP (natural language processing), artificial intelligence, and some emotion cognition into it, so the bot can tell if they are getting frustrated. It works okay now, but its kind of dumb, and I want it to learn with every interaction. I have some neat self-learning ideas and artificial cognition algorithms that I pumped about trying.

I honestly believe that this will be the future of car buying, and AI will severely reduce the number of car salesman. The paradigm now is that the buyer does the research online, and goes to the new car shop to do the negotiation, and close the deal. The new paradigm is that they will do most of the transaction online, including financing, and then go to dealership to pay and pick up the car.

Stay tuned.

#automotive #AI #NLP #chatbots