jasonBV
05-18-08, 02:06 AM
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={$kb Results.$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 :)
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={$kb Results.$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 :)