How to pass variables as context to IBM Cloud Watson Assistant with V2?











up vote
1
down vote

favorite












I am trying to use the new API version V2 for IBM Cloud Watson Assistant. Instead of sending a message for a workspace I need to send a message to an assistant. The context structure has global and skill-related sections now.



How would my app pass in values as context variables? Where in the structure would they need to be placed? I am using the Python SDK.
I am interested in sending information as part of client dialog actions.










share|improve this question
























  • What language are you using?
    – German Attanasio
    Nov 22 at 15:58










  • added info about Python SDK
    – data_henrik
    Nov 22 at 16:02










  • There seems to be an issue with the SDK where only 3 documented variables are sent as part of the context github.com/watson-developer-cloud/python-sdk/issues/597. The developer is looking at the problem but I don't think it will get fixed before Monday
    – German Attanasio
    Nov 22 at 16:05












  • I tried context->skills->main skill->user_defined and it seems to work
    – data_henrik
    Nov 22 at 16:08






  • 1




    @GermanAttanasio I updated my answer with complete cURL request and response for your reference - stackoverflow.com/questions/53404249/…
    – Vidyasagar Machupalli
    Nov 23 at 2:24

















up vote
1
down vote

favorite












I am trying to use the new API version V2 for IBM Cloud Watson Assistant. Instead of sending a message for a workspace I need to send a message to an assistant. The context structure has global and skill-related sections now.



How would my app pass in values as context variables? Where in the structure would they need to be placed? I am using the Python SDK.
I am interested in sending information as part of client dialog actions.










share|improve this question
























  • What language are you using?
    – German Attanasio
    Nov 22 at 15:58










  • added info about Python SDK
    – data_henrik
    Nov 22 at 16:02










  • There seems to be an issue with the SDK where only 3 documented variables are sent as part of the context github.com/watson-developer-cloud/python-sdk/issues/597. The developer is looking at the problem but I don't think it will get fixed before Monday
    – German Attanasio
    Nov 22 at 16:05












  • I tried context->skills->main skill->user_defined and it seems to work
    – data_henrik
    Nov 22 at 16:08






  • 1




    @GermanAttanasio I updated my answer with complete cURL request and response for your reference - stackoverflow.com/questions/53404249/…
    – Vidyasagar Machupalli
    Nov 23 at 2:24















up vote
1
down vote

favorite









up vote
1
down vote

favorite











I am trying to use the new API version V2 for IBM Cloud Watson Assistant. Instead of sending a message for a workspace I need to send a message to an assistant. The context structure has global and skill-related sections now.



How would my app pass in values as context variables? Where in the structure would they need to be placed? I am using the Python SDK.
I am interested in sending information as part of client dialog actions.










share|improve this question















I am trying to use the new API version V2 for IBM Cloud Watson Assistant. Instead of sending a message for a workspace I need to send a message to an assistant. The context structure has global and skill-related sections now.



How would my app pass in values as context variables? Where in the structure would they need to be placed? I am using the Python SDK.
I am interested in sending information as part of client dialog actions.







python ibm-cloud watson-conversation






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 22 at 16:02

























asked Nov 22 at 15:55









data_henrik

8,54021030




8,54021030












  • What language are you using?
    – German Attanasio
    Nov 22 at 15:58










  • added info about Python SDK
    – data_henrik
    Nov 22 at 16:02










  • There seems to be an issue with the SDK where only 3 documented variables are sent as part of the context github.com/watson-developer-cloud/python-sdk/issues/597. The developer is looking at the problem but I don't think it will get fixed before Monday
    – German Attanasio
    Nov 22 at 16:05












  • I tried context->skills->main skill->user_defined and it seems to work
    – data_henrik
    Nov 22 at 16:08






  • 1




    @GermanAttanasio I updated my answer with complete cURL request and response for your reference - stackoverflow.com/questions/53404249/…
    – Vidyasagar Machupalli
    Nov 23 at 2:24




















  • What language are you using?
    – German Attanasio
    Nov 22 at 15:58










  • added info about Python SDK
    – data_henrik
    Nov 22 at 16:02










  • There seems to be an issue with the SDK where only 3 documented variables are sent as part of the context github.com/watson-developer-cloud/python-sdk/issues/597. The developer is looking at the problem but I don't think it will get fixed before Monday
    – German Attanasio
    Nov 22 at 16:05












  • I tried context->skills->main skill->user_defined and it seems to work
    – data_henrik
    Nov 22 at 16:08






  • 1




    @GermanAttanasio I updated my answer with complete cURL request and response for your reference - stackoverflow.com/questions/53404249/…
    – Vidyasagar Machupalli
    Nov 23 at 2:24


















What language are you using?
– German Attanasio
Nov 22 at 15:58




What language are you using?
– German Attanasio
Nov 22 at 15:58












added info about Python SDK
– data_henrik
Nov 22 at 16:02




added info about Python SDK
– data_henrik
Nov 22 at 16:02












There seems to be an issue with the SDK where only 3 documented variables are sent as part of the context github.com/watson-developer-cloud/python-sdk/issues/597. The developer is looking at the problem but I don't think it will get fixed before Monday
– German Attanasio
Nov 22 at 16:05






There seems to be an issue with the SDK where only 3 documented variables are sent as part of the context github.com/watson-developer-cloud/python-sdk/issues/597. The developer is looking at the problem but I don't think it will get fixed before Monday
– German Attanasio
Nov 22 at 16:05














I tried context->skills->main skill->user_defined and it seems to work
– data_henrik
Nov 22 at 16:08




I tried context->skills->main skill->user_defined and it seems to work
– data_henrik
Nov 22 at 16:08




1




1




@GermanAttanasio I updated my answer with complete cURL request and response for your reference - stackoverflow.com/questions/53404249/…
– Vidyasagar Machupalli
Nov 23 at 2:24






@GermanAttanasio I updated my answer with complete cURL request and response for your reference - stackoverflow.com/questions/53404249/…
– Vidyasagar Machupalli
Nov 23 at 2:24














1 Answer
1






active

oldest

votes

















up vote
1
down vote



accepted










Based on testing the Python SDK and the API V2 using a tool, I came to the following conclusion. Context is provided by the assistant if it is requested as part of the input options.



  "context": {
"skills": {
"main skill": {
"user_defined": {
"topic": "some chatbot talk",
"skip_user_input": true
}
}
},
"global": {
"system": {
"turn_count": 2
}
}
}


To pass back values from my client / app to the assistant, I could use the context parameter. However, in contrast to the V1 API I needed to place the key / value pairs "down below" in the user_defined part:



context['skills']['main skill']['user_defined'].update({'mydateOUT':'2018-10-08'})


The above is a code snippet from this sample file for a client action. With that placement of my context variables everything works and I can implement client actions using the API Version 2.






share|improve this answer





















    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53434543%2fhow-to-pass-variables-as-context-to-ibm-cloud-watson-assistant-with-v2%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    1
    down vote



    accepted










    Based on testing the Python SDK and the API V2 using a tool, I came to the following conclusion. Context is provided by the assistant if it is requested as part of the input options.



      "context": {
    "skills": {
    "main skill": {
    "user_defined": {
    "topic": "some chatbot talk",
    "skip_user_input": true
    }
    }
    },
    "global": {
    "system": {
    "turn_count": 2
    }
    }
    }


    To pass back values from my client / app to the assistant, I could use the context parameter. However, in contrast to the V1 API I needed to place the key / value pairs "down below" in the user_defined part:



    context['skills']['main skill']['user_defined'].update({'mydateOUT':'2018-10-08'})


    The above is a code snippet from this sample file for a client action. With that placement of my context variables everything works and I can implement client actions using the API Version 2.






    share|improve this answer

























      up vote
      1
      down vote



      accepted










      Based on testing the Python SDK and the API V2 using a tool, I came to the following conclusion. Context is provided by the assistant if it is requested as part of the input options.



        "context": {
      "skills": {
      "main skill": {
      "user_defined": {
      "topic": "some chatbot talk",
      "skip_user_input": true
      }
      }
      },
      "global": {
      "system": {
      "turn_count": 2
      }
      }
      }


      To pass back values from my client / app to the assistant, I could use the context parameter. However, in contrast to the V1 API I needed to place the key / value pairs "down below" in the user_defined part:



      context['skills']['main skill']['user_defined'].update({'mydateOUT':'2018-10-08'})


      The above is a code snippet from this sample file for a client action. With that placement of my context variables everything works and I can implement client actions using the API Version 2.






      share|improve this answer























        up vote
        1
        down vote



        accepted







        up vote
        1
        down vote



        accepted






        Based on testing the Python SDK and the API V2 using a tool, I came to the following conclusion. Context is provided by the assistant if it is requested as part of the input options.



          "context": {
        "skills": {
        "main skill": {
        "user_defined": {
        "topic": "some chatbot talk",
        "skip_user_input": true
        }
        }
        },
        "global": {
        "system": {
        "turn_count": 2
        }
        }
        }


        To pass back values from my client / app to the assistant, I could use the context parameter. However, in contrast to the V1 API I needed to place the key / value pairs "down below" in the user_defined part:



        context['skills']['main skill']['user_defined'].update({'mydateOUT':'2018-10-08'})


        The above is a code snippet from this sample file for a client action. With that placement of my context variables everything works and I can implement client actions using the API Version 2.






        share|improve this answer












        Based on testing the Python SDK and the API V2 using a tool, I came to the following conclusion. Context is provided by the assistant if it is requested as part of the input options.



          "context": {
        "skills": {
        "main skill": {
        "user_defined": {
        "topic": "some chatbot talk",
        "skip_user_input": true
        }
        }
        },
        "global": {
        "system": {
        "turn_count": 2
        }
        }
        }


        To pass back values from my client / app to the assistant, I could use the context parameter. However, in contrast to the V1 API I needed to place the key / value pairs "down below" in the user_defined part:



        context['skills']['main skill']['user_defined'].update({'mydateOUT':'2018-10-08'})


        The above is a code snippet from this sample file for a client action. With that placement of my context variables everything works and I can implement client actions using the API Version 2.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 23 at 7:54









        data_henrik

        8,54021030




        8,54021030






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53434543%2fhow-to-pass-variables-as-context-to-ibm-cloud-watson-assistant-with-v2%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            What visual should I use to simply compare current year value vs last year in Power BI desktop

            How to ignore python UserWarning in pytest?

            Alexandru Averescu