<commit_before># Jovo Output Object

Learn more about the Jovo `$output` object.

* [Introduction](#introduction)
* [Output Structure](#output-structure)
* [platform.output Middleware](#platformoutput-middleware)


## Introduction

The Jovo `$output` is a consolidated JSON object that prepared during [routing](../routing '../routing') , and later turned into a response in the [`platform.output` Middleware](#platformoutput-middleware).

You can access the object like this:

```js
this.$output
```

If you log it after calling the [`tell` method](./README.md#tell '../#tell'):

```js
this.tell('Hello World!');
console.log(this.$output);
```

The logs for the `$output` object look like this:

```js
{ 
  tell: { 
    speech: 'Hello World!' 
  } 
}
```

And the generated response would be the following:

```js
// @platform=Alexa
{
	"version": "1.0",
	"response": {
		"shouldEndSession": true,
		"outputSpeech": {
			"type": "SSML",
			"ssml": "<speak>Hello World!</speak>"
		}
	},
	"sessionAttributes": {}
}

// @platform=Google Assistant
{
	"fulfillmentText": "Hello World!",
	"outputContexts": [
		{
			"name": "projects/<project-id>/agent/sessions/<session-id>/contexts/google_assistant_welcome"
		},
		{
			"name": "projects/<project-id>/agent/sessions/<session-id>/contexts/actions_capability_screen_output"
		},
		{
			"name": "projects/<project-id>/agent/sessions/<session-id>/contexts/actions_capability_audio_output"
		},
		{
			"name": "projects/<project-id>/agent/sessions/<session-id>/contexts/google_assistant_input_type_keyboard"
		},
		{
			"name": "projects/<project-id>/agent/sessions/<session-id>/contexts/actions_capability_web_browser"
		},
		{
			"name": "projects/<project-id>/agent/sessions/<session-id>/contexts/actions_capability_media_response_audio"
		}
	],
	"payload": {
		"google": {
			"expectUserResponse": false,
			"richResponse": {
				"items": [
					{
						"simpleResponse": {
							"ssml": "<speak>Hello World!</speak>"
						}
					}
				]
			},
			"userStorage": "{\"userId\":\"<user-id>\"}"
		}
	}
}
```
<commit_msg>🔀 Merge pull request #508 from simonrevill/patch-2<commit_after># Jovo Output Object

Learn more about the Jovo `$output` object.

* [Introduction](#introduction)
* [Output Structure](#output-structure)
* [platform.output Middleware](#platformoutput-middleware)


## Introduction

The Jovo `$output` is a consolidated JSON object that prepared during [routing](../routing '../routing') , and later turned into a response in the [`platform.output` Middleware](#platformoutput-middleware).

You can access the object like this:

```js
this.$output
```

If you log it after calling the [`tell` method](./README.md#tell '../#tell'):

```js
this.tell('Hello World!');
console.log(this.$output);
```

The logs for the `$output` object look like this:

```js
{ 
  tell: { 
    speech: 'Hello World!' 
  } 
}
```

And the generated response would be the following:

```js
// @platform=Alexa
{
	"version": "1.0",
	"response": {
		"shouldEndSession": true,
		"outputSpeech": {
			"type": "SSML",
			"ssml": "<speak>Hello World!</speak>"
		}
	},
	"sessionAttributes": {}
}

// @platform=Google Assistant
{
	"fulfillmentText": "Hello World!",
	"outputContexts": [
		{
			"name": "projects/<project-id>/agent/sessions/<session-id>/contexts/google_assistant_welcome"
		},
		{
			"name": "projects/<project-id>/agent/sessions/<session-id>/contexts/actions_capability_screen_output"
		},
		{
			"name": "projects/<project-id>/agent/sessions/<session-id>/contexts/actions_capability_audio_output"
		},
		{
			"name": "projects/<project-id>/agent/sessions/<session-id>/contexts/google_assistant_input_type_keyboard"
		},
		{
			"name": "projects/<project-id>/agent/sessions/<session-id>/contexts/actions_capability_web_browser"
		},
		{
			"name": "projects/<project-id>/agent/sessions/<session-id>/contexts/actions_capability_media_response_audio"
		}
	],
	"payload": {
		"google": {
			"expectUserResponse": false,
			"richResponse": {
				"items": [
					{
						"simpleResponse": {
							"ssml": "<speak>Hello World!</speak>"
						}
					}
				]
			},
			"userStorage": "{\"userId\":\"<user-id>\"}"
		}
	}
}
```

If you are reading the logs returned from the server (e.g. AWS CloudWatch), you can use the [`JSON.stringify()`] method to turn the object into a human-readable JSON string response:

```js
this.tell('Hello World!');
console.log(JSON.stringify(this.$output, null, 4));

// Output:
{ 
    "tell": { 
        "speech": "Hello World!"
    } 
}
```

{'fraction_non_alphanumeric': 0.180527833222444, 'fraction_numerical': 0.001996007984031936, 'mean_word_length': 4.039106145251397, 'pattern_counts': {'":': 50, '<': 37, '<?xml version=': 0, '>': 37, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '348971', 'n_tokens_mistral': 1744, 'n_tokens_neox': 1546, 'n_words': 304}