Create an account in thingspeak.com.
- Go to channels ==> my channels and create new channel. Give name and description to your channels.
Here,we need 8 channels.
1) Device Control
Fields
- Light ON
- Light Off
- Fan ON
- Fan Off
These link is used in backendless site
GET https://api.thingspeak.com/update?api_key=.......&field1=0 //light on
GET https://api.thingspeak.com/update?api_key=........&field1=1 //light off
GET https://api.thingspeak.com/update?api_key=........&field1=2 // fan on
GET https://api.thingspeak.com/update?api_key=.........&field1=3 //fan off
2) Light Status
Fields
- Light off
- Light on
GET https://api.thingspeak.com/update?api_key=.......&field1=0 //light off
GET https://api.thingspeak.com/update?api_key=.......&field1=1 //light on
3) Fan Status
Fields
- Fan off
- Fan on
GET https://api.thingspeak.com/update?api_key=.......&field1=0 // fan off
GET https://api.thingspeak.com/update?api_key=.......&field1=1 // fan on
4) Humidity
Fields
- value of humidity
https://api.thingspeak.com/channels/....../fields/field1/last.html?api_key=........
Write channel ID and read API key
5) Temperature
Fields
- value of temperature
https://api.thingspeak.com/channels/......./fields/field1/last.html?api_key=.....
Write channel ID and read API key
6) intruder notification (update soon)
Fields
- intruder alert
7) fire notification
Fields
- fire alert
8)guest notification
Fields
- guest alert
when you click on any channel you can see its channel id and write API keys in the API keys tab. channel id is required to get the information/ value in the channel. and write key is required to store a value in the channel.
Backendless SideBackendless is used to create the Alexa skill. It is a simple drag and drop programming used to create Alexa skill which can be accessed by backendless API.
Create an account in backendless: https://backendless.com/
- Log in to your account in backendless account. Click create app and give a name to your app.
- Click the Business Logic icon located in the icon bar on the left. You will see the API SERVICES screen.
- Click the “+” icon to create a new service. Make sure to select CODELESS in the “New Service” popup. Enter “AlexaService”for the service name. Click the SAVE button:
Backendless creates the API Service and will prompt you to create a method for the service. This will be the method which will process requests from Alexa. Enter “handleRequest” for the method name. Make sure to select POST for the REST operation, and declare an argument with the name of “req” and type “Any Object” as shown below:
When you click on app at left side you will see page like this.
- Step 1
When you click on app at left side you will see page like this.
- Step 2
Now go to codeless section ,In browser section you will see function node press add new.
Click the gear icon located in blue block right next to the word “Function”. Add two arguments by dragging the input blocks as shown in the image below. Assign the names of the arguments as "whatToSay" and "waitForResponse".
After saving first we have to create object for that click on object and select first option.
Next, go to text section and select fifth option.
After dragging text edit it and for last we have to create repeat steps for creating an object. After edit you will see like this.
Next go to logic section and select not.
For waitForResponse drag it from above as shown in image.
Next, create object edit it as shown in image.
Again go to text section and select fifth option.
For ssml go to text section and select six option.
Now for first and third item select text
After joining text block , for second item select whatToSay from above.
Complete function look like this.
- Step 3
After saving the function go to handleRequest in browser section. In custom section you will see function which we created. Click the Custom Functions category in the toolbar on the left and drag the sendAlexaResponse block to connect with the return connector of your service method.
It will look like this.
- Step 4
Create new function and give name getIntentName
Next, go to object section and select get property of block.
Select three get property of and edit it as shown.
For request drop it from above as shown in image.
Complete function look like this.
- Step 5
Now, go back to handleRequest section. Here, go to variable section and create variable request.
After creating variable select set request to.
After that go to custom function, select getIntentName and select Method Argument req from context block.
Next, from logic section select first option and edit it to if elseif as shown.
Next, go to logic section and select second option.
Next go to variable section and select request.
After that create variable respond and select set respond to block.
Next, for ifelse case select request from variable section. For do select set respond to from variable section.
After that go to Network API and select first option.
After placing you will see
Next is for light off simply right click on LightOn block and create duplicate. After that edit it for LightOff. You will see block like this.
Next is FanOn , we have to do duplicate it again and change it to FanOn.
Next is FanOff , duplicate above block and change it to FanOff.
We are done with Light and Fan. Next, we will do for Weather. For weather, duplicate ifelse and do part and change it request to Weather and set respond to Temperature is .
After this go to text section, select third option and join it with set respond block. Next , go to Network API section select first option and join it with append block as shown in image.
Again select append text and edit it as shown in image.
Next duplicate the block below set respond and join it below append text block as shown.
Next you can duplicate degree Celsius block or select third option from text section and change it to %.
We are done with Temperature. Next, we do for Camera follow steps as mentioned above. It should be look like as shown in image . (Update soon)
Next, we do Status part for that duplicate request and respond block, change it as shown
Go to Logic section, select first option join it with respond block for if statement select second option from same section its look like this.
Join it with ifelse in between them, select first option from Network API.
when you click on return it will look like this.
Place it at first place for second place select text from Text section. It should look like this.
For do part use set respond to block after that go to gear button of if block and add else as shown.
Next, duplicate this whole block as shown
After duplicate, join it below it and change it for Fan.
We are done with Status , next is Notification for that duplicate request and respond block and change it. (Update soon)
Next select set fire to from Variable section and join with respond do this same for intruder and guest. After that select first option from Network API and join with all three blocks as shown.
Next , select first and second option from Logic section. Join second with first as shown.
After that add fire variable from Variable section and text from Text section, change it to 1.
For do use set respond block and text block . It should look like this.
Duplicate this block 2 times for intruder and guest. It will look like this.
After that select first, second,third option from Logic section and join as shown
Select third option again from Logic section and place it on second place after that select second option 2 times and place it in between them. It should look like this.
After editing its look like this.
After that select first option from Network API and edit it as shown below. In these we use update link of fire,intruder and guest.
Next, select forth option and second option 2 times and join in with forth option section. It will look like this.
Congratulations we have successfully created an app. If you want android or IOS application you can also make it . Simply click on download template and save it.
For URL go to API service and click on show full URL which will be used at Amazon skill.
Go to amazon developer console and sign in using amazon account.
Go to Developer console.
Go to Alexa then select Alexa Skill Kit and then create new skill by clicking on Add new skill.
When you add new skill you will see skill information page.
1. Skill Information
we have to provide skill type,language,name,invocation name.
- Skill type ==> select custom.
- Name ==> select any name.
- Invocation name ==> which you use while communicating with Alexa.
For example ;- Alexa, ask sensor to turn switch trigger on or Alexa, ask light on here invocation names are sensor and light.
- click save and then next.
2. Interaction Model
Here, we will use skill builder. So,Click on Launch Skill Builder.
In this you can use two methods either use code editor or use intent both do same thing. For code editor simply go to code editor and copy paste code which is given by Adithya or you can make intent as follow.
Code Editor
{
"languageModel": {
"intents": [
{
"name": "AMAZON.CancelIntent",
"samples": []
},
{
"name": "AMAZON.HelpIntent",
"samples": []
},
{
"name": "AMAZON.StopIntent",
"samples": []
},
{
"name": "Camera",
"samples": [
"please send a snapshot of my living room",
"please send a snapshot of my home",
"please send a photo of my living room",
"please send a photo of my home"
],
"slots": []
},
{
"name": "FanOff",
"samples": [
"turn off Fan",
"switch off Fan",
"turn off the Fan",
"switch off the Fan",
"turn fan off"
],
"slots": []
},
{
"name": "FanOn",
"samples": [
"turn on Fan",
"switch on Fan",
"turn on the Fan",
"switch on the Fan",
"turn fan on"
],
"slots": []
},
{
"name": "Introduction",
"samples": [
"what you can do",
"what can you do",
"what can you do for me"
],
"slots": []
},
{
"name": "LightsOff",
"samples": [
"turn off lights",
"switch off lights",
"turn off the lights",
"switch off the lights",
"turn lights off",
"turn light off",
"turn off light",
"turn off the light",
"switch off the light"
],
"slots": []
},
{
"name": "LightsOn",
"samples": [
"turn on lights",
"switch on lights",
"turn on the lights",
"switch on the lights"
],
"slots": []
},
{
"name": "Notification",
"samples": [
"what are my notifications",
"is there any notifications",
"is there any updates",
"read out my notifications",
"tell me about my notifications"
],
"slots": []
},
{
"name": "Status",
"samples": [
"what is my device status",
"what is the status of my devices",
"tell me about my device status"
],
"slots": []
},
{
"name": "Weather",
"samples": [
"what is the weather condition of my home",
"what is the weather of my home",
"what is the weather",
"what is the temperature of my home",
"what is the temperature"
],
"slots": []
}
],
"invocationName": "home"
}
}
Simply go to Intent section and press "+".
Write intent name what ever you wanna give be sure it should be same as you gave on backenless site otherwise it will not work. After giving intent name add sample utterances. Do this for rest of the intent.
After all the intent save it and build model.
3. Configuration
In this we have to provideURL which was generated in backendless.
4. SSL Certificate
Select second option here.
5. Test
Comments