Creating a Search Intent in Watson Assistant

If Watson Assistant doesn’t know how to answer a question, it can search your website for answers and provide suggestions. The pro version has built in support for WordPress search and Google search. If you are using the free version you can add you own search intent as follows:

  1. Go to the IBM Cloud Resource list
  2. Sign into you IBM Cloud Account
  3. Type “Watson” in the product column
  4. Click on the “AI / Machine Learning” dropdown
  5. Click on “Watson Assistant-mi” or the name of your Watson Assistant instance
  6. Click on the “Launch Watson Assistant” button
  7. Locate your Watson Assistant instance skill and click on it
  8. Click on your Dialog in the list
  9. Choose the “Dialogs” tab
  10. Locate and modify your “anything_else” node or create one, if not present
  11. To create a new node, click “Add Node”
  12. Enter “Anything else” in the node name field
  13. Click on “Enter condition” field and choose “anything_else” under common conditions
  14. Click “Customize”
  15. Click “Callout to webhook” and then Apply
  16. Click “Add parameter” and add “callType” and “websearch” as the key and value
  17. Click “Add parameter” and add “searchterm” and “<? input.text ?>” as the key and value
  18. Note the return variable displayed below the parameter section for use in the next step
  19. Verify that the return variable is displayed in the first “If assistant recognizes” spot and add the following line to the “Responds with” field, changing the webhook variable name as required: <? T(String).join(“, “, $webhook_result_X.get(‘Response’).![message]) ?>
  20. Choose “Options > Webhook” from the menu on the left
  21. Enter your webhook url under the “IBM Watson Assistant” tab on the “AI Chatbot > Settings” page
  22. Add the following code to your themes function file.
				
					function my_custom_chatbotcalls(){
if ( isset( $calltype ) && 'websearch' == $calltype ) {
&nbsp; &nbsp; &nbsp; &nbsp; $searchterm = sanitize_text_field( $body->searchterm );
&nbsp; &nbsp; &nbsp; &nbsp; if ( function_exists( 'ai_chatbot_easy_integration_strip_common_terms' ) ) {
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $searchterm = ai_chatbot_easy_integration_strip_common_terms( $searchterm );
&nbsp; &nbsp; &nbsp; &nbsp; }


&nbsp; &nbsp; if ( function_exists( 'ai_chatbot_easy_integration_lookup_wordpress_search_results' ) ) {
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $response = ai_chatbot_easy_integration_lookup_wordpress_search_results( $searchterm );
&nbsp; &nbsp; }
&nbsp; &nbsp; return $response;
}
add_filter( 'ai_chatbot_easy_integration_custom_calls', 'my_custom_chatbotcalls', 10, 3 );
				
			

Your chatbot should now return serach results from your website when it doesn’t know how to respond to a customer request.

Accessibility Tools
hide