Star InactiveStar InactiveStar InactiveStar InactiveStar Inactive

I need a nice looking and easy to use date and time selector. I didn't want to use a drop down for the time because it just feels kludgy and old. I opted for a clock shape analog with hours. Once you select your hour it changes the hours to 5 minute intervals. The am/pm select is in the middle. The standard JQuery datepicker is used to select the date but in a static way. All this opens in a dialog. Please not this does multiples of 5 for minutes (0, 5, 10, 15, etc.). This opens in a dialog and needs JQuery to work. Another piece of functionality I added was to have the dialog set 2 form elements; 1 textbox with a nice formatted date and 1 hidden with a MySQL date.

For the file go to https://github.com/mrosandich/slickDTP

Quick Example: https://www.ourace.com/code_examples/slickDTP/index.html

 

User Rating: 4 / 5

Star ActiveStar ActiveStar ActiveStar ActiveStar Inactive

This is my Helloworld for interacting with the amazon echo.

I packed it into one file. i'm not a big fan of samples being weighed down by includes (unless it calls for it).

In this example. Say your phrase: Alexa start Count Example

The echo will respond by saying the phrase "Welcome to the Our Ace count example say next item" and sending you a card in your echo app

 The echo light will stay on and wait for you to say "next item" or "next"

When you say next it will count up by 1 using the session attributes in the json. You pass it json attributes and it passes them back

say next item until it hits five then it will quit. The light will go off on your echo.

Please note: you have to access you developer portal and set up your URL web service and SSL settings. Also, make sure your echo is using your developer email. If not setup another user on your echo and switch profiles to your developer account.

 your dev setup area is here dev aw

 Intent Schema:

{
  "intents": [
    {
      "intent": "quit",
      "slots": []
    },
    {
      "intent": "next",
      "slots": []
    }
  ]
}

 

 

 Sample Utterances

 next item

 

Below is the PHP code.

$EchoJArray = json_decode(file_get_contents('php://input'));
$RequestType = $EchoJArray->request->type;



$JsonOut 	= GetJsonMessageResponse($RequestType,$EchoJArray);
$size 		= strlen($JsonOut);
header('Content-Type: application/json');
header("Content-length: $size");
echo $JsonOut;

//-----------------------------------------------------------------------------------------//
//					     Some functions
//-----------------------------------------------------------------------------------------//

//This function returns a json blob for output
function GetJsonMessageResponse($RequestMessageType,$EchoJArray){

	$RequestId = $EchoJArray->request->requestId;
	$ReturnValue = "";
	
	if( $RequestMessageType == "LaunchRequest" ){
		$ReturnValue= '
		{
		  "version": "1.0",
		  "sessionAttributes": {
			"countActionList": {
			  "read": true,
			  "category": true,
			  "currentTask": "none",
			  "currentStep": 0
			}
		  },
		  "response": {
			"outputSpeech": {
			  "type": "PlainText",
			  "text": "Welcome to the, Our, Ace, count example"
			},
			"card": {
			  "type": "Simple",
			  "title": "Our Ace count example",
			  "content": "I can count to five."
			},
			"reprompt": {
			  "outputSpeech": {
				"type": "PlainText",
				"text": "Can I help you with anything else?"
			  }
			},
			"shouldEndSession": false
		  }
		}';
	}
	
	if( $RequestMessageType == "SessionEndedRequest" )
	{
		$ReturnValue = '{
		  "type": "SessionEndedRequest",
		  "requestId": "$RequestId",
		  "timestamp": "' . date("c") . '",
		  "reason": "USER_INITIATED "
		}
		';
		
	}
	
	if( $RequestMessageType == "IntentRequest" ){
	
		$NextNumber = 0;
		$EndSession = "false";
		$SpeakPhrase = "The next number is ";
		if( $EchoJArray->request->intent->name == "next" )
		{
			$NextNumber = $EchoJArray->session->attributes->countActionList->currentStep + 1;
			$SpeakPhrase = "The next number is $NextNumber";
			
			if( $EchoJArray->session->attributes->countActionList->currentStep == 3 )
			{
				$EndSession = "true";
				$SpeakPhrase = "Thank you for counting and good bye";
			}
		}
		
	
		$ReturnValue= '
		{
		  "version": "1.0",
		  "sessionAttributes": {
			"countActionList": {
			  "read": true,
			  "category": true,
			  "currentTask": "none",
			  "currentStep": '.$NextNumber.'
			}
		  },
		  "response": {
			"outputSpeech": {
			  "type": "PlainText",
			  "text": "' . $SpeakPhrase . '"
			},
			"card": {
			  "type": "Simple",
			  "title": "Our Ace count example",
			  "content": "' . $SpeakPhrase . '"
			},
			"reprompt": {
			  "outputSpeech": {
				"type": "PlainText",
				"text": "Say next item to continue."
			  }
			},
			"shouldEndSession": ' . $EndSession . '
		  }
		}';
	}
	return $ReturnValue;
}// end function GetJsonMessageResponse


If you want Alexa to repeat phrases back to you try this:

Intent:
{
  "intents": [
    {
      "intent": "repeat",
      "slots": [
         {
          "name": "Words",
          "type": "LITERAL"
         }
       ]
    }
  ]
}

Utterances:
repeat words {any|Words}
repeat words {any|Words} {any|Words}
repeat words {any|Words} {any|Words} {any|Words}
repeat words {any|Words} {any|Words} {any|Words} {any|Words}
repeat words {any|Words} {any|Words} {any|Words} {any|Words} {any|Words}
repeat words {any|Words} {any|Words} {any|Words} {any|Words} {any|Words} {any|Words}
repeat words {any|Words} {any|Words} {any|Words} {any|Words} {any|Words} {any|Words} {any|Words}
repeat words {any|Words} {any|Words} {any|Words} {any|Words} {any|Words} {any|Words} {any|Words} {any|Words}

each repeat Words line allows for inputs. the first line would grab only 1 word. if there are 3 words after the phrase "repeat words" it would match the 3rd utterance down. If you wanted to catch a lot of words you would need to extend how many utterances are listed and keep adding an extra {any|Words} for each line.

To get the words into PHP it would look like this

$TempWords = $EchoJArray->request->intent->slots->Words->value; //based off the above code.