Search
  • Medium One

Connect Alexa to Medium One

Updated: Jun 15

This tutorial will show you how to easily connect Amazon’s Alexa-controlled device to Medium One cloud without any additional hardware. You will utilize Alexa’s voice control interaction with Medium One.


In this tutorial, you will:

  1. Create an Alexa Skill

  2. Connect your Skill to Medium One

  3. Write a workflow to generate a random number

Here's what you need to get started:

  1. Medium One Prototyping Sandbox [Buy]

  2. Familiarity with Medium One Getting Started Guide [Link]

  3. Any Medium One project and the activation email that came with it

  4. An Amazon Developer account (https://developer.amazon.com/)

  5. An Amazon Alexa Device


Step 1. Create your Alexa Skill

Log into your Amazon Developer account at https://developer.amazon.com/. Click on “Alexa” from your dashboard.

Click “Get Started” under the Alexa Skills kit:

Click “Add A New Skill.”

On the Skill Information page:

  1. For Skill Type, click “Custom Interaction Model”

  2. For Name, put “Generate random number demo”

  3. For Invocation name, put “medium one”

  4. In Global Fields, select “no” for Audio Player

Click “Save.”

Once saved, click “Next” to move to the next page.

On the Interaction Model page, copy and paste the following into “Intent Schema:”

{
    "intents": [
        {
            "intent": "SensorStatusIntent"
        }
      ]
} 

Your “Intent Schema” should look similar to this:

Now, you need to define the question you will ask Alexa.


In Sample Utterance window, type in the following text:

SensorStatusIntent for random number 

Your “Sample Utterances” should look similar to this:

Note: This corresponds to the following request to Alexa: ‘Alexa, ask medium one for random number.’

Click on the “Save” button. It will take a few seconds to build the model. Leave this page open for now - you will need to come back to it in the next step.

Step 2. Create an Alexa Stream and User

Log into Medium One.


Click on “Config→ Data Streams”. Scroll to the bottom and click “Create New Stream.”

Name the stream “alexa_requests”; then, click “Save Data Stream.”

Once saved, your Config Data Streams page should look similar to this:

Then, go to "Setup" > "Manage Users".


Create a new user and take note of the username and password you use - you will have to enter this information in later.


Step 3. Link Alexa and Medium One

For this step, you will need to switch between the Amazon Developer configuration page and the Medium One’s OAUTH Clients Page.


In your Medium One account, go to “Setup” -> “Manage OAuth Clients”. Click on “Add New OAuth Client.”

On Authorize a OAuth Client page, enter Name and Additional login message for the OAuth page, as shown below.

Under Permissions, leave “Stream Access Permission”, then click on the plus sign to the right. Check both, the read and write permissions, and choose “alexa_requests” as the Stream Access Permission.


This gives Alexa a skill permission to send data to this stream.  Leave this as is, and switch back to your Amazon Developer page.

This step assumes that you have not navigated away from anything on this page since Step 1.

Click on the “Configuration” tab.

On the Configuration page, under Global Fields, configure Endpoint and Account Linking.

In Endpoint,

  1. For the Service Endpoint Type, select “HTTPS”

  2. For Geographical region, select “North America”

Once the region is selected, paste "https://assistant.mediumone.com/alexa_request?stream=alexa_requests" into the textbox below.

In Account Linking, select “Yes” to allow users to link the account.

Still in Account Linking, paste "https://auth-sandbox.mediumone.com/oauth2/authorize" in Authorization URL at the top, and "https://auth-sandbox.mediumone.com/oauth2/token" lower down where it says Access Token URI.


Make sure “Auth Code Grant” is selected.

Take note of the two Redirect URLs in the blue box.

Copy and paste the links from the Redirect URLs section on Amazon into the Redirect URIs section on Medium One.


Use the plus button to add the second URI.


Click “Save.”

Once saved, your page should look similar to this.


Take note of the Client ID in the green box and the Client Secret in the orange box. Copy and paste these into the green and orange boxes on the Amazon Developer page as shown below:

Once copied, your Account Linking should look similar to this:

You do not need to put anything for Domain List and Scope.

For privacy policy, paste “https://mediumone.com/privacy”. Then click “Save.”

Finally, on SSL Certificate page, configure Certificate for NA Endpoint.

Select the middle option, then click “Save”.

Step 4. Link your Account to the Skill

Go on the Alexa App on your phone or the desktop version here. Make sure you are logged into your Amazon Account and you have already configured your Alexa device.


This tutorial shows how to link your account to Alexa using your mobile device, however, the mobile app and website look very similar.


Navigate to Skills.

Click on Your Skills on the upper right-hand corner.

Navigate to the skill you created. In this tutorial, the skill is called “Generate Random Number Demo.”

Click “Link Account.”

Note: If you ever want to link to a new user, you’ll have to disable the skill then re-enable it to unlink.

Enter the Username and Password of the user you created earlier in the tutorial.

You should see this on the next page, with your skill name:

Checkpoint

Go to your Amazon Developer account.


On the Test page, try to simulate the command for Alexa.


Go to Service Simulator section and type in “ask for random number”; then, click the “Ask Generate random number demo” button.


You will see “There was an error calling the remote endpoint”. This is OK, as you have not created the workflow that generates that required random number yet!

You can easily confirm the sent request by viewing it in Data Viewer.

Go to “Data Viewer” -> “Data Streams”, then click on ‘alexa_requests.’

You should see one event like the photo below.


Step 5. Create Workflow

Go to your Workflow Studio and create a new workflow called “Generate number for alexa”.


In Tags and Triggers, under alexa_requests, drag “alexa_requests:request.intent.name.” into the view.


In Modules, under Foundation, drag Base Python into the view.


Connect in1 to the green box.


In Outputs, drag Processed Stream - Single to the screen.


Connect out1 on the blue box to in1 on the orange box.  


Double click on the Base Python and replace the code with the code here.


Then, click “Save and Activate.”

Your workflow should look like this:

Checkpoint

Go back to the Test page of Amazon developer’s website.

In Service Simulator, enter utterance “ask for random number.”


You should see a JSON event come up in the response section, as shown below.


Step 6. Talk to Alexa

Now, you’re ready to ask Alexa to get your random number.


“Alexa, ask Medium One to generate random number.”


Alexa responds by saying a random number. The number was generated on fly by the Medium One workflow at the moment of Alexa’s request.

Congratulations! You have successfully connected your device to Medium One!



Want to learn more about what Medium One can do?

Check out our documentation and tutorials & get started on your next IoT project!

© 2018 Medium One   All Rights Reserved

4633 Old Ironsides Dr. #280, Santa Clara, CA  95054                

info@mediumone.com

|

  • YouTube - White Circle