Javascript 根据Watson Assistant上下文自动加载网页

Javascript 根据Watson Assistant上下文自动加载网页,javascript,ibm-watson,watson-conversation,Javascript,Ibm Watson,Watson Conversation,我正试图让一个应用程序根据沃森助手对话中的上下文编排特定的网页 我使用的文件是github()上Watson Assistant(中间)示例文件的编辑 下面是我为实现这一点而编辑的代码片段(在api.js中): var http = new XMLHttpRequest(); http.open('POST', messageEndpoint, true); http.setRequestHeader('Content-type', 'application/json'); http.onrea

我正试图让一个应用程序根据沃森助手对话中的上下文编排特定的网页

我使用的文件是github()上Watson Assistant(中间)示例文件的编辑

下面是我为实现这一点而编辑的代码片段(在api.js中):

var http = new XMLHttpRequest();
http.open('POST', messageEndpoint, true);
http.setRequestHeader('Content-type', 'application/json');
http.onreadystatechange = function() {
  if (http.readyState === 4 && http.status === 200 && http.responseText) {
    Api.setResponsePayload(http.responseText);

var json = JSON.parse(http.responseText);
        context = json.context;

          if(json.context.action === 'SocialMedia') {

          document.getElementById("payload-column").setAttribute("style", "background-color: #ffffff;") //renders background white as without this line the webpage comes back with black hidden text for some reason
          document.getElementById("payload-column").setAttribute("src", "https://www.csc2.ncsu.edu/faculty/healey/tweet_viz/tweet_app/?q=" + json.context.AnalysisSearchItem);

          } 
Watson Assistant工作区内的相应配置为:

{
  "context": {
    "action": "SocialMedia"
  },
  "output": {
    "text": {
      "values": [
        "Loading sentiment analysis from the Computer Science department of North Carolina State University..."
      ],
      "selection_policy": "sequential"
    }
  }
}
我连接到Watson Assistant工作区,因为正常的聊天机器人对话正常工作

document.getElementById("payload-column").setAttribute("src", "https://www.csc2.ncsu.edu/faculty/healey/tweet_viz/tweet_app/?q=" + json.context.AnalysisSearchItem);
行本身确实会将iframe更改为我想要的网站(我在index.html文件中定义了一个iframe),这只是IF条件

if(json.context.action === 'SocialMedia') 
当上下文位于SocialMedia下时,不会成功执行

如果有人能帮助解决这个问题,我将不胜感激