Javascript code for generic business FAQ’s

On Facebook, and on websites in general, there are a lot of bots being used to answer the typical FAQ’s. These generally pop up when the website loads, or after browsing for a few minutes. And they also pop automatically into messenger on Facebook, prompting potential customers to ask any questions.

There are also bots that are fully classified as “chatbots” capable of having a longer more complex conversation with a human. To the point where many of them pass the Turin Test. These bots are able to determine the intent of the text inputted, and have some degree of AI to understand this. However, that is simply beyond my scope (at this point).

So instead, I have had a go at creating the Javascript code for generic business FAQ’s. I must point out, this business is not actually real 🙂

Here is the code:
for (i = 0; i < 15; i++) {
var hello= prompt("Hello. How can we help you today?");
var str = hello;
document.write(hello);
var a2=str.includes("time");
var a3=str.includes("are you open");
var a = str.includes("shipping");//
var b= str.includes("postage");//
var b1=str.includes("post");
var b2=str.includes("ship");
var c= str.includes("where are you");//
var d= str.includes("where is your company");//
var e= str.includes("location");//
var e1=str.includes("located");
var e2=str.includes("find you");
var f=str.includes("how much");//
var g= str.includes("cost");//
var i=str.includes("contact");//
var i2=str.includes("in touch");//
if((a2==true) || (a3==true))
{
var answer1="Our opening times are 9-5, Monday to Friday. Life's too short to work weekends!";
alert(answer1);
document.write(answer1);}
else if ((a==true)||(b==true)||(b1==true)||(b2==true))
{
var answer2="We only post to mainland UK. All of our products are posted with Royal Mail. The basic postage cost is £8 per parcel for guaranteed Next Day Delivery. If you require Saturday delivery, the cost is £12.";
alert(answer2);
document.write(answer2);
}
else if ((c==true)||(d==true)||(e==true)||(e1==true)||(e2==true))
{
var answer3="You can find us at number 5 Oxford Road Manchester, from 9-5 Monday to Friday.";
alert(answer3);
document.write(answer3);
}
else if ((f==true)||(g==true))
{
var answer4="You can find our entire product price list on our Facebook Page. For more information, why not give us a call?";
alert(answer4);
document.write(answer4);
}
else if ((i==true)||(i2==true))
{
var answer5="Give us a call at 1234 567 890";
alert(answer5);
document.write(answer5);
}
else
{
var answer6="Thanks for your message. We'll get back to you as soon as possible.";
alert(answer6);
document.write(answer6);
}
}

Essentially, this simple code works by finding certain words or phrases in the input, and matching these to an appropriate response.

A lot easier than answering those repetitive questions yourself!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s