api.ai : How do I make proper response? - artificial-intelligence

How do make a right response for the questions?
After 3 conversation flow from the user,I am getting the linear response from the bot.
Existing API structure.
Screenshot of my api.ai flow
eg: user: I'd like to book a room, please.
bot: What kind of room would you like?
user: March 23rd.
bot: Certainly. When for, Sir/Madam?
user: Three nights.
bot: How long will you be staying?
user: What kind of rooms do u have?
bot: Certainly. When for, Sir/Madam?
exceptation
user: I'd like to book a room, please.
bot: Certainly. When for, Sir/Madam?
user: March 23rd.
bot: How long will you be staying?
user: Three nights.
bot: What kind of room would you like?
user: What kind of rooms do u have?

It looks like you've mixed up intents, user say examples and responses. Each user says example is an example of something a user can say to match the entire intent. If the intent is matched, one of the responses for the intent is randomly selected and surfaced to the user. If you'd like to ask the sequence of question you mention after a user indicates they'd like to book a room you should use something API.AI calls slot filling. If you do, your intent will look like this:
You'll also need to create a room type entity. I created a basic one for you that looks like this:
If you query your API.AI agent with "I'd like to book a room, please." The conversation will look like this:
User: "I'd like to book a room, please."
API.AI: "Certianly. When for, Sir/Madam?"
User: "March 23rd."
API.AI: "How log will you be staying?"
User: "Three nights."
API.AI: "What kind of room would you like?"
User:"Suite"
API.AI: "Great! I've book your suite on March 23rd for 3 days."

Related

API Response - How to handle response in React

I'm trying to work with an API that sends out a list of questions to create a question set. This is the response from the API:
{"questionSetItems":[[1,"From which date would you like your insurance to start from?","This is the date on which you want the policy to begin. The policy will not pay for any claims which occur prior to this date.","Dropdown",[],"",false],[2,"What is your title?","","DropDown",[],"",false],[3,"What is your title?","","DropDown",[],"",false],[4,"What is your forename?","","Edit",[],"",false],[5,"What is your surname?","","Edit",[],"",false],[6,"What is your date of birth?","","Date",[],"",false],[7,"You and your spouse or partner are not: <br\/>Professional Sportspeople<br\/>Professional Entertainers<br\/>Professional Gamblers<br\/>Moneylenders or Pawnbrokers<br\/>Bailiffs or Bodyguards<br\/>Bar Managers<br\/>Car Dealers\/Salespeople<br\/>Circus or Fairground Employees\/Owners<br\/>Clairvoyants, Tarot Readers or Palmistry Experts<br\/>Croupiers, Gaming Club Managers\/Proprietors<br\/>Diamond or Metal Dealers<br\/>Exotic Dancers<br\/>Jewellers or Jewellery Consultants<br\/>Street\/Market Traders<br\/>Tattooists<br\/>Student<br\/>Unemployed\/In voluntary employment<br\/><br\/>Please confirm that you agree to the above statements.","","YesNo",["inputEmploymentYes","inputEmploymentNo"],"",true],[8,"Please select the relevant employment types for both you and your spouse or partner","","ButtonList",["inputSportspeople","inputEntertainers","inputGamblers","inputBar","inputBailiffs","inputMoneyLender","inputTarot","inputCircus","inputCar","inputExotic","inputDiamond","inputCroupiers","inputTattooists","inputStreet","inputJewellers","inputVoluntary","inputUnemployed","inputOther","inputStudent"],"partnerType",false],[9,"Do you need to add a joint policyholder?","","YesNo",["inputJointHolderYes","inputJointHolderNo"],"",true]],"headerLogo":"","cOB":"STDH","isLastPage":false}
How to look through the array in React?
yo
u can use like this .u can keep it in a variable name and u can check in which key ur getting the array of datas , then you can map the fields and u will get data
enter image description here

cloud firestore role based access example: can user create a comment?

While reading the cloud firestore role based access example https://firebase.google.com/docs/firestore/solutions/role-based-access#rules, step 4, I find it not clear whether the user can create a comment or not.
According to the above link, the comment is owned by a user, here is the data model:
/stories/{storyid}/comments/{commentid}
{
user: "alice",
content: "I think this is a great story!"
}
And the rules:
match /comments/{comment} {
allow read: if isOneOfRoles(get(/databases/$(database)/documents/stories/$(story)),
['owner', 'writer', 'commenter', 'reader']);
// Owners, writers, and commenters can create comments. The
// user id in the comment document must match the requesting
// user's id.
//
// Note: we have to use get() here to retrieve the story
// document so that we can check the user's role.
allow create: if isOneOfRoles(get(/databases/$(database)/documents/stories/$(story)),
['owner', 'writer', 'commenter'])
&& request.resource.data.user == request.auth.uid;
}
Note the last line of the rules, to create the comment, the authenticated user (request.auth.uid) has to be the user who is the owner of the comment. However, before even create this comment, how can this user property exist? Maybe, when create the comment, do not require the last segment of the rule "&& request.resource.data.user == request.auth.uid". But when update the comment, can add this rule.
Did I miss anything? Btw, do they actually test examples before using them for online reference? It is also a pity that there is no timestamp when these online documents are created. I was told nowadays things two years old can be obsolete.
The request.resource variable contains the document as it will exist after this operation is completed (assuming it is allowed). So request.resource.data.user is the value of the user field that the operation is trying to write, not the value as it currently exists (that'd be resource.data.user, without request.).

How to check for user perms (DISCORDIA)

The title speaks for itself, please help, pretty please.
The member class contains hasPermission function. So the code to check if message author has permission would look like this:
if message.member:hasPermission(banMembers) then
-- do action
end
Useful links:
Lua documentation: https://github.com/SinisterRectus/Discordia/wiki/
All permision's enums: https://github.com/SinisterRectus/Discordia/wiki/Enumerations#permission

google calendar api service.calendars().clear(calendarId=calenderID).execute() returns Invalid Value

When executing service.calendars().clear(calendarId=calenderID).execute() on a SECONDARY calendar, one gets the following answer:
googleapiclient.errors.HttpError: https://www.googleapis.com/calendar/v3/calendars/XXXXXXXXXXXXXXXXc%40group.calendar.google.com/clear? returned "Invalid Value">
The documentation in https://developers.google.com/calendar/v3/reference/calendars/clear
seems to evolve on 'primary' calendars, though it is not consistent over the programming languages, in ruby the example quotes 'calendarId', while in the other programming languages, 'primary' is used.
How are events on a secondary calendar deleted?
For deleting an event in a secondary calendar, you must use the Events: delete endpoint. A Python example would look like this:
service.events().delete(calendarId='secondary-calendar-id', eventId='secondary-calendar-event-id').execute()
If you want to get a list of all the calendars you have and in that way get their ids, you can use the CalendarList: list endpoint. A Python example would look like this:
page_token = None
while True:
calendar_list = service.calendarList().list(pageToken=page_token).execute()
for calendar_list_entry in calendar_list['items']:
print calendar_list_entry['summary']
page_token = calendar_list.get('nextPageToken')
if not page_token:
break

JSONP Extjs4 issues

I am trying to to load a JSON store with data that I am retrieving from a search server (Solr).
In Firebug, I can see the response (Solr returns data) but I cannot get the store to be loaded with the incoming data.
Notice that I am working locally (solr's address: localhost:8080/blah/blah and my app's address: localhost:8500/blah/blah).
My store code:
Ext.define('Ledger.store.Searchstore', {
extend: 'Ext.data.Store',
requires: ['Ledger.model.Searchmodel'],
model: 'Ledger.model.Searchmodel',
fields: [
{name:'id', mapping:'id'},
{name: 'model', mapping: 'title'},
{name: 'firstname', mapping: 'firstname'},
{name: 'lastname', mapping: 'lastname'},
{name: 'title', mapping: 'title'},
{name: 'biog', mapping: 'biog'}
],
autoLoad: true,
proxy: {
type:'jsonp',
url: 'http://127.0.0.1:8080/solr/select/?q=*:*&fq=model:book&wt=json',
//noCache: false,
//actionMethods:{create: "POST", read: "POST", update: "POST", destroy: "POST"},
//callbackKey: 'myCallback',
reader:{
type: 'json',
root: 'response.docs'
}
}
});
My model code:
Ext.define('Ledger.model.Searchmodel',{
extend:'Ext.data.Model',
fields:[
{name:'id', mapping:'id'},
{name: 'model', mapping: 'title'},
{name: 'firstname', mapping: 'firstname'},
{name: 'lastname', mapping: 'lastname'},
{name: 'title', mapping: 'title'},
{name: 'biog', mapping: 'biog'}
]
});
The incoming JSON from search server (it is valid):
{
"responseHeader":{
"status":0,
"QTime":1,
"params":{
"indent":"on",
"q":"*:*",
"wt":"json",
"fq":"model:book"}},
"response":{"numFound":8,"start":0,"docs":[
{
"id":"1",
"last_modified":"2012-05-12 15:33:07.0",
"model":"book",
"title":"The Art of Fielding: A Novel",
"fake_id":"b_1",
"biog":"At Westish College, a small school on the shore of Lake Michigan, baseball star Henry Skrimshander seems destined for big league stardom. But when a routine throw goes disastrously off course, the fates of five people are upended.\nHenry's fight against self-doubt threatens to ruin his future. College president Guert Affenlight, a longtime bachelor, has fallen unexpectedly and helplessly in love. Owen Dunne, Henry's gay roommate and teammate, becomes caught up in a dangerous affair. Mike Schwartz, the Harpooners' team captain and Henry's best friend, realizes he has guided Henry's career at the expense of his own. And Pella Affenlight, Guert's daughter, returns to Westish after escaping an ill-fated marriage, determined to start a new life.\nAs the season counts down to its climactic final game, these five are forced to confront their deepest hopes, anxieties, and secrets. In the process they forge new bonds, and help one another find their true paths. Written with boundless intelligence and filled with the tenderness of youth, The Art of Fielding is an expansive, warmhearted novel about ambition and its limits, about family and friendship and love, and about commitment--to oneself and to others.\t\t\t\t\t"},
{
"id":"2",
"last_modified":"2012-05-12 15:33:55.0",
"model":"book",
"title":"The Tiger's Wife",
"fake_id":"b_2",
"biog":"Starred Review. The sometimes crushing power of myth, story, and memory is explored in the brilliant debut of Obreht, the youngest of the New Yorker's 20-under-40. Natalia Stefanovi, a doctor living (and, in between suspensions, practicing) in an unnamed country that's a ringer for Obreht's native Croatia, crosses the border in search of answers about the death of her beloved grandfather, who raised her on tales from the village he grew up in, and where, following German bombardment in 1941, a tiger escaped from the zoo in a nearby city and befriended a mysterious deaf-mute woman. The evolving story of the tiger's wife, as the deaf-mute becomes known, forms one of three strands that sustain the novel, the other two being Natalia's efforts to care for orphans and a wayward family who, to lift a curse, are searching for the bones of a long-dead relative; and several of her grandfather's stories about Gavran Gailé, the deathless man, whose appearances coincide with catastrophe and who may hold the key to all the stories that ensnare Natalia. Obreht is an expert at depicting history through aftermath, people through the love they inspire, and place through the stories that endure; the reflected world she creates is both immediately recognizable and a legend in its own right. Obreht is talented far beyond her years, and her unsentimental faith in language, dream, and memory is a pleasure."},
{
"id":"3",
"last_modified":"2012-05-12 15:34:00.0",
"model":"book",
"title":"State of Wonder",
"fake_id":"b_3",
"biog":"In State of Wonder, pharmaceutical researcher Dr. Marina Singh sets off into the Amazon jungle to find the remains and effects of a colleague who recently died under somewhat mysterious circumstances. But first she must locate Dr. Anneck Swenson, a renowned gynecologist who has spent years looking at the reproductive habits of a local tribe where women can conceive well into their middle ages and beyond. Eccentric and notoriously tough, Swenson is paid to find the key to this longstanding childbearing ability by the same company for which Dr. Singh works. Yet that isn’t their only connection: both have an overlapping professional past that Dr. Singh has long tried to forget. In finding her former mentor, Dr. Singh must face her own disappointments and regrets, along with the jungle’s unforgiving humidity and insects, making State of Wonder a multi-layered atmospheric novel that is hard to put down. Indeed, Patchett solidifies her well-deserved place as one of today’s master storytellers. Emotional, vivid, and a work of literature that will surely resonate with readers in the weeks and months to come, State of Wonder truly is a thing of beauty and mystery, much like the Amazon jungle itself."},
{
"id":"4",
"last_modified":"2012-05-12 15:34:05.0",
"model":"book",
"title":"The Marriage Plot",
"fake_id":"b_4",
"biog":"A stunning novel—erudite, compassionate and penetrating in its analysis of love relationships. Eugenides focuses primarily on three characters, who all graduate from Brown in 1982. One of the pieces of this triangle is Madeleine Hanna, who finds herself somewhat embarrassed to have emerged from a “normal” household in New Jersey (though we later find out the normality of her upbringing is only relative). She becomes enamored with Leonard, a brilliant but moody student, in their Semiotics course, one of the texts being, ironically, Roland Barthes’ A Lover’s Discourse, which Madeleine finds disturbingly problematic in helping her figure out her own love relationship. We discover that Leonard had been diagnosed with bipolar disorder during his first year at Brown, and his struggle with mood swings throughout the novel is both titanic and tender. The third major player is Mitchell, a Religious Studies major who is also attracted to Madeleine but whose reticence she finds both disturbing and incomprehensible. On graduation day, Leonard has a breakdown and is hospitalized in a mental-health ward, and Madeleine shows her commitment by skipping the festivities and seeking him out. After graduation, Leonard and Madeleine live together when Leonard gets an internship at a biology lab on Cape Cod, and the spring after graduation they marry, when Leonard is able to get his mood swings under temporary control. Meanwhile Mitchell, who takes his major seriously, travels to India seeking a path—and briefly finds one when he volunteers to work with the dying in Calcutta. But Mitchell’s road to self-discovery eventually returns him to the States—and opens another opportunity for love that complicates Madeleine’s life. "},
{
"id":"5",
"last_modified":"2012-05-12 15:34:07.0",
"model":"book",
"title":"Steve Jobs",
"fake_id":"b_5",
"biog":"Based on more than forty interviews with Jobs conducted over two years—as well as interviews with more than a hundred family members, friends, adversaries, competitors, and colleagues—Walter Isaacson has written a riveting story of the roller-coaster life and searingly intense personality of a creative entrepreneur whose passion for perfection and ferocious drive revolutionized six industries: personal computers, animated movies, music, phones, tablet computing, and digital publishing.\r\nAt a time when America is seeking ways to sustain its innovative edge, and when societies around the world are trying to build digital-age economies, Jobs stands as the ultimate icon of inventiveness and applied imagination. He knew that the best way to create value in the twenty-first century was to connect creativity with technology. He built a company where leaps of the imagination were combined with remarkable feats of engineering.\nAlthough Jobs cooperated with this book, he asked for no control over what was written nor even the right to read it before it was published. He put nothing off-limits. He encouraged the people he knew to speak honestly. And Jobs speaks candidly, sometimes brutally so, about the people he worked with and competed against. His friends, foes, and colleagues provide an unvarnished view of the passions, perfectionism, obsessions, artistry, devilry, and compulsion for control that shaped his approach to business and the innovative products that resulted.\nDriven by demons, Jobs could drive those around him to fury and despair. But his personality and products were interrelated, just as Apple’s hardware and software tended to be, as if part of an integrated system. His tale is instructive and cautionary, filled with lessons about innovation, character, leadership, and values."},
{
"id":"6",
"last_modified":"2012-05-12 15:34:10.0",
"model":"book",
"title":"The Mill River Recluse",
"fake_id":"b_6",
"biog":"Having been loaned a Kindle from a friend, I immediately went in search of books that were inexpensive. I stumbled on The Mill River Recluse and the reviews were what made me really want to read this book. Having never written a review before, when I completed this book I felt I HAD to write a review. I was so wonderfully surprised to the depth of characters, storylines and twists and turns along the way. I stayed up all night just to finish it!! I found myself chuckling at times and caught myself off guard with tears rolling down my face. You became part of Mill River and its community almost from the first page. I really didn't want the story to end.\nIf you have only one chance to read a good Kindle book - this is by far the one! I enjoyed it so much, that when I someday purchase my own Kindle, I will be adding (and most likely reading) this book again....one I DEFINATELY want to add to a 'forever' collection!"},
{
"id":"7",
"last_modified":"2012-05-12 15:34:13.0",
"model":"book",
"title":"Chasing Amanda",
"fake_id":"b_7",
"biog":"In \"Chasing Amanda\" Melissa Foster guides us in helping Molly; wife, mother to a teenage son, search for a missing girl. The young girl has disappeared from their quiet, rural community; a place where things like this simply don't happen. For Molly, it's deja vu. Several years earlier, while living in Philadelphia, she witnessed a similar event. She did nothing at that time, and has been tormented by her inaction ever since.\nMolly's special gift, or curse, is her clairvoyance. She can sometimes 'see' things that others cannot. In Philadelphia, she failed the little girl, whose body was found shortly after. Now, she promised herself that she would not make that mistake again. Molly persists, using her clairvoyance and sheer stubbornness in an effort to find the child. In doing so, Molly exposes her town's shameful secrets, presenting a conclusion to this story, that I never saw coming!\nMelissa Foster's skill with her characters, drew me into the story immediately. The suspense that followed made this book a definite page-turner!"},
{
"id":"13",
"last_modified":"2012-05-12 16:08:48.0",
"model":"book",
"title":"Kodokan Judo",
"fake_id":"b_13",
"biog":"Judo, or the Way of Gentleness, an ideal form of physical exercise and a reliable system, of self-defense, was specially created from traditional Japanese martial arts. This book by the creator of Kodokan judo is uniquely comprehensive and the most authoritative guide to this martial art ever published.\r\nOver a hundred years ago Jigoro Kano mastered swordsmanship and hand-to-hand combat. Failing to discover any underlying principle, he set about designing a new martial art to reflect the concept of maximum efficiency in the use of physical and mental energy. Today, the concepts and techniques of judo taught at the Kodokan are the ones originally devised by their creator and collected together in this book. Covering everything from the fundamental techniques to prearranged formal exercises for both men and women, the book offers detailed explanations of how techniques are combined in two types of practice: randori (free practice) and kata (the practice of forms). In addition to a discussion of traditional methods of resuscitation, the book concludes with a useful appendix of information on the founder and the Kodokan International Judo Center, and a glossary of judo terminology. Fully illustrated throughout, Kodokan Judo will help students and instructors everywhere to discover the principles, techniques, and spirit of this popular martial art."}]
}}
Somewhere I have a button in order to "console.log" the store, but when I call (notice that I have set autoload attribute to true in the store definition) it is empty. When I am loading the above JSON (copy the server's response in a JSON file) via AJAX proxy, the store gets loaded with the data.
What is the problem?
Try this few things.
First one set proxy into model not into store. I had same problem for long time. Then try to reload ur app.
Second set root "docs" directly.
Third set a Ledger.store.Searchstore.load();
At last i used a proxy like this one and i left to my php file how to read remote file:
proxy: {
type: 'ajax',
api: {
read: 'scripts/receive.php',
create: 'scripts/create.php?action=create',
update: 'scripts/create.php?action=update',
destroy:'scripts/destroy.php?action=destroy'
},

Resources