0

I'm building a chatbot on Telegram with Watson Assistant and Node RED. I need to take a date and time from the user for booking an appointment, so I used a slot that require the insertion of the two information. Using the trial chatbot offered by Watson, I have no problem with slot; but using Node RED, I can't go beyond entering the date. Through the debug, I saw that after entering the date, then after running the first slot, this error is returned "msg.payload.content is empty". Moreover, going to see the body of the output message returned by the assistant, the msg.payload.output.generic field is empty. On the other hand, it should contain the response of the assistant who requests, after having entered the date, also to insert the time. It seems that the bot is stuck on entering the date, but in reality I don't think so, because in the trial chatbot, it works perfectly.

What could be the problem?

1 Answers1

0

Neither the Assistant V1 nor the V2 set or look at msg.payload.content. On input they look at msg.payload and on exit they assign the response from Watson Assistant to msg.payload.

If you are getting a "msg.payload.content" is empty error, then that will be happening somewhere in your flow. Most likely at the end where you are trying to process the response. If msg.payload.content is empty then the assistant dialog is not returning any output. This is strange as it should be returning the prompt for the currently empty slot.

What does msg.payload look like?

Are you using the V1 or the V2 node, and which version of node-red-node-watson nodes are you using? You can tell, by going to the palette.

Both V1 and V2 nodes, however, have been tested with slots, and the response does end up on msg.payload.content. Current released version of node-red-node-watson is 0.9.0.

chughts
  • 4,210
  • 2
  • 14
  • 27
  • Ok, now i found the reason of my problem, but i dont know how to fix it. The problem was that the bot sets a random session_id at every user's messages, so at every call I lost the context. I thought of generating a random session id at the beginning of the user interaction with the bot and save it into msg.params["session_id"], so it will used during that session. When the user insert the intent of #exit from the assistant, the system will generate a new session_id. do you think it's a correct strategy? or is there a better way to implement it? – iacopo pacifici Feb 07 '20 at 16:32
  • just in case, would you know how to generate a random session id? @chughts – iacopo pacifici Feb 07 '20 at 16:33
  • If you switch off the `multiple sessions` Option in the node’s configuration then the node manages the session for you, and you don’t need to pass it in. If you do want multiple sessions then you do need to feed back the session id that the node outputs on `msg.payload.session_id` – chughts Feb 07 '20 at 17:00
  • since i need multiple sessions, i thought a solution like yours, but i dont know how to take the msg.payload.session_id from the Watson Assistant node and pass the result to the block function that i create before this node to set the assistant. I tried with another block function that takes the session_id from the assistant with msg.sessionId = msg.payload.session_id; return msg; But when i pass this msg.sessionId to the msg.params["session_id"] the system loops, returning this error "msg.payload.chatId is empty". – iacopo pacifici Feb 07 '20 at 17:11
  • I am working on a fix to allow you to provide any string on `msg.params.session_id`, which the node then maps to the real session. I will allow a new field `msg.params.reset_session` to wipe out the node's map, and start clean. I am hoping to release 0.9.1 with the fix later today. I need to test running locally and in the cloud, before releasing. – chughts Feb 07 '20 at 19:41
  • I have just published V0.9.1 of the nodes. You can now use any string on msg.params.session_id, and the node will map that to the real session id. To create a new session use a new string. To reset a session send in `msg.params.reset_session` – chughts Feb 07 '20 at 20:37
  • Using any string as session_id, I obtain the error that URL session_id parameter is not a valid GUID. Is there any problem or must I first convert the string to a GUID? – iacopo pacifici Feb 08 '20 at 15:24
  • You need to upgrade your Watson nodes to the new release - 0.9.1 – chughts Feb 08 '20 at 16:31