<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>alexa Archives - gj</title>
	<atom:link href="https://blog.gaiterjones.com/tag/alexa/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.gaiterjones.com/tag/alexa/</link>
	<description>gaiterjones</description>
	<lastBuildDate>Wed, 25 Apr 2018 10:41:27 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.4.3</generator>
	<item>
		<title>Simulate and test your Alexa Skill with the Alexa Skills Kit Command Line Interface (ASK CLI)</title>
		<link>https://blog.gaiterjones.com/simulate-and-test-your-alexa-skill-with-the-alexa-skills-kit-command-line-interface-ask-cli/</link>
					<comments>https://blog.gaiterjones.com/simulate-and-test-your-alexa-skill-with-the-alexa-skills-kit-command-line-interface-ask-cli/#respond</comments>
		
		<dc:creator><![CDATA[PAJ]]></dc:creator>
		<pubDate>Wed, 25 Apr 2018 10:16:31 +0000</pubDate>
				<category><![CDATA[Alexa]]></category>
		<category><![CDATA[Amazon]]></category>
		<category><![CDATA[Docker]]></category>
		<category><![CDATA[alexa]]></category>
		<guid isPermaLink="false">http://blog.gaiterjones.com/?p=1871</guid>

					<description><![CDATA[The new Alexa Skills Kit Developer Console is fab and a lot of things have changed since I developed my first skill in 2016, one of the changes is skill...<a class="more-link" href="https://blog.gaiterjones.com/simulate-and-test-your-alexa-skill-with-the-alexa-skills-kit-command-line-interface-ask-cli/" title="Continue reading">Continue reading</a>]]></description>
										<content:encoded><![CDATA[<p>The new Alexa Skills Kit Developer Console is fab and a lot of things have changed since I <a href="https://blog.gaiterjones.com/amazon-alexa-php-hello-world-example/">developed my first skill in 2016</a>, one of the changes is skill testing which you can now do quite easily with the Alexa Skills Kit Command Line Interface (ASK CLI)</p>
<p>If you are building skills with my PHP code here are a few notes on using the ASK CLI to do simple skill invocation tests using a Docker compose ASK CLI nodejs container.</p>
<p>Assuming you are familiar with using Docker and docker-compose here are the steps to testing your skill from the command line :</p>
<ol>
<li>git clone https://github.com/gaiterjones/docker-amazon-ask-cli</li>
<li>cd docker-amazon-ask-cli</li>
<li>docker-compose build</li>
<li>docker-compose up -d</li>
<li>./init.sh
<ol>
<li>Initialise <em>ask</em> with your amazon developer credentials, you will be prompted to create a default profile and then to paste an authorisation url into your browser. The url will take you to an Amazon authorisation page where you need to login with your developer login. You will then receive an authorisation code which you can paste into the init window to create your cli-config credentials file.</li>
<li><img fetchpriority="high" decoding="async" src="https://blog.gaiterjones.com/wp-content/uploads/2018/04/amazon-ask-cli-1.jpg" alt="" width="600" height="194" class="aligncenter size-full wp-image-1872" /></li>
</ol>
</li>
<li>Test skill with skill simulation
<ol>
<li>./ask.sh amzn1.ask.skill.123 &#8220;ask my skill to do something&#8221; where amzn1.ask.skill.123 is the id of your skill and &#8220;ask my skill to do something&#8221; is the invocation term you want to test with your skill &#8211; i.e. what you would ask Alexa to do to open and use your skill.</li>
<li><img decoding="async" src="https://blog.gaiterjones.com/wp-content/uploads/2018/04/amazon-ask-cli-2.jpg" alt="" width="600" height="265" class="aligncenter size-full wp-image-1873" /></li>
</ol>
</li>
</ol>
<p>Check out <em>ask.sh</em> for the ASK CLI syntax being used. You can use this directly from the container with <em>docker exec -it dockeramazonaskcli_nodejs_1 /bin/bash</em></p>
<p>The credentials will be saved in <em>cli-config</em> when the container is stopped.</p>
<p>You can do a whole lot more with the ASK CLI, check out the documentation here <a href="https://developer.amazon.com/docs/smapi/ask-cli-command-reference.html">https://developer.amazon.com/docs/smapi/ask-cli-command-reference.html</a></p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.gaiterjones.com/simulate-and-test-your-alexa-skill-with-the-alexa-skills-kit-command-line-interface-ask-cli/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Amazon Alexa PHP Hello World Example</title>
		<link>https://blog.gaiterjones.com/amazon-alexa-php-hello-world-example/</link>
					<comments>https://blog.gaiterjones.com/amazon-alexa-php-hello-world-example/#comments</comments>
		
		<dc:creator><![CDATA[PAJ]]></dc:creator>
		<pubDate>Tue, 13 Dec 2016 18:33:25 +0000</pubDate>
				<category><![CDATA[Alexa]]></category>
		<category><![CDATA[Amazon]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Raspberry Pi]]></category>
		<category><![CDATA[alexa]]></category>
		<category><![CDATA[amazon]]></category>
		<category><![CDATA[echo]]></category>
		<category><![CDATA[hello world]]></category>
		<category><![CDATA[php]]></category>
		<guid isPermaLink="false">http://blog.gaiterjones.com/?p=1481</guid>

					<description><![CDATA[NOTE &#8211; this blog entry was written for the old version of the Alexa Skills Kit Developer Console &#8211; whilst the PHP server code still works some info and screen...<a class="more-link" href="https://blog.gaiterjones.com/amazon-alexa-php-hello-world-example/" title="Continue reading">Continue reading</a>]]></description>
										<content:encoded><![CDATA[<p><strong>NOTE &#8211; this blog entry was written for the old version of the Alexa Skills Kit Developer Console &#8211; whilst the PHP server code still works some info and screen shots of the developer console are now obsolete!</strong></p>
<p>This Christmas (2016) a lot of people in Europe will be unpacking a shiny new Amazon Echo device and enjoying meaningful discussions with Alexa about life, the universe and everything.</p>
<p>If you are a geek like me then you will probably want Alexa to do a bit more than tell you about the weather or play Last Christmas by Wham. I bought my Amazon Echo Dot primarily to use for extremely important Home Automation tasks such as &#8216;<em>Alexa, switch on the Christmas Tree lights</em>&#8216;.</p>
<p>The developer documentation from Amazon is good but very biased towards node.js. I know absolutely nothing about node.js and some of the online examples seemed overly complex to me. Eventually I found some useable PHP code examples and set about creating my own flexible PHP server side app for handling Alexa requests.</p>
<p>The app I created uses Alexa to send home automation commands via an Internet server to a home based Raspberry Pi server that lets me control Lights and Audio equipment. This is a step by step Hello World example using the same script that shows how relatively simple it is to create an Amazon Alexa App using PHP on your server to handle requests.</p>
<p>Before we start, here is a shopping list of things you will need :</p>
<ol>
<li>Amazon developer account</li>
<li>Internet accessible web server (project tested with Apache)</li>
<li>SSL Certificate</li>
<li>PHP</li>
<li>Amazon Echo</li>
</ol>
<p>&nbsp;</p>
<h1>1. Install and Test the PHP Application</h1>
<ul>
<li>Download my example PHP application and extract it to your web server
<ul>
<li><a href="https://github.com/gaiterjones/amazon-alexa-php-hello-world-example"><strong>https://github.com/gaiterjones/amazon-alexa-php-hello-world-example</strong></a></li>
<li>preserve the file and folder structure
<ul>
<li>Application</li>
<li>Library</li>
<li>www</li>
<li>autoload.php</li>
</ul>
</li>
<li>Your web server needs to be able to serve web pages over SSL.</li>
</ul>
</li>
<li>create a folder that is writeable by your www server user, i.e. www-admin
<ul>
<li>configure this folder path as amazonCacheFolder in config.php
<ul>
<li><em>const amazonCacheFolder=&#8217;/home/www/amazon/cache/&#8217;;</em></li>
</ul>
</li>
</ul>
</li>
<li>make the file <em>PAJ/www/AmazonDev/alexa.php</em> web accessible
<ul>
<li>Test that the application is working by browsing to
<ul>
<li><strong><span style="color: #ff0000;">https</span>://www.your.server/youralias/alexa.php?debug</strong></li>
</ul>
</li>
<li>Make sure you see
<ul>
<li><strong>PAJ\Application\AmazonDev\AlexaRequest</strong></li>
<li><em>logfolder is writeable</em></li>
</ul>
</li>
<li>note the debug curl information as this will be helpful in testing access to your application.</li>
</ul>
</li>
</ul>
<h1>2. Register a Developer Account</h1>
<p>Register and login to Amazon Developer Services at <a href="https://developer.amazon.com/home.html">https://developer.amazon.com</a>. You should register with the Amazon account you used to setup your Amazon Echo device. Once you are registered and logged in, click on the <em>Alexa</em> tab, and then the <em>Get Started</em> button for the Alexa Skills Kit and click the <em>Add a New Skill</em> button.</p>
<figure id="attachment_1484" aria-describedby="caption-attachment-1484" style="width: 550px" class="wp-caption aligncenter"><img decoding="async" class="wp-image-1484 size-large" src="https://blog.gaiterjones.com/wp-content/uploads/2016/12/Image1-620x203.png" alt="Getting started with Alexa" width="550" height="180" srcset="https://blog.gaiterjones.com/wp-content/uploads/2016/12/Image1-620x203.png 620w, https://blog.gaiterjones.com/wp-content/uploads/2016/12/Image1-440x144.png 440w, https://blog.gaiterjones.com/wp-content/uploads/2016/12/Image1-768x252.png 768w, https://blog.gaiterjones.com/wp-content/uploads/2016/12/Image1-760x249.png 760w, https://blog.gaiterjones.com/wp-content/uploads/2016/12/Image1-550x180.png 550w, https://blog.gaiterjones.com/wp-content/uploads/2016/12/Image1.png 1025w" sizes="(max-width: 550px) 100vw, 550px" /><figcaption id="caption-attachment-1484" class="wp-caption-text">Getting started with Alexa</figcaption></figure>
<figure id="attachment_1486" aria-describedby="caption-attachment-1486" style="width: 513px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="wp-image-1486 size-full" src="https://blog.gaiterjones.com/wp-content/uploads/2016/12/Image.png" alt="Add a new skill" width="513" height="301" srcset="https://blog.gaiterjones.com/wp-content/uploads/2016/12/Image.png 513w, https://blog.gaiterjones.com/wp-content/uploads/2016/12/Image-440x258.png 440w" sizes="(max-width: 513px) 100vw, 513px" /><figcaption id="caption-attachment-1486" class="wp-caption-text">Add a new skill</figcaption></figure>
<p>&nbsp;</p>
<h1>3. Create and Test the Alexa Skill</h1>
<h2>Skill Information</h2>
<p>Amazon calls the process used to interact with the Alexa Voice Service a Skill. We will create a new private skill called Hello World.</p>
<figure id="attachment_1490" aria-describedby="caption-attachment-1490" style="width: 550px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="wp-image-1490 size-large" src="https://blog.gaiterjones.com/wp-content/uploads/2016/12/Image-1-620x387.png" alt="Alexa Skill Information" width="550" height="343" srcset="https://blog.gaiterjones.com/wp-content/uploads/2016/12/Image-1-620x387.png 620w, https://blog.gaiterjones.com/wp-content/uploads/2016/12/Image-1-440x274.png 440w, https://blog.gaiterjones.com/wp-content/uploads/2016/12/Image-1-768x479.png 768w, https://blog.gaiterjones.com/wp-content/uploads/2016/12/Image-1-760x474.png 760w, https://blog.gaiterjones.com/wp-content/uploads/2016/12/Image-1-550x343.png 550w, https://blog.gaiterjones.com/wp-content/uploads/2016/12/Image-1.png 837w" sizes="(max-width: 550px) 100vw, 550px" /><figcaption id="caption-attachment-1490" class="wp-caption-text">Alexa Skill Information</figcaption></figure>
<p>&nbsp;</p>
<ul>
<li>Skill Type
<ul>
<li>choose Custom Interaction Model</li>
</ul>
</li>
<li>Language
<ul>
<li>Select from drop down</li>
</ul>
</li>
<li>Name
<ul>
<li>The name of the skill
<ul>
<li>Hello World</li>
</ul>
</li>
</ul>
</li>
<li>Invocation Name
<ul>
<li>This is the name we will use to activate the skill when talking to Alexa
<ul>
<li>hello world
<ul>
<li>&#8220;<em>Alexa, ask <strong>hello world</strong> to say hello world</em>&#8220;</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
<li>Click Next</li>
</ul>
<p>&nbsp;</p>
<h2>Interaction Model &#8211; Skill Builder Beta</h2>
<p>The interaction model describes how the user will interact with the voice service. In the context of Alexa, an intent represents an action that fulfills a user’s spoken request. Intents can optionally have arguments called slots. The intent schema is configured as an array in JavaScript Object Notation (JSON) format.</p>
<p>Use the Skill Builder Beta and paste the following skills builder intent json schema into the code section :</p>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-1739 size-full" src="https://blog.gaiterjones.com/wp-content/uploads/2016/12/alexa-skills-kit.png" alt="" width="400" height="418" /></p>
<p>&nbsp;</p>
<span class="collapseomatic collapse" id="id65fc9b2bb9ef6"  tabindex="0" title="Show interaction model json"    >Show interaction model json</span><div id="target-id65fc9b2bb9ef6" class="collapseomatic_content ">
[text]
{<br />
  &quot;intents&quot;: [<br />
    {<br />
      &quot;name&quot;: &quot;AMAZON.CancelIntent&quot;,<br />
      &quot;samples&quot;: []
    },<br />
    {<br />
      &quot;name&quot;: &quot;AMAZON.HelpIntent&quot;,<br />
      &quot;samples&quot;: []
    },<br />
    {<br />
      &quot;name&quot;: &quot;AMAZON.StopIntent&quot;,<br />
      &quot;samples&quot;: []
    },<br />
    {<br />
      &quot;name&quot;: &quot;HelloWorld&quot;,<br />
      &quot;samples&quot;: [<br />
        &quot;say {command}&quot;,<br />
        &quot;for {command}&quot;,<br />
        &quot;{prompt}&quot;<br />
      ],<br />
      &quot;slots&quot;: [<br />
        {<br />
          &quot;name&quot;: &quot;command&quot;,<br />
          &quot;type&quot;: &quot;COMMANDOBJECTS&quot;,<br />
          &quot;samples&quot;: []
        },<br />
        {<br />
          &quot;name&quot;: &quot;prompt&quot;,<br />
          &quot;type&quot;: &quot;PROMPTOBJECTS&quot;,<br />
          &quot;samples&quot;: []
        }<br />
      ]
    }<br />
  ],<br />
  &quot;types&quot;: [<br />
    {<br />
      &quot;name&quot;: &quot;COMMANDOBJECTS&quot;,<br />
      &quot;values&quot;: [<br />
        {<br />
          &quot;name&quot;: {<br />
            &quot;value&quot;: &quot;hello world&quot;<br />
          }<br />
        },<br />
        {<br />
          &quot;name&quot;: {<br />
            &quot;value&quot;: &quot;clever quotes&quot;<br />
          }<br />
        }<br />
      ]
    },<br />
    {<br />
      &quot;name&quot;: &quot;PROMPTOBJECTS&quot;,<br />
      &quot;values&quot;: [<br />
        {<br />
          &quot;name&quot;: {<br />
            &quot;value&quot;: &quot;yes&quot;<br />
          }<br />
        },<br />
        {<br />
          &quot;name&quot;: {<br />
            &quot;value&quot;: &quot;no&quot;<br />
          }<br />
        },<br />
        {<br />
          &quot;name&quot;: {<br />
            &quot;value&quot;: &quot;ok&quot;<br />
          }<br />
        },<br />
        {<br />
          &quot;name&quot;: {<br />
            &quot;value&quot;: &quot;sure&quot;<br />
          }<br />
        }<br />
      ]
    }<br />
  ]
}<br />
[/text]
</div>
<figure id="attachment_1736" aria-describedby="caption-attachment-1736" style="width: 600px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="wp-image-1736 size-full" src="https://blog.gaiterjones.com/wp-content/uploads/2016/12/amazon-skill-builder-beta.jpg" alt="" width="600" height="483" /><figcaption id="caption-attachment-1736" class="wp-caption-text">Amazon Skill Builder</figcaption></figure>
<p>Here we have defined our intent name <strong>HelloWorld</strong> and associated slots.</p>
<p>Some default Intents are added by Amazon</p>
<p><em>AMAZON.CancelIntent</em><br />
<em> AMAZON.HelplIntent</em><br />
<em> AMAZON.StoplIntent</em></p>
<p>You can think of slots as variables to the intent, we have a slot (variable) named <em>command</em> with possible values contained in the <em>COMMANDOBJECTS </em>intent slot.</p>
<p>Next we configure the sample utterances for the skill. These are what people say to Alexa to invoke the intents configured in the skill.</p>
<figure id="attachment_1737" aria-describedby="caption-attachment-1737" style="width: 600px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="wp-image-1737 size-full" src="https://blog.gaiterjones.com/wp-content/uploads/2016/12/amazon-skill-builder-beta-sample-utterances.jpg" alt="" width="600" height="413" /><figcaption id="caption-attachment-1737" class="wp-caption-text">Sample Utterances</figcaption></figure>
<p>The sample utterance starts with the intent name <strong>HelloWorld</strong>, followed by any combination of words a user might use to interact with the skill, and then the slot name that corresponds with this interaction.</p>
<p>When a user interacts with our Alexa Skill</p>
<p style="text-align: center;"><em>&#8216;Alexa, ask hello world to say hello world&#8217;</em></p>
<p style="text-align: left;">The voice service try to determine the user intention by matching the spoken words to the configured utterances, invoking the configured intent and matching the slot values to the phrases provided to the slot. In this case it will match &#8216;<em>hello world</em>&#8216; to the value configured in the command slot of the <em>HelloWorld</em> intent. This data will be sent to our server for us to process.</p>
<p style="text-align: left;">Why use slots? By using the amazon voice service to process and match the users spoken words to a configured set of slot variables (object types) we do not have to process the spoken words ourselves, we simply match the slot type to the command or processes we want to execute making it easier to determine user intent.</p>
<p style="text-align: left;">When you are finished configuring the Skill Builder you must save your configuration by clicking the Save Model button, and then build the model by clicking the Build Model button.</p>
<h2 style="text-align: left;">Configuration</h2>
<figure id="attachment_1499" aria-describedby="caption-attachment-1499" style="width: 550px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="wp-image-1499 size-large" src="https://blog.gaiterjones.com/wp-content/uploads/2016/12/Image-5-620x373.png" alt="Configuration" width="550" height="331" srcset="https://blog.gaiterjones.com/wp-content/uploads/2016/12/Image-5-620x373.png 620w, https://blog.gaiterjones.com/wp-content/uploads/2016/12/Image-5-440x265.png 440w, https://blog.gaiterjones.com/wp-content/uploads/2016/12/Image-5-768x462.png 768w, https://blog.gaiterjones.com/wp-content/uploads/2016/12/Image-5-760x458.png 760w, https://blog.gaiterjones.com/wp-content/uploads/2016/12/Image-5-550x331.png 550w, https://blog.gaiterjones.com/wp-content/uploads/2016/12/Image-5.png 842w" sizes="(max-width: 550px) 100vw, 550px" /><figcaption id="caption-attachment-1499" class="wp-caption-text">Configuration</figcaption></figure>
<p>Now we will configure how the Skill communicates with our PHP application.</p>
<ul>
<li>Select HTTPS</li>
<li>Select the geographical location closest to your server</li>
<li>Enter the URL to the Alexa php script on your server
<ul>
<li><strong>https://www.your.server/youralias/alexa.php</strong></li>
</ul>
</li>
</ul>
<p>&nbsp;</p>
<p style="text-align: left;">Click Next.</p>
<h2 style="text-align: left;">SSL Certificate</h2>
<figure id="attachment_1500" aria-describedby="caption-attachment-1500" style="width: 571px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="wp-image-1500 size-full" src="https://blog.gaiterjones.com/wp-content/uploads/2016/12/Image-6.png" alt="SSL Certificate" width="571" height="251" srcset="https://blog.gaiterjones.com/wp-content/uploads/2016/12/Image-6.png 571w, https://blog.gaiterjones.com/wp-content/uploads/2016/12/Image-6-440x193.png 440w, https://blog.gaiterjones.com/wp-content/uploads/2016/12/Image-6-550x242.png 550w" sizes="(max-width: 571px) 100vw, 571px" /><figcaption id="caption-attachment-1500" class="wp-caption-text">SSL Certificate</figcaption></figure>
<p style="text-align: left;">Assuming your web server has a valid SSL certificate select &#8216;My development endpoint has a certificate from a trusted certificate authority&#8217;.</p>
<p style="text-align: left;">Click Next.</p>
<h2 style="text-align: left;">TEST</h2>
<p>We can now test the Skill and server PHP application by using the service simulator.</p>
<figure id="attachment_1501" aria-describedby="caption-attachment-1501" style="width: 550px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="wp-image-1501 size-large" src="https://blog.gaiterjones.com/wp-content/uploads/2016/12/Image-7-620x392.png" alt="Testing Alexa Skill" width="550" height="348" srcset="https://blog.gaiterjones.com/wp-content/uploads/2016/12/Image-7-620x392.png 620w, https://blog.gaiterjones.com/wp-content/uploads/2016/12/Image-7-440x278.png 440w, https://blog.gaiterjones.com/wp-content/uploads/2016/12/Image-7-768x486.png 768w, https://blog.gaiterjones.com/wp-content/uploads/2016/12/Image-7-760x481.png 760w, https://blog.gaiterjones.com/wp-content/uploads/2016/12/Image-7-550x348.png 550w, https://blog.gaiterjones.com/wp-content/uploads/2016/12/Image-7.png 844w" sizes="(max-width: 550px) 100vw, 550px" /><figcaption id="caption-attachment-1501" class="wp-caption-text">Testing Alexa Skill</figcaption></figure>
<p>&nbsp;</p>
<p>In the Enter Utterance text box we can type the phrase we would say to invoke the application using our Echo device</p>
<p style="text-align: center;">Alexa, ask hello world to say hello world</p>
<p style="text-align: left;">The application will fail with an exception error if you have not yet added your amazon credentials to the config file in PAJ/Application/Amazon/Alexa/config.php. You can see the application id and userid in the service request. Copy these and add them to config.php.</p>
<pre class="brush: php; title: ; notranslate">
	// AMAZON ALEXA
	const amazonSkillId = 'amzn1.ask.skill.XXX';
	const amazonUserId = 'amzn1.ask.account.XXX';
	const amazonEchoServiceDomain = 'echo-api.amazon.com';
	const amazonCacheFolder='/home/www/amazon/cache';
</pre>
<p>Run the test again. If the application is working you will see the service response JSON data returned from our PHP application, and the text that would be spoken by the Echo device.</p>
<pre class="brush: plain; title: ; notranslate">
  &quot;response&quot;: {
    &quot;outputSpeech&quot;: {
      &quot;type&quot;: &quot;PlainText&quot;,
      &quot;text&quot;: &quot;OK, I will now say hello world&quot;
    },
</pre>
<h2>Publishing</h2>
<p>The publishing information is used to define how the app will appear to users if it is made public. This includes the category, countries the app will be available in, description, sample phrases and images.</p>
<p>This information will also be displayed in the Alexa mobile app.</p>
<p>You cannot publish your app until you have completed this section. When all sections are complete the Submit for Certification button will be available. Clicking this will begin the certification process where Amazon checks your app for compliance and functionality before publishing it in the Alexa Skills store and making it publicly accessible.</p>
<h2>Privacy &amp; Compliance</h2>
<p>Complete the privacy and Compliance section and click Save to save the Skill.</p>
<p>&nbsp;</p>
<h1>4. Test with Amazon Echo device</h1>
<p>To use your newly created Hello World skill with your Echo device make sure the skill is visible and enabled in the Alexa app, under <em>Home</em> -&gt; <em>Skills</em> select <em>Your Skills</em></p>
<p>&nbsp;</p>
<figure id="attachment_1504" aria-describedby="caption-attachment-1504" style="width: 411px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="wp-image-1504" src="https://blog.gaiterjones.com/wp-content/uploads/2016/12/Photo-13-12-2016-12-23-07-620x514.png" alt="Select your skill in Alexa App" width="411" height="341" srcset="https://blog.gaiterjones.com/wp-content/uploads/2016/12/Photo-13-12-2016-12-23-07-620x514.png 620w, https://blog.gaiterjones.com/wp-content/uploads/2016/12/Photo-13-12-2016-12-23-07-440x365.png 440w, https://blog.gaiterjones.com/wp-content/uploads/2016/12/Photo-13-12-2016-12-23-07-550x456.png 550w, https://blog.gaiterjones.com/wp-content/uploads/2016/12/Photo-13-12-2016-12-23-07.png 750w" sizes="(max-width: 411px) 100vw, 411px" /><figcaption id="caption-attachment-1504" class="wp-caption-text">Select your skill in Alexa App</figcaption></figure>
<p>Now say to Alexa</p>
<p style="text-align: center;"><em>Alexa, ask hello world to say hello world</em></p>
<p style="text-align: left;">Your Echo device will respond with</p>
<p style="text-align: center;"><em>OK, I will now say hello world<br />
</em></p>
<p style="text-align: left;">You can also say, &#8216;<em>Alexa, open hello world</em>&#8216;, this initiates a Launch Request.</p>
<p style="text-align: left;">Ok, so this is a bit lame, change the output text response by modifying the response text in the HelloWorld.php intent return array.</p>
<pre class="brush: php; title: ; notranslate">
	return array(
		'intent' =&amp;amp;amp;amp;amp;amp;amp;gt; array(
			'response' =&amp;amp;amp;amp;amp;amp;gt; 'OK, I will now say something much more meaningful',
			'target' =&amp;amp;amp;amp;amp;amp;gt; $_target,
			'status' =&amp;amp;amp;amp;amp;amp;gt; false
		)
	);

</pre>
<h1 style="text-align: left;">How the PHP application works</h1>
<p>The PHP server side process is relatively straightforward:</p>
<ul>
<li>Amazon sends the Alexa request data as an HTTP POST request to alexa.php.
<ul>
<li>alexa.php initiates the wwwApp bootload which injects the following php objects
<ul>
<li>Config
<ul>
<li>config data for the app</li>
</ul>
</li>
<li>Security
<ul>
<li>validates the Alexa Request as per the guidelines <a href="https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/developing-an-alexa-skill-as-a-web-service">here</a>.</li>
<li> This includes :
<ul>
<li>Validating the amazon application id</li>
<li>Verifying that the Request was Sent by Alexa
<ul>
<li><span>determine whether the URL meets each of the following criteria:</span>
<ul>
<li><span>The protocol is equal to https (case insensitive).</span></li>
<li><span>The hostname is equal to s3.amazonaws.com (case insensitive).</span></li>
<li><span>The path starts with /echo.api/ (case sensitive).</span></li>
<li><span>If a port is defined in the URL, the port is equal to 443.</span></li>
</ul>
</li>
</ul>
</li>
<li>Validate the Signature of the Request</li>
<li>Validate the Timestamp of the Request</li>
</ul>
</li>
</ul>
</li>
<li>Log
<ul>
<li>logging</li>
</ul>
</li>
<li>Request
<ul>
<li>parses the alexa post data</li>
</ul>
</li>
<li>Data
<ul>
<li>renders the response</li>
<li>renders default intent responses
<ul>
<li>STOP, CANCEL, HELP</li>
</ul>
</li>
<li>render LaunchRequest response
<ul>
<li>open hello world</li>
</ul>
</li>
<li>initiating PAJ\Application\AmazonDev\Alexa\Intent\IntentName()</li>
<li>processing the Amazon intent data
<ul>
<li>formulating a text response based on the process data, in this case simply returning the response text for hello world
<ul>
<li>&#8216;<em>OK, I will now say hello world</em>&#8216;</li>
</ul>
</li>
<li>managing session attribute data</li>
</ul>
</li>
<li>wrapping the response text and card data into a JSON request and outputting it</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
<p>If you look at HelloWorld.php in Alexa\Intent you will see how we are parsing the intent data from Amazon, looping through the slot data and performing an action on each slot. In this case looking for the &#8216;command&#8217; slot, validating the spoken words and then acting on them to formulate a response.</p>
<p>&nbsp;</p>
<h2>Further customisation</h2>
<p>Here you can also see how you can now further customise the application. For example suppose you want to ask alexa to turn the lounge lights on</p>
<p style="text-align: center;"><em>&#8216;Alexa, ask Home to switch the lounge lights on&#8217;</em></p>
<p style="text-align: left;">Here my Alexa Skill is called Home, my intent name is Command, and I have configures a slot called switch which contains object types (variables) such as &#8216;lounge lights on&#8217; and &#8216;lounge lights off&#8217;.</p>
<p style="text-align: left;">In Alexa/Intent/Command.php I parse the intent data to find the <em>switch </em>slot, verify that the slot value contains either &#8216;lounge lights on&#8217;, or &#8216;lounge lights off&#8217; and the send the appropriate commands to my home automation system, i.e. <a href="http://www.fhem.de">FHEM</a>. When the command has been successfully executed I can return the appropriate response.</p>
<p style="text-align: left;"><img loading="lazy" decoding="async" class="aligncenter wp-image-1515" src="https://blog.gaiterjones.com/wp-content/uploads/2016/12/Photo-15-12-2016-12-11-24-516x620.png" alt="" width="344" height="413" srcset="https://blog.gaiterjones.com/wp-content/uploads/2016/12/Photo-15-12-2016-12-11-24-516x620.png 516w, https://blog.gaiterjones.com/wp-content/uploads/2016/12/Photo-15-12-2016-12-11-24-366x440.png 366w, https://blog.gaiterjones.com/wp-content/uploads/2016/12/Photo-15-12-2016-12-11-24-550x661.png 550w, https://blog.gaiterjones.com/wp-content/uploads/2016/12/Photo-15-12-2016-12-11-24.png 750w" sizes="(max-width: 344px) 100vw, 344px" /></p>
<p style="text-align: center;"><em>&#8216;Ok, I have switched the lounge lights on&#8217;</em></p>
<h1>Debugging</h1>
<p>If the Application is not working as expected check out the logfiles in your cache folder, for each Amazon Alexa request you will see the request, intent and response data logged in a file called helloworld_yyyy-mm-dd.log.</p>
<p>Use the skills tester in the Amazon skill builder to test and debug your skill. To debug further use the example curl command from the debug page. Execute this from a bash terminal to run curl and simulate an alexa request to your application.</p>
<h1>Amazon Default Intents</h1>
<p>You will notice that Amazon includes some default intents in the interaction model : AMAZON.StopIntent, AMAZON.CancelIntent, AMAZON.HelpIntent. If you want to publish your skill you must also include responses for these default intents. The default response for the Stop and Cancel intent is included in the renderAlexaResponse method. An examples for the Stop intent can be found in the Help folder.</p>
<h1>Prompt and Response Dialog</h1>
<p>Having completed a basic Alex command skill I will extend this PHP example to allow for prompts and responses <a href="https://blog.gaiterjones.com/amazon-alexa-php-prompt-and-response-example/">in part 2 of this blog post</a>.</p>
<h1>Submit for Certification</h1>
<p>Alexa Skills built with this project will pass the Amazon certification process. After submitting your skill you will receive a confirmation email from Amazon, and within 24 hours a response to notify you whether your skill has passed certification of not. Once your skill has been certified you cannot make any changes to the skill configuration without revoking it&#8217;s published status.</p>
<p>If you publish a skill with this application please let us know in the comments!</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.gaiterjones.com/amazon-alexa-php-hello-world-example/feed/</wfw:commentRss>
			<slash:comments>48</slash:comments>
		
		
			</item>
	</channel>
</rss>
