I´ve gotten an echo show on Christmas. Now I want to try out how I can customize it a bit. I have created several sensors whose metrics are stored in an AWS DynamoDB. Now I am wondering what possibilities I have to show charts created out of that data. Is it possible to display charts using Alexa Presentation Language (APL) directly? Is it possible to include iframes in APL?
I did not find much information on that topic. Maybe you can point me to the right direction.
Many thanks in advance
Not sure if this is what you were looking for, but you can generate SVG graphics and render those using APL VectorGraphic primitives.
You will have to build a custom skill that, when invoked, can pull the data for your metrics, and generate the APL to render the graphs.
Alternatively, if you have a different server-side rendering API for the metrics that can rasterize, you can produce a PNG and render that on the Echo Show.
For reference, I will show the code a a nodejs function which is able to navigate to an URL:
const MetricsChoiceIntentHandler = {
canHandle(handlerInput) {
return Alexa.getIntentName(handlerInput.requestEnvelope) === 'MetricsChoiceIntent';
},
handle(handlerInput) {
const choice = handlerInput.requestEnvelope.request.intent.slots.choice.value;
const speakOutput = `Alles klar. Auf zu ${choice}`;
console.log("Deine Wahl: "+choice);
if (Alexa.getSupportedInterfaces(handlerInput.requestEnvelope)['Alexa.Presentation.APL']) {
handlerInput.responseBuilder.addDirective({
type: 'Alexa.Presentation.APL.RenderDocument',
document: launchDocument,
token: 'jip'
});
var urlToGo="";
switch(choice){
case "gaswarner":
urlToGo="https://www.url1.com";
break;
case "temperatur":
urlToGo="https://www.url2.com"
break;
}
handlerInput.responseBuilder.addDirective({
type: "Alexa.Presentation.APL.ExecuteCommands",
token: 'jip',
commands: [{
type: "OpenURL",
source: urlToGo
}]
});
}
return handlerInput.responseBuilder
.speak(speakOutput)
.getResponse();
}
};
There are two important things to mention:
You have to respond with a document in order to navigate to a URL. This can also be a blank dummy APL document
If you want to navigate to an URL, you have to set the token (which can be anything you like) on both the document and the command directive.
Related
It is a basic question from a newbie. I am testing an API using Postman Tool. I am new to using Postman tool. Here are the details:
"custretryatmpt": 1,
"isrefno":true,
"msisdnlist":[{"phoneno":"9XXXXXXXXXX","agentno":"8XXXXXXXXX"}]
I know how to enter the Keys & value for custretryatmpt and isrefno. How to enter Key & Value for
"msisdnlist":[{"phoneno":"9XXXXXXXXXX","agentno":"8XXXXXXXXX"}]
Requesting help...
click body tab and select round row button
select Json right cornar.
paste json below
send
{
"custretryatmpt": 1,
"isrefno": true,
"msisdnlist": [
{
"phoneno": "9XXXXXXXXXX",
"agentno": "8XXXXXXXXX"
}
]
}
Select your request method type (POST)
It's a lot easier to explain it with an image. Also the link https://community.postman.com/t/sending-an-array-as-form-data/4606 from the post can be helpful.
I want to be able to pull all github pull reviews via the api. At the moment you can only GET a review via a specific number as per the below
GET /repos/:owner/:repo/pulls/:pull_number/reviews
Is there a way that instead of just 1 pull_number i can pull through all pull reviews?
Im using Postman for the requests.
You can use GraphQL API v4 iterating over the pull requests and getting reviews list for each one. But it would give you a bunch of issues that have no reviews, so you would need to use the Github Search API to filter only issues of type PR that have been reviewed :
https://api.github.com/search/issues?q=repo:mui-org/material-ui%20type:pr%20-review:none
Using GraphQL v4 you can get the reviews easily :
{
search(type: ISSUE, query: "repo:mui-org/material-ui type:pr -review:none", first: 100) {
issueCount
nodes {
... on PullRequest {
number
reviews(first: 100) {
nodes {
author {
login
}
bodyText
state
createdAt
}
}
}
}
}
}
My app is being set up to use HelloSign through it's API. I'm trying to create a Template using a PDF I have. My goal is to have fields in the PDF that I can pre-fill in before sending it to the customer to their signature. I'm going to pre-fill things in like their full name, their account #, etc.
I've uploaded the PDF into the Template tool and added the custom fields using the GUI tool. However, as I've found on the documentation and other StackOverflow questions, I need to set these custom fields to "Me (when sending)" in the Assigned to setting. However, for me, this option doesn't appear at all (See image).
As a result, when my API calls the sendWithTemplate function with this as one of the parameters, I'm getting an error of "Invalid custom field parameters".
I'm on the Pro plan currently. Also, if HelloSign is reading this, you should let people on a free account use a template in test mode or something, no reason to make me sign up with CC to test using templates.
const opts = {
test_mode: 1,
template_id: templateId,
clientId: '<my client id>',
subject: 'Test Document',
message: 'Sign this test document',
signers: [
{
email_address: 'email#email.com',
name: 'Klay'
}
],
custom_fields: [
{ personName: "Klay Curry" }
]
};
HelloSign.signatureRequest.sendWithTemplate(opts).then((res) => {
console.log("RES", res);
}).catch((err) => {
console.log("ERR", err);
});
I'm a HelloSign API support engineer and happy to help.
Apologies, we are updating our documentation, but the custom field should be set to "Sender" which is the same as "Me (when sending)".
Also, the custom_fields object should be set like so with NodeJs:
custom_fields = [ { "name" : "personName", "value" : "Klay Curry" } ]
As for your piece about letting folks on a free account use a template in test mode, I believe if you just create a template past your template limit, it will automatically say that the template is locked and can be used in test_mode.
I will also reply to you on the ticket you opened for this.
I am moving from SQL to Couch DB from my web application, my very first application.
While i can not say why I do not like SQL queries, not sure that i don not, the idea of making CURL requests to access my database sound must better than using PHPs PDO .
I have spent a little over a day and a half trying to acquaint myself with the couch DB HTTP API. I can not claim I have throughly read the API , but who thoroughly reads an API before beginning to code. So my, possibly silly, question is - how do I pass an variable other than doc to a map function while making a http request to the view. The API clearly says that a map function only takes a single parameter which is "doc", in which case the function below itself is wrong but I can't find any section in the API that lets me query a database using end-user provided input.
my map function is
function(doc, pid2){
if (doc.pid === pid2)
{
emit(doc._id, doc) ;
}
}
pid2 is a number that will be provided by a front end user.
<?php
$pid2 = file_get_contents(facebook graphi api call_returns a Profile ID) ;
$user_exists = HTTP request to couch DB view to return
in JSON format the list of JSON documents with pid = $pid2
?>
Let your view emit the documents with doc.pid as the key
function(doc) {
emit(doc.pid, doc);
}
and use the key parameter to retrieve the right document:
http://localhost:5984/<database>/_design/<designdoc>/_view/<viewname>?key=<pid2>
This should return all documents with doc.pid === pid2.
I have an Ember app with a login form which returns the current user in JSON format after successful login.
Using createRecord sets the returned JSON attributes directly on the model. For instance, is_private becomes user.is_private, not user.get('isPrivate')?
How do I load the user model so that the attributes are set correctly and I don't have to re-fetch it using the id?
As of a few days ago in ember data 1.0 beta you can use pushPayload to load data directly into the store. For example if you get data pushed to your app through WebSockets (we use the Heroku add-on Pusher). You can call it on the store (source) directly and it will pass it through the appropriate serializer:
var postsJSON = {
posts: [
{id: 1, post_title: "Great post"}
]
}
this.store.pushPayload('post',postsJSON)
NOTE that it will not currently load a singular object (ie post: {id: 1, post_title:"First!"}) - you need to format it as plural with an array.
DS.RESTSerializer has pushPayload as well (source), in which case you need to pass it the store instead.
I highly encourage reading the source code before using, as it looks like the implementation of it will be revisited.
Supposedly, the official way to do this is using adapter.load, as described in this thread:
Loading Data
Previously, some features of the store, such as load(), assumed a
single adapter.
If you want to load data from your backend without the application
asking for it (for example, through a WebSockets stream), use this
API:
store.adapterForType(App.Person).load(store, App.Person, payload);
This API will also handle sideloaded and embedded data. We plan to add
a more convenient version of this API in the future.
But unfortunately, it doesn't handle sideloaded data, despite what the documentation claims. I personally use something like the following, which is based on how find(ID) is implemented:
var id = json["person"]["id"];
var store = DS.get("defaultStore");
var adapter = store.adapterForType(App.Person);
adapter.didFindRecord(store, App.Person, json, id);
var person = App.Person.find(id);
Note that this code assumes JSON in the same format that find(ID) expects to receive from the server, as documented in the RESTAdapter guide:
{
person: {
id: 1,
is_private: false,
projects: [3]
},
projects: [
{ id: 3, name: "FooReader" }
]
}
This will apply any transformations you've configured using keyForAttributeName (such as mapping is_private to isPrivate), and it will handle sideloaded records. I'm not sure if this is a best practice, but it works quite well.
how about store.push('user', userJSON)?
http://emberjs.com/guides/models/pushing-records-into-the-store/#toc_pushing-records
All answers above did not work for me.
What only worked for me was:
this.store.buildRecord(this.store.modelFor('person'), data.id, data)