0

In Watson-conversation one of the first things I do is asking the user an Id. I receive that in python and check in a simple db I have if the id exists there (it is quite a simple logic).

Now, what I want is to jump to Node 1 if the user does not exist in my db. So I was looking for something in python to do so, as Watson cannot check my db.

I have been looking at several info. this was the most usefull, but I searched for more.

It also looked interesting to me to look for slots and handlers, but again, that cannot check in my simple database.

I was expecting something like this:

  • Node 1: asking id
  • If id exists then:
  • Node 2: Hi $name! blah blah blah
  • but if id does not exist Jump to Node 1.

I have made a simple function so as to understand what I want to do:

def checkingId(bot, update):
    message=update.message.text #let's suppose it is already parsed, to make it simpler
    result=cursor.execute("select name from users where id=message")

    if(result!=None): #so if the id exists in the table
        #no problem here, keep it going like normal watson would do
                whatever()

    else:
        jumpToNode1InWatson (???)

I have also seen that there might be this parameter dialog_node": "node1 or whatever it is" in the json(?), so I may access this via python, but I have not found anything relevant about it.

source of that

Thanks in advance. If you think the question can be edited to improve it, comment it and I'll try my best to do so.

Louis Storming
  • 151
  • 1
  • 10

1 Answers1

2

This IBM Cloud solution tutorial for a database-driven chatbot has code to interact with a DB from Watson Assistant. The related GitHub repo shows it for Db2 and PostgreSQL. It is done via an IBM Cloud Functions action. The other option is to use a client-side dialog action.

Now, once you checked for the ID you would set a variable. In a dialog tree you could then have the condition that the ID is present or has a certain value to process a dialog node or switch into that branch of the dialog tree. Thus, you would force Watson Assistant into your intended processing.

data_henrik
  • 16,724
  • 2
  • 28
  • 49
  • 1
    Essentially you can use the Assistant Dialog to switch to the appropriate node, by having your application set context variables and/or the input text, to force a node match or trigger an appropriate digression. – chughts Feb 13 '19 at 15:04
  • Thanks a lot Henrik! I have also though about something: in the end, as I am implementing a telegram-watson communication, I thought that not all that the user sends from telegram, needs to be passed to watson. I can do some cleaning and checks, and set a variable! And also the other way around, not everything watson responds must be sent to the user via TL, as I can clean and do some checks before doing so! But I'll be taking a look at that, as it looks much cleaner! – Louis Storming Feb 15 '19 at 08:32
  • @chughts The problem is how to force the node when you cannot pass to watson the id after it is checked! But I think I figured it out. If you already have the conversational design, you can "force" by cleaning and checking the data, doing stuff inside, and then responding! – Louis Storming Feb 15 '19 at 08:34
  • Check out Botkit and botkit middleware for Watson Assistant: https://github.com/watson-developer-cloud/botkit-middleware for inspiration or for direct use – data_henrik Feb 15 '19 at 14:20