Repository: rasahq/rasa
Issue: DialogFlow emulator response does not match API

**Rasa NLU version**: latest

**Issue**:

In the DF response there is key named `metaData` where the intent with the highest score gets placed. The issue is that rasa returns an object for `intentName` rather than what it should be, a string.

```
...
"metadata": {
  "intentId": "4b19212c-d89f-11e8-ab9d-fe4417299557",
  "webhookUsed": "false",
  "intentName": {
    "name": "welcome.greeting",
    "confidence": 0.9680702090263367
  }
},
...
```

https://github.com/RasaHQ/rasa_nlu/blob/master/rasa_nlu/emulators/dialogflow.py#L49

According to DialogFlow, this key should just be a string:
```
...
"metadata": {
  "intentId": "4b19212c-d89f-11e8-ab9d-fe4417299557",
  "webhookUsed": "false",
  "intentName": "welcome.greeting"
},
...
```

Solution:

In [the emulator](https://github.com/RasaHQ/rasa_nlu/blob/master/rasa_nlu/emulators/dialogflow.py) we set `result.action` and `result.metadata.intentName` to the intent, and `result.score` the intent confidence like I have below:

```python
"id": str(uuid.uuid1()),
"timestamp": datetime.now().isoformat(),
"result": {
  "source": "agent",
  "resolvedQuery": data["text"],
  "action": data["intent"]["name"],
  "actionIncomplete": None,
  "parameters": entities,
  "contexts": [],
  "metadata": {
     "intentId": str(uuid.uuid1()),
     "webhookUsed": "false",
     "intentName": data["intent"]["name"]
   },
   "fulfillment": {},
   "score": data["intent"]["confidence"],
 },
 ...
```

Changing the response to something other than the DialogFlow API returns breaks functionality. Currently I am writing a Rasa SDK that utilizes the C# ApiAiSdk model [Metadata](https://github.com/dialogflow/dialogflow-dotnet-client/blob/master/ApiAiSDK/Model/Metadata.cs#L25) for deserializing the response. As you can see, the member `IntentName` is a string.

If this seems like a valid solution I can make the change, write tests, and open a PR.

Thank you.

Changed files:
tests/base/test_emulators.py, rasa_nlu/emulators/dialogflow.py

diff --git a/rasa_nlu/emulators/dialogflow.py b/rasa_nlu/emulators/dialogflow.py
index ed456a89d49..8e4e88e4f9f 100644
--- a/rasa_nlu/emulators/dialogflow.py
+++ b/rasa_nlu/emulators/dialogflow.py
@@ -39,17 +39,17 @@ class DialogflowEmulator(NoEmulator):
             "result": {
                 "source": "agent",
                 "resolvedQuery": data["text"],
-                "action": None,
-                "actionIncomplete": None,
+                "action": data["intent"]["name"],
+                "actionIncomplete": False,
                 "parameters": entities,
                 "contexts": [],
                 "metadata": {
                     "intentId": str(uuid.uuid1()),
                     "webhookUsed": "false",
-                    "intentName": data["intent"]
+                    "intentName": data["intent"]["name"]
                 },
                 "fulfillment": {},
-                "score": None,
+                "score": data["intent"]["confidence"],
             },
             "status": {
                 "code": 200,
diff --git a/tests/base/test_emulators.py b/tests/base/test_emulators.py
index 8d4926a831c..379f5637dd4 100644
--- a/tests/base/test_emulators.py
+++ b/tests/base/test_emulators.py
@@ -125,16 +125,13 @@ def test_dialogflow_response():
     assert norm == {
         "id": norm["id"],
         "result": {
-            "action": None,
-            "actionIncomplete": None,
+            "action": data["intent"]["name"],
+            "actionIncomplete": False,
             "contexts": [],
             "fulfillment": {},
             "metadata": {
                 "intentId": norm["result"]["metadata"]["intentId"],
-                "intentName": {
-                    "confidence": data["intent"]["confidence"],
-                    "name": data["intent"]["name"]
-                },
+                "intentName": data["intent"]["name"],
                 "webhookUsed": "false"
             },
             "parameters": {
@@ -143,7 +140,7 @@ def test_dialogflow_response():
                 ]
             },
             "resolvedQuery": data["text"],
-            "score": None,
+            "score": data["intent"]["confidence"],
             "source": "agent"
         },
         "sessionId": norm["sessionId"],