Search code examples
phpcurlibm-cloudwatson-conversation

Watson Assistant CURL API: How to handle the Responds with OPTIONS?


I'm trying out IBM Watson Assistant. Ultimate goal is to integrate it with my custom PHP backend, via it's Watson Assistant's cURL API Endpoints (because there's no complete PHP SDK yet).

When I setup a Dialog with the OPTIONS (other than, TEXT) as the Respond, the OPTIONS are perfectly working inside it's own "Try it out" Chat Window. But when I query it through the cURL API as usual, everything else is working except for that Dialogs with OPTIONS.

Here's the working example inside Try it out Window:

enter image description here

But then, here's the return from cURL API (for the same question asked):

stdClass Object
(
    [intents] => Array
        (
            [0] => stdClass Object
                (
                    [intent] => SOexchangenetworks
                    [confidence] => 1
                )

        )

    [entities] => Array
        (
        )

    [input] => stdClass Object
        (
            [text] => Which Stack Exchange Network should I go to look for an answer?
        )

    [output] => stdClass Object
        (
            [text] => Array
                (
                )

            [nodes_visited] => Array
                (
                    [0] => node_1_1531885028865
                )

            [log_messages] => Array
                (
                )

        )

    [context] => stdClass Object
        (
            [conversation_id] => 77ec8fc6-fb6a-4890-92b4-c58cdbc85ba3
            [system] => stdClass Object
                (
                    [dialog_stack] => Array
                        (
                            [0] => stdClass Object
                                (
                                    [dialog_node] => root
                                )

                        )

                    [dialog_turn_counter] => 1
                    [dialog_request_counter] => 1
                    [branch_exited] => 1
                    [branch_exited_reason] => completed
                )

        )

)

Problem Highlight:

You can see that [output][text] section is totally blank, when the Dialog Respond contains OPTIONS.

Note: Normally, the [output][text] section contains the reply from Watson, if the Respond type is Text. I've been keep using this cURL API for a while.

How do I solve this please?


Solution

  • Based on the Watson Assistant release notes so called "rich responses" were added July 2018. The current API version is 2018-07-10. In your curl command you are using the API version 2018-02-16. Try the curl command again, but we the current API version.