<commit_before>The Alexa Web Service simply handles the JSON requests and responses that constitute an Alexa "Skill."
For general information on create an Alexa skill as a web service, look here:
https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/alexa-skills-kit-interface-reference#Introduction



####AlexaRequest: Verify and parse the request from Alexa.####

Alexa will send your web service (aka your "skill") JSON in an HTTP POST request, like so:

````Ruby
{
  "session": {
    "sessionId": "SessionId.abc12d34-12ab-1abc-111-a12c3456d7ef9",
    "application": {
      "applicationId": "amzn1.echo-sdk-ams.app.xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
    },
    "attributes": {},
    "user": {
      "userId": "amzn1.account.AHHLP<KEY>"
    },
    "new": true
  },
  "request": {
    "type": "LaunchRequest",
    "requestId": "EdwRequestId.xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
    "timestamp": "2016-06-17T21:07:57Z",
    "locale": "en-US"
  },
  "version": "1.0"
}
````

The framework will automatically verify that the request comes from Amazon, and check the signature and timestamp of the request, as outlined [here]('https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/developing-an-alexa-skill-as-a-web-service') 

It will also automatically create an instance of the AlexaRequest class just to provide some convenience methods for handling the JSON request:

````Ruby
@echo_request.intent_name 
@echo_request.slots
@echo_request.slots.myslot
@echo_request.launch_request
@echo_request.intent_request
@echo_request.session_ended_request
@echo_request.session_new?
````

Your skill works by providing Alexa with different responses depending on the the type/name/slot values of the request: 

````Ruby
if @echo_request.launch_request
  # have alexa say hello
end
````

(Take a look at eight_ball.rb for some further examples.)




####AlexaResponse:  Respond to user requests.####

The AlexaResponse class provides the proper JSON to make Alexa responses.

Create a new response object:

````response = AlexaObjects::Response.new````

Then, define the response attributes:

````Ruby
response.end_session = true
response.spoken_response = "This is what Alexa will say to you"
response.reprompt_text = "This is what she'll say if she doesn't hear your response the first time."
````

You can then send the response back to Alexa with the following command:<commit_msg>typos<commit_after>The Alexa Web Service simply handles the JSON requests and responses that constitute an Alexa "Skill."
For general information on creating an Alexa skill as a web service, look here:
https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/alexa-skills-kit-interface-reference#Introduction



####AlexaRequest: Verify and parse the request from Alexa.####

Alexa will send your web service (aka your "skill") JSON in an HTTP POST request, like so:

````Ruby
{
  "session": {
    "sessionId": "SessionId.abc12d34-12ab-1abc-111-a12c3456d7ef9",
    "application": {
      "applicationId": "amzn1.echo-sdk-ams.app.xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
    },
    "attributes": {},
    "user": {
      "userId": "amzn1.account.AHHLP<KEY>"
    },
    "new": true
  },
  "request": {
    "type": "LaunchRequest",
    "requestId": "EdwRequestId.xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
    "timestamp": "2016-06-17T21:07:57Z",
    "locale": "en-US"
  },
  "version": "1.0"
}
````

The Alexa Web Service framework will automatically verify that the request comes from Amazon, and check the signature and timestamp of the request, as outlined [here]('https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/developing-an-alexa-skill-as-a-web-service') 

It will also automatically create an instance of the AlexaRequest class just to provide some convenience methods for handling the JSON request:

````Ruby
@echo_request.intent_name 
@echo_request.slots
@echo_request.slots.myslot
@echo_request.launch_request
@echo_request.intent_request
@echo_request.session_ended_request
@echo_request.session_new?
````

Your skill works by providing Alexa with different responses depending on the the type/name/slot values of the request: 

````Ruby
if @echo_request.launch_request
  # have alexa say hello
end
````

(Take a look at eight_ball.rb for some further examples.)




####AlexaResponse:  Respond to user requests.####

The AlexaResponse class generates the proper JSON to make Alexa responses.

Create a new response object:

````response = AlexaObjects::Response.new````

Then, define the response attributes:

````Ruby
response.end_session = true
response.spoken_response = "This is what Alexa will say to you"
response.reprompt_text = "This is what she'll say if she doesn't hear your response the first time."
````

You can then send the response back to Alexa with the following command:
{'fraction_non_alphanumeric': 0.11406217829936174, 'fraction_numerical': 0.014823965410747375, 'mean_word_length': 4.622685185185185, 'pattern_counts': {'":': 28, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 8, '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': '5669220', 'n_tokens_mistral': 1604, 'n_tokens_neox': 1432, 'n_words': 474}