1

I want to have a config page, where the user can setup the credentials of the Watson Assistant to use.

Actually, to setup the credentials, you need something similar to:

var assistant = new AssistantV1({
  username: process.env.ASSISTANT_USERNAME,
  password: process.env.ASSISTANT_PASSWORD,
  url: 'https://gateway.watsonplatform.net/assistant/api/',
  version: '2018-02-16',
});

and then you do:

assistant.message({
  input: { text: newMessageFromUser },
  workspace_id: process.env.WORKSPACE_ID,
  context : response.context,
}, processResponse)

Obviously, if on my config page the user chose to use another workpace with other IDs, I cannot do again the "const assistant = new AssistantV1" and do another new one with other credentials. I am looking into a way to pass them as parameters when someone changes the configuration on the config page.

In order to do so, is it possible to pass not only the workspace but also the username and password as parameters to assistant.message? If it is possible, how can I do it? What options do I have to change the username & password on the conversation invocation?

Thanks!

data_henrik
  • 16,724
  • 2
  • 28
  • 49
AndresG
  • 69
  • 6

1 Answers1

1

The message API is as specified. It works on an instantiated and configure Watson Assistant object.

In your case, you would need to (re-)initialize a new Watson Assistant instance with the user-provided username / password. Also note that Watson Assistant for authentication is moving away from username / password to IAM (Identity and Access Management) bearer token. You need to keep this in mind because not all users might be able to provide what you ask for.

data_henrik
  • 16,724
  • 2
  • 28
  • 49