I created one project with watson conversion.
Flow is like:(sorry i can't show my dialog flow but i will try to explain it)
(W:Watson,U:User)
U:what documents required for open account?
W: Name, Email, Contact. Can I open it for you?
U:Yes
W:Great, Please enter your Name.
U: XYZ
W: XYZ please enter your contact number.
U: 9999999999
W: XYZ, you are doing great please enter your email.
U: xyz#domain.com
now come to watson dialog part.
W:Great, Please enter your name.(i used " < ? input.text ?>" to take user input)
{
"context":{"name":"< ? input.text ?>"}
"output":{"text":"Great,Please enter your name."}
}
U:XYZ
W:XYZ please enter your contact number
{
"context":{"contact":"< ? input.text ?>"}
"output":{"text":"$name, Please enter your contact number"}
}
U:9999999999
W: XYZ, you are doing great please enter your email.
{
"context":{"email":"< ? input.text ?>"}
"output":{"text":"$name, you are doing great please enter your email."}
}
U: xyz#domain.com
This is my flow and it is working perfect when I run it inside the watson.
But when i am trying to run it from my own application then it takes only my name but not entered in loop means it is not taking other information.
reason is in json it pass:
{
"text":"XYZ"
}
but watson shows it's intent as irrelevant.
in my project i just want to pass user data from my application to watson and it display output as mention above.
is it support < ? input.text ?>...?
For the part where Watson Conversation is giving intent as irrelevant, it is so because you be missing to send parameter conversation_id as context parameter.
You will get conversation_id in response and pass it in subsequest calls. If you do not pass that, then a new id will be generated everytime
//Extract converstaionId from first call
String conversationId=msgResponse.getContext().get("conversation_id")
//Second call in which user gives his name
Map contextData=new HashMap();
context.put("conversation_id", conversationId); // conversationId will be in the response of previous call
Related
I use read message API to get all messages for one conversation between two users.
The result is the following (check image). enter image description here
How I am supposed to know what are the messages I have sent and others I received?
The purpose is to display the conversation like in the picture.enter image description here
This is how I read messages sent between two users.
function readConversationWithUser(userId){
return new Promise((resolve) => {
var messageSession = api.readDbSession(userId.toString(), 0, null,
function on_read(count) {
var messages = messageSession.getMessages();
resolve(messages);
});
messageSession.enableReadReceipt(true);
messageSession.read(100);
});
}
userId is my user's unique address.
Thank you very much for your help!
PS: Is there any library to use with angular application or typescript?
I try to make a push notification for my google assistant app.
I used the sendNotification Code form the google developer site: https://developers.google.com/actions/assistant/updates/notifications
I am coding Java.
Everything is working, expect getting the correct user id.
When I hardcode my user it works, but how do I get the user id in the code?
I tried following code:
Argument arg_userId = request.getArgument(ConstantsKt.ARG_UPDATES_USER_ID);
String userId = request.getUser().getUserId();
--> I get "java.lang.reflect.InvocationTargetException"
String userId = arg_userId.getRawText();
--> same Exception
There are two problems with the approach you're taking to get the notification ID:
The ID attached to the user object is deprecated and probably unavailable.
This wasn't the ID you wanted anyway.
In the response where the user finalizes the notification, that response includes an ID which you should get and store. Since you're using Java, the code might look something like this:
ResponseBuilder responseBuilder = getResponseBuilder(request);
Argument permission = request.getArgument(ConstantsKt.ARG_PERMISSION);
if (permission != null) {
Argument userId = request.getArgument(ConstantsKt.ARG_UPDATES_USER_ID);
// code to save intent and userID in your db
responseBuilder.add("Ok, I'll start alerting you.").endConversation();
} else {
responseBuilder.add("Ok, I won't alert you.");
}
return responseBuilder.build();
I want to send an email with a content related to my data such as in following piece of code I found on Datasource script of Google AppMaker Project Tracker template. But I don't understand how it works. How that data.modifiedBy reflect to the record in my datasource?
Any help from the floors? Thanks ..
Look at the Notifications server side script in the template.
It has method notifyAboutItemChanges_ which is passing the data to this record.
function notifyAboutItemChanges_(changes) {
var settings = getAppSettingsRecord_()[0];
if (!settings.EnableEmailNotifications) {
return;
}
var data = {
appUrl: settings.AppUrl,
itemType: changes[0].Type,
itemKey: changes[0]._key,
itemName: changes[0].Name,
modifiedBy: changes[0].ModifiedBy,
changes: changes
};
// Email subject.
var subjectTemplate =
HtmlService.createTemplate(settings.NotificationEmailSubject);
}
This function is passing this data to your settings record.
So no magic here :) You need to pass the data to your record which will be replaced at run time with the values.
For more details on Email refer this sample app.
At the moment this is a general question with no code as I am looking for a BEST practices example to my question:
User issues an email change request. (done)
A link is sent to the new address to confirm the new email. (done)
User clicks the confirmation link and the DB update is complete. (done)
What also needs to happen is when the confirmation link is sent for the change, an email should also be sent to the original email address where the user can click a link to reverse the process for whatever reason. I would think also that even if the new email address was accepted, if the original link denies the change it reverts and 2) if the original email reverts and then the new email link is confirmed, that the request would then be denied.
Any direction or code on this matter would be greatly appreciated.
Seems like a simple bit field in the database user record would suffice, or an associated database record would work too. When both emails are sent, mark the field for that user, let's call it "ChangeEmailSent" to 1. When either email is clicked, the field should be updated to 0. The actual changing of the email should only occur if the field is 1.
Some pseudo-code if you like
private void CancelEmailChange(email)
{
var user = Database.GetUser(email);
user.ChangeEmailSent = false;
Database.Save();
}
private void ProcessEmailChange(email)
{
var user = Database.GetUser(email);
if (user.ChangeEmailSent)
{
user.email = getNewEmailAddress(); //whatever logic for a new email
user.ChangeEmailSent = false;
Database.Save();
}
}
How does this code look? Pretty solid and efficient? Any way I could do this better?
EDIT: Forgot to mention, I'm checking as a user fills out a signup form, before they hit submit to actually create the account.
Template HTML:
...
<input id="username">
{{#if usernameTaken}}
<div class="error">Username is taken.</div>
{{/if}}
...
Client:
Template.signupPage.events
'blur #username': (e) ->
username = $(e.target).val()
Meteor.call 'userExists', username, (error, result) ->
Session.set 'usernameTaken', result.exists
Template.signupPage.helpers
usernameTaken: ->
return Session.get('usernameTaken')
Server:
Meteor.methods
userExists: (username) ->
check username, String
results = Meteor.users.find
username:
$regex: "^#{username}$", $options: 'i'
return { exists: results.count() > 0 }
On the client-side, there's a potentially confusing interaction here. In the example, "myusername" is taken, but "myusername1" is not.
User types in "myusername" and then blurs the field
Client makes a method call to see if "myusername" is taken
User changes their mind, changes the field to "myusername1" and blurs the field
Client makes a method call to see if "myusername1" is taken
The first method call returns, and "Username is taken" appears
A reasonably long time passes
The second method call returns, and "Username is taken" disappears
If the user doesn't wait for the "reasonably long time", they'll probably think the "Username is taken" refers to "myusername1" and not "myusername".
I'd take some steps against this:
Display "Checking username availability..." while the method call is in progress. Replace it with e.g. "myusername is taken" or "myusername1 is available" when the method returns. Use colour and icons appropriately.
If the method call is in progress and the user types anything in the field, even if they didn't blur the field yet, then hide the "Checking username availability". When the out-of-date method call returns, ignore the result.
If it says "#{username} is (taken|available)" and the user types anything in the field, even if they didn't blur the field yet, then hide that text.
It should work, but the accounts API already have built in duplicate username detection as usernames / emails should be unique.
So you could also rely on Accounts.createUser (see the doc):
Accounts.createUser({username:..., email:..., password:...}, function(error, result){
//you will get an error if the username already exists
});