Disclaimer: this is all totally hypothetical, of course. This blog doesn't necessarily condone illicitly buying cannabis.

I've seen people use their Amazon echo to do some incredible things. So I thought I'd lower the tone a bit and use it for naughtiness.

First of all, create a blank Lambda function, using the node 4.3 engine. Set up a Twilio app, and create a number with SMS enabled.

Now create a new node project $ npm init . Create a file called index.js . Then install the dependencies...

$ npm install --save alexa-sdk

$ npm install --save twilio

Now the code...

const Alexa = require('alexa-sdk') const twilio = require('twilio') const accountSid = '{{ account sid }}' const authToken = '{{ account token }}' const dealersNum = '123' const twilioNum = '213' const client = new twilio.RestClient(accountSid, authToken) exports.handler = (event, context, callback) => { const alexa = Alexa.handler(event, context) alexa.registerHandlers(handlers) alexa.execute() } const handlers = { 'Order': function() { const choice = this.event.request.intent.slots.choice.value client.messages.create({ body: `Ayup mate, can you drop ${choice}`, to: dealersNum, // Text this number from: twilioNum, }, (function(err) { if (err) console.log(err) this.emit(':tell', `Texting your dealer for ${choice}`) }).bind(this)) }, 'Unhandled': function() { this.emit(':tell', 'Having trouble contacting your dealer!') } }

Now create an Alexa app, and use the following intents.

{ "intents": [ { "intent": "Order", "slots": [ { "name": "choice", "type": "CHOICES" } ] } ] }

Be sure to use a sensible invocation, such as 'my deadler', so to trigger it you would say 'Alexa, ask my dealer for ...'.

Now create some custom slots with the name CHOICES . Then add the following, separated by line.

"an ounce of weed" "a ten bag of weed"

Of course, you could add whatever in here.

Now for your utterances. Utterances are phrases, separated by line breaks, starting with the function name, which should match the function names in the nodejs code. Followed by a series of natural language phrases, and your pre-defined arguments 'slots'. Defining how you interact with your custom Alexa skill set.

Order {choice} Order I would like {choice}, thanks

Order correlates with the Order handler in the nodejs code. Then the choice is picked up from your voice command and converted into this.event.request.intent.slots.choice.value in your handler.

Save and publish you app as a test app, and you should see it in your list of skills.

Here it is in action!

If you're using Ad Blocker, that's cool, but please consider making a small donation for the upkeep of this blog. Much appreciated! https://monzo.me/ewanvalentine