How to trigger a specific node in IBM Watson Assistant from URL

705 views Asked by At

I have a website which links to a chatbot built on IBM Watson Assistant. There are some hyperlinks on the website that I want to trigger specific nodes/ intents the watson dialog.

Example: User clicks on "Provide feedback" link, the watson chatbot launches and based on the link the "provide_feedback" intent is recognised (thus preventing the user from needing to specify the intent after clicking the link).

Has anyone tried this before?

2

There are 2 answers

0
data_henrik On

The Watson Assistant service basically is used via a REST API. That API is invoked from the "Try it" pane in the workspace editor, from your dedicated application or maybe from widgets embedded into a website. The message call is used to send user input to Watson Assistant and to receive a chatbot response.

What you can do is to call the message API from your app and pass a specific term as input message. That term would match an intent and hence trigger a specific dialog node. As an example, if you have an intent "provide_feedback" defined for the phrase "user pressed feedback button" and you pass in exactly that phrase as input message, then the intent "provide_feedback" will match.

0
TVK On

I also came across this requirement and want to mention another alternative here:

Instead of sending an input text that matches the intent of your desired node, you can also pass

Intents to use when evaluating the user input.doc

and tell the assistant to match it with confidence of 1.0.

I think this is a clean method, because you don't need to deal with disambiguation of your input text. Then you don't need to send input text at all and the intent actually does not even need example phrases :-)

For example if you want to trigger a node that has the intent #provide_feedback

you can call this python example code:

send_message_to_chatbot(text="", intent="provide_feedback")

def send_message_to_chatbot(text="", intent=""):
    message = assistant.message(
        assistant_id=ASSISTANT_ID,
        session_id=SESSION_ID,
        input=MessageInput(
            text=text,
            intents=[RuntimeIntent(intent=intent, confidence=1.0)]
        )            
    ).get_result()

    return message

Prerequisite is of course that the node is in the root branch of your dialog so it can be triggered.