Jump to content

How To: Forcing knowledgebase search before submitting ticket


Recommended Posts

Many of the support tickets I receive are already answered in the knowledgebase. In an attempt to eliminate these tickets and send the customer to the appropriate article I've implemented an additional search page before giving the customer the ability to open a support ticket. The search page utilizes MySQL fulltext indexes to bounce the customers question against the knowledgebase title to look for a match (or you can always use the article itself to match against).

 

If there are no matches or the customer's question isn't answered they can click on the normal support ticket link after the search to fill out their full information. If you don't wish to utilize the search page every time you may always use the direct ticket link in your template file(s).

 

You may wish to tweak the search query to use a different search method such as "in boolean mode" to change the order of results. You may also use the article content instead of the title, but this particular method works for me so far since implementation.

 

Example of my page: http://www.bargainvoice.com/smartsearch.php

 

Here's how I did it.

 

1) Create the fulltext index on your MySQL knowledgebase table.

create index smartsearch on tblknowledgebase fulltext(title);

 

2) Create the template file "smartsearch.tpl" in your template directory.

<div align="center"><b>If you need assistance or have a question please use the form below.</b></div><br/>

<form method="post" action="{$SERVER.PHP_SELF}" enctype="multipart/form-data">

<table cellspacing="1" cellpadding="0" class="frame">
<tr>
 <td>
  <table width="100%" cellpadding="2">
   <tr>
    <td class="fieldarea">Please enter your question, problem, or keywords.</td>
    <td><input type="text" name="subject" size="60" value="{$subject}" /></td>
   </tr>
   <tr><td colspan="2" class="fieldarea" style="text-align: center"><b>example questions:</b> <i>How do I cancel my account?</i> <b>or</b> <i>Control Panel</i> <b>or</b> <i>Where can I find my user information?</i></td></tr>
  </table>
 </td>
</tr>
</table>
<p align="center"><input type="submit" name="submit" value="Submit Question" /></p>
</form>
<br/>

{if $submit}
{if $kbResults}
<div align="center">
<b>Please review the following knowledgebase articles before submitting your ticket.</b><br/>
{foreach key=id item=dat from=$kbResults}
<a href="knowledgebase.php?action=displayarticle&catid={$kbResults.$id.category}&id={$kbResults.$id.id}">{$kbResults.$id.title}</a><br/>
{/foreach}
</div>
{else}
 <div align="center"><b>No results found for your search.</b></div>
{/if}
<br/><br/>
<div align="center" style="color: red;"><b>If you couldn't find your answer above you may <a href="submitticket.php">click here to submit a support ticket</a></b></div>
<br/>
{/if}

 

3) Create the file "smartsearch.php" in your main whmcs directory.

<?
require("dbconnect.php");
require("includes/functions.php");
require("init.php");
if ($submit) {
if ($subject) {
 $sql="select * from $db_name.tblknowledgebase where MATCH (title) AGAINST ('" . addslashes($subject) . "')";
 $tmpResults=mysql_query($sql);
 while ($row=mysql_fetch_array($tmpResults,MYSQL_ASSOC)) {
  $kbResults[]=$row;
 }
 $smarty->assign("kbResults",$kbResults);
}
$smarty->assign("submit",$submit);
}
$smarty->assign("subject",$subject);
$templatefile="smartsearch";
include("display.php");
?>

 

4) Next change the links in your template files that contain "submitticket.php" to "smartsearch.php" so the customer is now directed to the new search page.

 

You may have to change or alter some of the html to match your installation, the above code works for me. Hopefully all the files came across correctly in the post :)

Link to comment
Share on other sites

Error

query SQL:

 

CREATE INDEX smartsearch ON tblknowledgebase FULLTEXT (

title

)

-------------------------------------------------------------

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'fulltext(title)' at line 1

-------------------------------------------------------------

 

Solution?

MySQL version: 4.1.22-standard

 

Thanks

Link to comment
Share on other sites

jasonBV

 

I really hate you for posting this code :)

after i have seen it i went and tried to implement an instant responce when submitting a ticket from whmcs ticket system using your php code and javascript.

 

I worked 6 hours nonstop and not even 5 minutes break and i even forgot to eat because of you :)

 

it was really really hard but at the end i made it !

here are the results , there are only 3 articles in the database so you may get nothing but use the keywords

hosting perl limit to get all 3 results , enter the keywords in the text area of course any type it not copy and paste.

 

http://www.hosting777.com/clients/submitticket.php?step=2&deptid=002

 

what do you think guys?

Link to comment
Share on other sites

jasonBV

 

I really hate you for posting this code :)

after i have seen it i went and tried to implement an instant responce when submitting a ticket from whmcs ticket system using your php code and javascript.

 

I worked 6 hours nonstop and not even 5 minutes break and i even forgot to eat because of you :)

 

it was really really hard but at the end i made it !

here are the results , there are only 3 articles in the database so you may get nothing but use the keywords

hosting perl limit to get all 3 results , enter the keywords in the text area of course any type it not copy and paste.

 

http://www.hosting777.com/clients/submitticket.php?step=2&deptid=002

 

what do you think guys?

 

Really well done! Would be nice to see something like this make it into the release...

Link to comment
Share on other sites

jasonBV

 

I really hate you for posting this code :)

after i have seen it i went and tried to implement an instant responce when submitting a ticket from whmcs ticket system using your php code and javascript.

 

I worked 6 hours nonstop and not even 5 minutes break and i even forgot to eat because of you :)

 

it was really really hard but at the end i made it !

here are the results , there are only 3 articles in the database so you may get nothing but use the keywords

hosting perl limit to get all 3 results , enter the keywords in the text area of course any type it not copy and paste.

 

http://www.hosting777.com/clients/submitticket.php?step=2&deptid=002

 

what do you think guys?

 

WOW - That looks fantastic. To be honest, having that feature is one reason that I was tempted to move to Kayako. Any chance of sharing? :D

Link to comment
Share on other sites

joe123 - that indeed does look nice, and seems to work extremely well. The only problem I found was that it interferes with the browser history and makes it harder to go back, probably because the search is posting or a getting. Probably not much can be done about that, but it's a minor quibble.

Link to comment
Share on other sites

WOW - That looks fantastic. To be honest, having that feature is one reason that I was tempted to move to Kayako. Any chance of sharing? :D

 

Yes, I was considering going to Kayako just for this very feature! Thanks to both OP and Joe123. Joe123 are you going to share?

Link to comment
Share on other sites

Hello guys

 

I am so sorry i was away for a few days , and i had no idea this thread got so big , i see that many want this feature so i contacted matt asking him for a knowledgebase.php with a search function that searches for all words so i can integrate the code with the original file .

I hope he can give me such a file and as soon as i receive it (if i do) i will wrire the code and contribute Immediatelly.

Link to comment
Share on other sites

OK

I contacted matt and he said this is on there dev tracker already . so something similar will be included in the next release

 

If you have no patience then you can use my code !

 

TO get the files just send an email to

 

link AT hosting777.com

 

 

Enjoy it !

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated