Carlos Mendez Comas
Created December 18, 2016 © GPL3+

Alexa can make call using the Secretary Rosy!

Alexa can help us using Rosy to make telephone calls to our loved ones or get the balance of my credit card before I purchase at amazon

AdvancedWork in progressOver 1 day580
Alexa can make call using the Secretary Rosy!

Things used in this project

Hardware components

Telephone
×1

Software apps and online services

Telephony Application

Story

Read more

Custom parts and enclosures

The files with videos about alexa skills developed

There are some videos to demostrate Alexa to use Rosy to make phone calls to your loved ones and also to get the balance of your default credit card.

Balance for my credit card

Make Alexa ask Rosy for the balance of my credit card

Ask Rosy to call Carlitos Make the homework

Ask Rosy to call Carlitos on the telephone to remind him make the homework

Ask Rosy to call Ketty and tell her I love you

Ask Rosy to call Ketty (my wife) and tell her I love you

Ask alexa to make Rosy call my dad and tell him happy birthday

Ask alexa to make Rosy call my dad and tell him happy birthday

Ask alexa to make Rosy call my mon and tell her to take the medicine

Ask alexa to make Rosy call my mon and tell her to take the medicine

Schematics

Ask Alexa to call on the phone a say a message or ask for the balance available of the credit card

Thera are two diagrams. One is to make alexa call your loved ones on the telephone and tell them a message. The other page is to get the balance available of your credit card

Code

Lambda node.js Function for Alexa Skills

JavaScript
This is the lambda function mapped to the alexa skill
var https = require('https')
var response = require('https');
var querystring = require('querystring');
//var request = require('request');

exports.handler = (event, context) => {

try {
   if (event.session.new) {
      // New Session
      console.log("NEW SESSION")
    }
   
    switch (event.request.type) 
    {

      case "LaunchRequest":
        // Launch Request
        console.log('LAUNCH REQUEST')
        context.succeed(
          generateResponse(
            buildSpeechletResponse("I will be glad to help you more with Rosy asistance. We can call or get the balance available of your credit card", true),
            {}))
        break;
        
        
      case "IntentRequest":
        // Intent Request
        console.log('INTENT REQUEST')
        
        switch(event.request.intent.name) 
        {
        case "Call":
            

            var endpoint = 'https://www.superplazas.com/callrequest.cshtml?Token=89C8E8778F4AAE6B881D0BFBD80F7385&Message=' + event.request.intent.slots.Message.value 
            console.log(endpoint);
            var body =""
            https.get(endpoint, (response) => {
            response.on('data', (chunk) => {body += chunk})
            response.on('end', () => {
            var data = JSON.parse = data.items[0].statistics.suscriberCount
            context.succeed(
            generateResponse(
            buildSpeechletResponse(`I am Calling ${event.request.intent.slots.RELATIVE_PERSON.value} to tell ${event.request.intent.slots.PRONOUNS_PERSON.value}, ${event.request.intent.slots.Message.value}`, true),
            {}
			)
			)
			})
			})

     
        console.log(event.request.intent.slots.RELATIVE_PERSON.value)    
        context.succeed(
          generateResponse(
            buildSpeechletResponse(`I am Calling ${event.request.intent.slots.RELATIVE_PERSON.value} to tell ${event.request.intent.slots.PRONOUNS_PERSON.value}, ${event.request.intent.slots.Message.value}`, true),
            {}))










            var options = {
              host: 'www.superplazas.com',
              port: 80,
              path: '/callrequest.csthml?Token=89C8E8778F4AAE6B881D0BFBD80F7385&Message'+ event.request.intent.slots.Message.value
            };
            
            http.get(options, function(resp){
              resp.on('data', function(chunk){
                //do something with chunk
              });
            }).on("error", function(e){
              console.log("Got error: " + e.message);
            });




         





         break;

         case "GetBalanceOfMyCreditCard":
             context.succeed(
               generateResponse(
               buildSpeechletResponse("The balance available of your credit card is 200 dollars", true),
               {}))

         break;
      default:
        //context.fail(`INVALID REQUEST TYPE: ${event.request.type}`)
        generateResponse( buildSpeechletResponse('Current view count is ', true));

        }
        
        
        
        
      case "SessionEndedRequest":
        // Session Ended Request
        console.log('SESSION ENDED REQUEST')
        break;

    default:
        context.fail(`INVALID REQUEST TYPE: ${event.request.type}`)
        
    }
         
}
catch(error) { context.fail(`Exception: ${error}`) }

    
    
}



// Helpers
buildSpeechletResponse = (outputText, shouldEndSession) => {

  return {
    outputSpeech: {
      type: "PlainText",
      text: outputText
    },
    shouldEndSession: shouldEndSession
  }

}

generateResponse = (speechletResponse, sessionAttributes) => {

  return {
    version: "1.0",
    sessionAttributes: sessionAttributes,
    response: speechletResponse
  }

}

Intents from Alexa module

JavaScript
This is the Alexa intents and slots for the Alexa Skill
{
  "intents": [
  {
    "intent": "GetBalanceOfMyCreditCard" 
  },
   { 
     "intent": "Call",
    "slots": [
      {
        "name":"RELATIVE_PERSON",
        "type": "RELATIVE_PERSON"
      },
      {
        "name":"PRONOUNS_PERSON",
        "type": "PRONOUNS_PERSON"
      },
      {
      "name": "Message",
      "type": "Message"
      }
    ]
    
    
  }   
      
  ]
  
}

Utterances to get the two functions developed

Plain text
Utterances to get the functionalities developed for alexa to integrate with Rosy asistance
Call call {RELATIVE_PERSON} and tell {PRONOUNS_PERSON} {Message}
Call call {RELATIVE_PERSON} and please tell {PRONOUNS_PERSON} {Message}
Call call {RELATIVE_PERSON} and tell {PRONOUNS_PERSON} {Message} please
Call call {RELATIVE_PERSON} to remind {PRONOUNS_PERSON} to {Message} please
GetBalanceOfMyCreditCard get the balance of my credit card
GetBalanceOfMyCreditCard How much many is in my credit card

Credits

Carlos Mendez Comas

Carlos Mendez Comas

1 project • 1 follower
Thanks to Ketty Rivas (My wife) and My children (Charlotte, Charles, Carlos and Steven).

Comments