I don't understand how my google action shows up on "Works with Google" search - google-cloud-platform

I have followed below tutorial to build my own home action.
https://github.com/actions-on-google/smart-home-nodejs
I don't understand well on how this works. Let me explain you all about what I have understood so far and what I have done by now.
What I have DONE :
I built a conversational action (built with dialogflow's inline editor and intents) to change a data of the Firebase realtime database. (for instance, when I say "Turn the light on", then the Firebase data 'LED/OnOff' turns 0 to 1). Below is the code I have in my Dialogflow inline editor. (I have excluded the field including my project's credentials.)
'use strict';
const functions = require('firebase-functions');
const admin = require('firebase-admin');
const {WebhookClient} = require('dialogflow-fulfillment');
const {Card, Suggestion} = require('dialogflow-fulfillment');
admin.initializeApp();
process.env.DEBUG = 'dialogflow:debug'; // enables lib debugging statements
exports.dialogflowFirebaseFulfillment = functions.https.onRequest((request, response) => {
const agent = new WebhookClient({ request, response });
console.log('Dialogflow Request headers: ' + JSON.stringify(request.headers));
console.log('Dialogflow Request body: ' + JSON.stringify(request.body));
function welcome(agent) {
agent.add(`Welcome to my agent!`);
}
function fallback(agent) {
agent.add(`I didn't understand`);
agent.add(`I'm sorry, can you try again?`);
}
function handle_heatOn(agent) {
const state = agent.parameters.heat_on;
console.log(state);
var heat = 0;
if (state == 1)
heat = 1;
return admin.database().ref('0/OnOff').update({
on : true
});
}
function handle_heatOff(agent) {
const state = agent.parameters.heat_on;
var heat = 0;
if (state == 0)
heat = 0;
return admin.database().ref('0/OnOff').update({
on : false
});
}
//some more functions, related to controlling 4 different devices (heater, cooler, exhaust fan, LED) - exempted
// Run the proper function handler based on the matched Dialogflow intent name
let intentMap = new Map();
intentMap.set('Default Welcome Intent', welcome);
intentMap.set('Default Fallback Intent', fallback);
intentMap.set('heat_on', handle_heatOn);
intentMap.set('heat_off', handle_heatOff);
intentMap.set('cool_on', handle_coolOn);
intentMap.set('cool_off', handle_coolOff);
intentMap.set('exha_on', handle_exhaOn);
intentMap.set('exha_off', handle_exhaOff);
intentMap.set('led_on', handle_ledOn);
intentMap.set('led_off', handle_ledOff);
// intentMap.set('your intent name here', yourFunctionHandler);
// intentMap.set('your intent name here', googleAssistantHandler);
agent.handleRequest(intentMap);
});
Then I have deployed my action and Google has approved my action! It is now in production and can be searched in anyone's google account.
I have set up an OAuth 2.0 server. I'm really a beginner in developing, so I managed to use Auth0 to make the server. I have followed the below tutorial :
https://v3.jovo.tech/tutorials/google-action-account-linking-auth0
As a conclusion, when I invoke my conversational action in anyone's Google Assistant App, It will prompt the user to the authentication (login) screen (By Auth0). After the user inputs ID and Password, google assistant will link the user's account and launch my app.
However, my action is not shown on Google Home's "Works with Google" category. After trying to complete Brand Verification in Google Actions Console and linking one of my existent app on Google Play, I still don't know what to do or where to start from.
What I have understood so far :
Sorry for my shallow understanding in advance. I have understood that once my action is invoked by a user, it has to do account linking, which requires OAuth 2.0 server to exchange authentication token. If exchanging token has succeeded, the user's account is linked and he/she is able to use my action. The action will be launched after that.
I have searched the Internet and found some information such as Deep Linking and App Discovery, but I'm not sure this is the right keyword to start from.
I know I am really lacking in knowledge here. Please kindly at least hint where I should study and start.
What I want to understand and do :
I want to make my action, which is in production, show up on Google Home and Google Assistant App's "Works With Google" category without the prefix [test]. In other words, I want to let my app be searched just as the other company's apps. I understand that if you click on one of the apps of a company, your account will be linked and the company's action would be launched. Maybe I have to add some lines on Dialogflow's inline editor?? I know I might be silly, but I really appreciate your help. Thank you for reading my post.

Related

Ember - Change current route from browser console

I am not at all Ember developer, but I would like to change current route from browser console. Is it possible at all to access correctly Ember, e.g. Ember.Router.prototype.transitionTo('/feed')?
Version of the website is 3.16.9
After a lot of research, I have found out possible solutions that you can use. I was trying to achieve it on Linkedin website via Chrome Extension
function runEmbedded(path) {
const namespaces = window.Ember.Namespace.NAMESPACES;
let application;
namespaces.forEach(function (namespace) {
if (namespace instanceof window.Ember.Application) {
application = namespace;
return false;
}
});
application.__container__.lookup('router:main').transitionTo(path);
}
const payload = '/some/new-path'
script.text = `(${runEmbedded.toString()})('${payload}');`;
document.documentElement.appendChild(script);
Second solution/hack:
Another possible hack to use, when the website is not listening to pushState/replaceState actions from History API is to push state 2 times and then go back. Please remember that's only a hack.
history.pushState({}, '', msg.payload);
history.pushState({}, '', msg.payload);
history.back();

AWS Amplify federated google login work properly on browser but dont work on Android

The issues are when I am trying to run federated authentication with the help of amplify auth method on the browser it works fine, but when I try to run it on my mobile.
It throws error No user found when I try to use Auth.currentSession() but the same work on the browser.
tried to search about this type of issue but I found related to ionic-cordova-google-plugin not related to AWS Amplify Federated Login Issue.
Updating the question after closing the question with less debugging information without asking for any information.
This is issues raised in git hub with respect to my problem.
Issue No. 5351 amplify js it's still in open state.
https://github.com/aws-amplify/amplify-js/issues/5351
Another issue 3537 which is still in Open
These two issues has the same scenario like me, I hope its enough debugging information, if more required mention comment instead of closing without notification, it's bullying for a beginner not helping
I fixed the above problem by referring a comment or wrapped around fix.
Link that will take to that comment directly link to comment.
First read the above comment as it will give you overall idea of what exactly the issue is instead of directly jumping to the solution.
Once you read the comment you will be little unclear with respect to implementation as he has use capacitor and not every one are using capacitor.
In my implementation I ignore this part as I am not using capacitor.
App.addListener('appUrlOpen')
Now lets go to main step where we are fixing this issue, I am using deep links to redirect to my application
this.platform.ready().then(() => {
this.deeplinks
.route({
"/success.html": "success",
"/logout.html": "logout",
})
.subscribe(
(match: any) => {
const fragment = JSON.stringify(match).split('"fragment":"')[1];
// this link can be your any link based on your requirement,
// what I am doing it I am passing all the data which I get in my fragments.
// fragments consists of id_token, stage, code,response type.
// These need to be passed to Ionic in order for Amplify to run its magic.
document.location.href = `http://192.168.1.162:8100/#${fragment}`;
},
(nomatch) => {
console.log("Got a deeplink that didn't match", nomatch);
}
);
});
I got this idea by referring the issue in which the developer mentioned of sending code and state along with application deep linking URL.

Alexa, there was an issue processing your input

I'm following a video which explain how to create a skill and intents, to use Alexa. (Here is the link to see this video: https://www.youtube.com/watch?v=YMb0y66UCxs)
I have a problem, I can't go inside an Intent but I can run the skill with the sentence "Alexa open [Name of the skill]". I will show you the index.js from aws and after that the JSON file from developer amazon.
AWS
And here, the JSON:
I built this project in english in the developer amazon website, but i live in france. Maybe I can have a conflict there. And i also choose, in aws, the city east USA (virginia...). So when i say : ask [name of the skill] for [Un unterance], i have this problem:
When I click on the exclamation point, it says: "There was an issue processing your input". Do you see my problem ?
I don't know, and I could be wrong, but do you need to add a GetNewFactHandler? It doesn't look like you defined one anywhere and your trying to add it in .addRequestHandlers.
Based on the other handlers in your code I'm guessing it should look something like this:
const GetNewFactHandler = {
canHandle() {
const request = handlerInput.requestEnvelope.request;
return request.type === 'IntentRequest' && request.intent.name === 'GetNewFact'
},
handle(handlerInput) {
return handlerInput.responseBuilder
.speak('Hello from the get new fact intent')
.getResponse()
}
}
Oh sorry, I just forgot to put the part where I have this code in my aws.
The forgotten part

Is it possible to use AMAZON LEX to build a chatbot which connects with database and Web service stored on client side?

Our organization wants to develop a "LOST & FOUND System Application" using chatbot integrated in a website.
Whenever the user starts the conversation with the chatbot, the chatbot should ask the details of lost item or item found and it should store the details in database.
How can we do it ?
And can we use our own web-service because organization doesn't want to keep the database in Amazon's Server.
As someone who just implemented this very same situation (with a lot of help from #Sid8491), I can give some insight on how I managed it.
Note, I'm using C# because that's what the company I work for uses.
First, the bot requires input from the user to decide what intent is being called. For this, I implemented a PostText call to the Lex API.
PostTextRequest lexTextRequest = new PostTextRequest()
{
BotName = botName,
BotAlias = botAlias,
UserId = sessionId,
InputText = messageToSend
};
try
{
lexTextResponse = await awsLexClient.PostTextAsync(lexTextRequest);
}
catch (Exception ex)
{
throw new BadRequestException(ex);
}
Please note that this requires you to have created a Cognito Object to authenticate your AmazonLexClient (as shown below):
protected void InitLexService()
{
//Grab region for Lex Bot services
Amazon.RegionEndpoint svcRegionEndpoint = Amazon.RegionEndpoint.USEast1;
//Get credentials from Cognito
awsCredentials = new CognitoAWSCredentials(
poolId, // Identity pool ID
svcRegionEndpoint); // Region
//Instantiate Lex Client with Region
awsLexClient = new AmazonLexClient(awsCredentials, svcRegionEndpoint);
}
After we get the response from the bot, we use a simple switch case to correctly identify the method we need to call for our web application to run. The entire process is handled by our web application, and we use Lex only to identify the user's request and slot values.
//Call Amazon Lex with Text, capture response
var lexResponse = await awsLexSvc.SendTextMsgToLex(userMessage, sessionID);
//Extract intent and slot values from LexResponse
string intent = lexResponse.IntentName;
var slots = lexResponse.Slots;
//Use LexResponse's Intent to call the appropriate method
switch (intent)
{
case: /*Your intent name*/:
/*Call appropriate method*/;
break;
}
After that, it is just a matter of displaying the result to the user. Do let me know if you need more clarification!
UPDATE:
An example implementation of the slots data to write to SQL (again in C#) would look like this:
case "LostItem":
message = "Please fill the following form with the details of the item you lost.";
LostItem();
break;
This would then take you to the LostItem() method which you can use to fill up a form.
public void LostItem()
{
string itemName = string.Empty;
itemName = //Get from user
//repeat with whatever else you need for a complete item object
//Implement a SQL call to a stored procedure that inserts the object into your database.
//You can do a similar call to the database to retrieve an object as well
}
That should point you in the right direction hopefully. Google is your best friend if you need help with SQL stored procedures. Hopefully this helped!
Yes its possible.
You can send the requests to Lex from your website which will extract Intents and Entities.
Once you get these, you can write backend code in any language of your choice and use any DB you want.
In your use case, you might just want to use Lex. PostText will be main function you will be calling.
You will need to create an intent in Lex which will have multiple slots LosingDate, LosingPlace or whatever you want, then it will be able to get all these information from the user and pass it to your web application.

Create a web service that can answer to WhatsApp messages

I'm trying to understand if it's possible to create a web service that can send and answer to WhatsApp messages. I searched on the web and I found the WhatsAPI,
I guess this solution work fine, but with the actual version of WhatsApp it's not possible to get the nickname, the sender, the imei and the password.
To get them I set up a Linux PC in which I installed mitmproxy to sniff the web traffic of a Samsung Galaxy S4. By using mitmproxy I can see the web traffic generated by the phone, so I tried to register to WhatsApp (with an another SIM), but in mitmproxy I can't see the data I need for WhatsAPI.
Does anyone knows if it's possible to get the password by using another way?
If it exist can you suggest me a way? Do you think it's possible to do that or it's better to use Telegram or Wechat (they have public API)?
For Java, you can try WhatsUp
For Python, see YowsUp.
Beware that WhatsApp threatens legal action against many of these library developers and does not officially support using the service this way.
I have also spoken directly with WhatsApp representatives who have said no commercial API use of WhatsApp is acceptable.
Also note that bulk messaging is against the WhatsApp terms of service.
There used to be a PHP implementation at WhatsAPI, and another Java implementation, WhatsApi4J. Both are no longer available due to legal threats.
For .NET you use https://github.com/mgp25/Chat-API-NET
download installer for generate password https://github.com/mgp25/WART from this link
string nickname = "Nickname";
/* Your number in the format CCAANNNNNNNNN
* C - Country Code
* A - Area Code
* N - Phone number */
string sender = "***************"; //phone number
string password = "*****************"; // Obtain it with WART or Yowsup
WhatsApp wa = new WhatsApp(sender, password, nickname, true);
wa.OnConnectSuccess += () =>
{
Console.WriteLine("Connected");
wa.OnLoginSuccess += (phoneNumber, data) =>
{
Console.WriteLine("Connection success!");
wa.SendMessage("**************"/* Number */, "Hello World!");
Console.WriteLine("Message sent!");
};
wa.OnLoginFailed += (data) => {
Console.WriteLine("Login failed: {0}", data);
};
wa.Login();
};
wa.OnConnectFailed += (ex) =>
{
Console.WriteLine("Connect failed: {0}", ex.StackTrace);
};
wa.Connect();
Console.WriteLine("END");
Console.ReadLine();
wart app maybe works good for you.
WART
WhatsApp Registration Tool
Uses token generator created by Jake
Uses WhatsApiNet fork by me
Requires .NET Framework 4 or Mono Framework (mono-complete on Linux)
This tool is used to register new phonenumbers and can also be used to retrieve a new password for already registered numbers.
The registration identity is auto-generated by the program based on the phone number.
The optional (and highly recommended) password field is used as salt when generating the identity. This will generate a unique identity hash which cannot be replicated unless you know the password.
Leaving the password field blank will generate an identity hash of just the phone number, which can be easily replicated and is highly insecure.
If these answers were helpful to you, please consider saying thank you in a more constructive way