# Deploy Watson AI (with option response function) in Node-RED

**URL:** <https://discourse.nodered.org/t/deploy-watson-ai-with-option-response-function-in-node-red/29424>\
**Category:** General\
**Created:** [3 July 2020 05:11 UTC](https://discourse.nodered.org/t/deploy-watson-ai-with-option-response-function-in-node-red/29424 "2020-07-03T05:11:51Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![abhayssaini](https://avatars.discourse-cdn.com/v4/letter/a/c37758/32.png) [@abhayssaini](https://discourse.nodered.org/u/abhayssaini)\
**Post date:** [3 July 2020 05:11 UTC](https://discourse.nodered.org/t/deploy-watson-ai-with-option-response-function-in-node-red/29424/1 "2020-07-03T05:11:52Z")

</div>

Hello,

I'm using watson assistant were i have created a skill and in that i have used "option response". so i am deploying it in node-RED.

 ![Capture](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/4/143a622e3f77f17e31313e1e80debd73b12ee265.jpeg)

The problem is that in UI when watson interact with user upto when its not came up with "option response" but when watson has to response with option functionality then it's not showing any option!

 ![Capture2](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/3/63a33e5eadaa94425e6873f6178ddeb9871a6900.jpeg)

as you can see here watson asked for email address and then next watson reply has to be in "option response" but its not showing.....

in function 1 node code is :-

msg.payload = msg.payload.text;  
return msg;

in function 2 node code is :-

msg.payload = msg.payload.output.text[0];  
return msg;

in form node :-

 ![Capture4](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/a/ca48b5d7c6c2583bd5ae0677ef1e7fc9af82ab22.jpeg)

I tried to explain my problem as clear as i can. please! please! help me out with that.  
if i have used less nodes or whatever it is please let me know.  
Thank you.

i want to show, output from watson in (try it section) has to show like this :-

![Capture3](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/b/3b16ab8f20e42f718fe85a90b323a79f9e6ca653.jpeg)

when i tried typing this code in function node 2 :

msg.payload =payload

then in debug node at that point where watson has to option response is like that

 ![Capture5](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/5/85bb49938083d8d3ee0766f14879f77652e4bd1d.jpeg)

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [3 July 2020 07:30 UTC](https://discourse.nodered.org/t/deploy-watson-ai-with-option-response-function-in-node-red/29424/2 "2020-07-03T07:30:27Z")

</div>

Hi,

in your Function 2 code, you are getting the value of `msg.payload.output.text[0]`

The Debug output you've shared shows `msg.payload.output.text` is empty - it doesn't have any text for you to display.

You need to construct the text from:

`msg.output.generic[0].title` gives you `"Thank you. what type of job...."`

`msg.output.generic[0].options` is an array with the individual options in it - each has a `label` property that you would display and `value` object (although your screenshot doesn't show what is in that object, and I don't know the Watson Assistant api to say what it would be expecting).

---

<div class="post-metadata">

**Author:** ![abhayssaini](https://avatars.discourse-cdn.com/v4/letter/a/c37758/32.png) [@abhayssaini](https://discourse.nodered.org/u/abhayssaini)\
**Post date:** [3 July 2020 08:56 UTC](https://discourse.nodered.org/t/deploy-watson-ai-with-option-response-function-in-node-red/29424/3 "2020-07-03T08:56:08Z")

</div>

> [@knolleary](#):
>
> in your Function 2 code, you are getting the value of `msg.payload.output.text[0]`

if i not used .text[0] then output is coming under brackets from watson reply..

> [@knolleary](#):
>
> You need to construct the text from:
> 
> `msg.output.generic[0].title` gives you `"Thank you. what type of job...."`
> 
> `msg.output.generic[0].options` is an array with the individual options in it - each has a `label` property that you would display and `value` object

you mean like this in function 2 node -

 ![Capture6](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/e/6ed4fe596411ee48b7f465b9e1658ea21794c24a.jpeg)

> [@knolleary](#):
>
> (although your screenshot doesn't show what is in that object, and I don't know the Watson Assistant api to say what it would be expecting).

ohke -

 ![Capture7](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/0/402596261523fad835d79d473621066714a9ee12.jpeg)

here watson Assistant (i trained it ) works as a AI recruiter and he is asking for Email address from the user! after giving the email. watson have to reply with 3 option box along with ("thank you... what type......." ) as i shared a screenshot above in IBM watson try it section...

so that reply is not coming in node-red UI..  
i think now u get it !

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [3 July 2020 09:02 UTC](https://discourse.nodered.org/t/deploy-watson-ai-with-option-response-function-in-node-red/29424/4 "2020-07-03T09:02:56Z")

</div>

> [@abhayssaini](#):
>
> you mean like this in function 2 node -

Sort of - that will only give you the value of `payload.output.generic[0].options[0].label`.

If you want to include all the other bits, you'll need to build up a string containing the text you want.

---

<div class="post-metadata">

**Author:** ![abhayssaini](https://avatars.discourse-cdn.com/v4/letter/a/c37758/32.png) [@abhayssaini](https://discourse.nodered.org/u/abhayssaini)\
**Post date:** [3 July 2020 09:10 UTC](https://discourse.nodered.org/t/deploy-watson-ai-with-option-response-function-in-node-red/29424/5 "2020-07-03T09:10:04Z")

</div>

"i think the nodes which i had used are not capable of watson to show output in option response!"  
my main problem is that 👆  
what i want to tell you is, i want the output in Node-red UI like this 👇

 ![Capture8](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/6/16bc55b60274819ae938bcdbdd7edb437d267b93.jpeg)

now you got it or not!?

i want these 3 option format response in UI.....

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [3 July 2020 09:13 UTC](https://discourse.nodered.org/t/deploy-watson-ai-with-option-response-function-in-node-red/29424/6 "2020-07-03T09:13:59Z")

</div>

There is no pre-built dashboard UI component for doing chat dialogs like that (although it is one I've considered making, just not got around to it).

You'd need to build it up yourself using a ui\_template node with some custom HTML and JavaScript to draw the messages.

I understand that isn't as helpful a response as it could be, but I simply don't have a prebuilt example of a chat dialog I can point you at. Maybe someone else has...

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [4 July 2020 10:01 UTC](https://discourse.nodered.org/t/deploy-watson-ai-with-option-response-function-in-node-red/29424/8 "2020-07-04T10:01:26Z")

</div>

@abhayssaini - please don't DM (direct message) people asking for help - as you did to me. If I could help you I would have replied on this thread.

---

<div class="post-metadata">

**Author:** ![abhayssaini](https://avatars.discourse-cdn.com/v4/letter/a/c37758/32.png) [@abhayssaini](https://discourse.nodered.org/u/abhayssaini)\
**Post date:** [4 July 2020 11:58 UTC](https://discourse.nodered.org/t/deploy-watson-ai-with-option-response-function-in-node-red/29424/9 "2020-07-04T11:58:01Z")

</div>

ok,got it.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [2 September 2020 12:04 UTC](https://discourse.nodered.org/t/deploy-watson-ai-with-option-response-function-in-node-red/29424/10 "2020-09-02T12:04:15Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
