Amazon Lex - Taking user input and storing it - amazon-lex

Is there a way to store the users input from slots? For example, the persons favourite meat is beef and bun is brioche. Then can this data be checked and returned with I recommend the Tennessee Stack that has a 6oz beef patty inside of a brioche bun.
Also, would it be possible to then have this data sent in an email automatically? Or am I asking too much?
Cheers

It is definitely possible, but not with Lex alone.
You'll have to use another Amazon Web Service or your own website/server to do the emailing and storing long-term. However, storing the input short-term (the length of the chat session) is what the slots already do.
To return a dynamic reply based on the data in the slots, you will have to handle the Lex input that is sent to a Lambda Function, and build your Lex Response there.
Here are the documentations that should help:
Create a Lambda Function
Handling Lex Inputs in your Lambda Function
There is also a video tutorial on walking you through setting up the Lex bot with Lambda and testing it out: Intro to Lex - Bot Setup With Lambda

Related

Using data movement sdk ,want to remove collection from docs in real time in marklogic?

Actually I am new to data movement SDK,I want to know how we can used data movement sdk to remove collection from docs which match's specific condition in real time in marklogic ?
Yes, DMSK can reprocess documents in the database including modifying the collections on the documents.
The most efficient way to change document collections on the server might be to take an approach similar to the out-of-the-box ApplyTransformListener (as summarized by
https://docs.marklogic.com/guide/java/data-movement#id_51555) but to execute a custom module instead of a transform.
Summarizing the main points:
Write an SJS (Server-Side JavaScript) module that declares a variable (using the JavaScript var statement) to receive the document URIs sent by the client and modifies the collections on those documents using a function such as
https://docs.marklogic.com/xdmp.documentSetCollections
Install the SJS module in the modules database as described here
https://docs.marklogic.com/guide/java/resourceservices#id_13008
Create a QueryBatcher to get the document URIs either from a query on the database or from a client iterator as described here:
https://docs.marklogic.com/guide/java/data-movement#id_46947
Supply a lambda function for the QueryBatcher.onUrisReady() method - see
https://docs.marklogic.com/javadoc/client/com/marklogic/client/datamovement/QueryBatcher.html#onUrisReady-com.marklogic.client.datamovement.QueryBatchListener-
In the lambda function, construct and execute a ServerEvaluationCall to the SJS module, assigning the variable to the URIs passed to the lambda function - see:
https://docs.marklogic.com/guide/java/resourceservices#id_84134
Be sure to register failure listeners using the QueryBatcher.onQueryFailure() ApplyTransformListener.onFailure​() methods to log error or otherwise respond to the unexpected.
Hoping that helps,

Customize Twilio's click-to-call, transcribe and collect statistics

I'm using Java but the question is language-agnostic, so I posted it under twilio-PHP tag too.
My application needs to connect two customers: A and B. I want to transcribe the conversation and find out whether one of the parties did not pick up and screened the other to voicemail.
I'm following the steps in the click-to-call-tutorial
However, it looks like the Rest API supports recording but not transcription. I successfully can do:
Map<String, String> params = new HashMap<String, String>();
params.put("From", myTwilioNumber);
params.put("To", customerAPhoneNumber);
params.put("Url", "http://MyHandler.jsp");
params.put("IfMachine", "Hangup");
params.put("Record", "true");
Call call = client.getAccount().getCallFactory().create(params);
which gets the entire conversation recorded, but not transcribed!
As a side note -
params.put("IfMachine", "Hangup");
indeed hangs up, when reaches voicemail, but not before leaving a voicemail with random noise. Looks like Twilio's "probing" the response, and by the time it understands it got to voicemail, background noises have been recorded. Which is terrible user experience. Any advice?
Additionally, my call handling servlet does:
TwiMLResponse twimlResponse = new TwiMLResponse();
Say sayMessage = new Say(
"Hi, customer A, stay on line to speak with customer B?");
twimlResponse.append(sayMessage);
Dial dial = new Dial(customerBPhoneNumber);
twimlResponse.append(dial);
But when I'm looking at the TwiML Verbs , there is no place where I can set params.put("IfMachine", "Continue") . So the field call.getAnsweredBy() is null for the second call. In other words, I cannot know whether conversation between customer A and B ever happened.
Additionally, [TwiML Verb Record] ( https://www.twilio.com/docs/api/twiml/record ) does allow transcription, but if I do
twimlResponse.append(new Record());
it stops the conversation and records one of the customers.
So I cannot direct the REST API to transcribe, and TwiML Verbs does not even record the conversation in a way I want.
Can anyone help?
Thanks.
Twilio developer evangelist here.
I'm afraid that when recording both legs of a call, using the REST API, then transcription is not available. Transcription is only available on single messages recorded by the <Record> verb when the recording is under 2 minutes long.
I'd recommend recording the call and downloading the file to be sent off to a third party transcription service in order to transcribe longer, 2 legged calls like that.
In terms of the answering machine detection, it is an experimental feature and requires Twilio to listen to the first few seconds of a call to work out whether it is a machine or not. A good alternative, which can work as part of your <Dial> verb as well, is to use call screening. This is a good article on the pros and cons of AMD, as well as a good description of using human detection by call screening.
Let me know if this helps at all.

Adding custom attributes to Task?

How can i add custom attributes/data to Task via API . for example we wanted to add field like customer contact number or deal amount e.t.c
We don't currently support adding arbitrary metadata to tasks, though it's something we're thinking about. In the meantime, what many customers do is to simply put data in the note field in an easily-parseable form, which works well and also lets humans reading the task see the e.g. ticket number.
It's not a terribly elegant solution, but it works.
https://asana.com/developers/documentation/getting-started/custom-external_data
Custom external data allows a client application to add app-specific metadata to Tasks in the API. The custom data includes a string id that can be used to retrieve objects and a data blob that can store character strings.
See the external field at https://asana.com/developers/api-reference/tasks

verifying a single attendee with email

Is there a method to return a specific attendee's information by sending:
1) the attendee's email address
2) my user_key
3) my app_key
I could do this by searching the returned xml from this "event_list_attendees" method, however, I would prefer to only receive the one result (not hundreds for each call).
Note: I work on the platform team at Eventbrite
Currently there is no way to search for a specific attendee with event_list_attendees.
However, you can cut down on the amount of data returned by paging through the results until you have found the attendee or using the modified_after parameter if you know when the user was last updated: http://developer.eventbrite.com/doc/events/event_list_attendees/
I realize this limitation is non-ideal. We're actively working on building a new API which is more RESTful and does not have issues like this.

Save data from api request to a model (JSON)

Ok, so over the last week or so I have been getting to grips with making api calls and then having the response returned as JSON and then outputting the parts I want to my view (getting there i think, albeit slowly). The next part of my learning curve is to take this data and save it to a model so that i can use it elsewhere in my app.
What i want to achieve is after the api request has been made and the results are displayed I want to click a button that will then post the data to my model
In this example I am getting data for books via its ISBN number from the itunes api
here is an example of the data returned
{
"resultCount":1,
"results": [
{"kind":"ebook", "artistId":545975179, "artistName":"Gareth Halfacree", "price":9.99,
"description":"<p><b>Make the most out of the world’s first truly compact computer<\/b><\/p><p>It's the size of a credit card, it can be charged like a smartphone, it runs on open-source Linux, and it holds the promise of bringing programming and playing to millions at low cost. And now you can learn how to use this amazing computer from its co-creator, Eben Upton, in <i>Raspberry Pi User Guide<\/i>. Cowritten with Gareth Halfacree, this guide gets you up and running on Raspberry Pi, whether you're an educator, hacker, hobbyist, or kid. Learn how to connect your Pi to other hardware, install software, write basic programs, and set it up to run robots, multimedia centers, and more.<\/p><ul><li>Gets you up and running on Raspberry Pi, a high-tech computer the size of a credit card <\/li><li>Helps educators teach students how to program <\/li><li>Covers connecting Raspberry Pi to other hardware, such as monitors and keyboards, how to install software, and how to configure Raspberry Pi <\/li><li>Shows you how to set up Raspberry Pi as a simple productivity computer, write basic programs in Python, connect to servos and sensors, and drive a robot or multimedia center <\/li><\/ul><p>Adults, kids, and devoted hardware hackers, now that you've got a Raspberry Pi, get the very most out of it with <i>Raspberry Pi User Guide<\/i>.<\/p>", "genreIds":["10017", "38", "9027"], "releaseDate":"2012-08-30T07:00:00Z", "currency":"USD", "genres":["Computers", "Books", "Computers & Internet"], "trackId":559783692, "trackName":"Raspberry Pi User Guide", "artistIds":[545975179], "artworkUrl60":"http://a2.mzstatic.com/us/r30/Publication/v4/ba/a8/2c/baa82ce0-2ac7-7026-04da-6f74bc97b403/9781118464496.60x60-50.jpg", "artistViewUrl":"https://itunes.apple.com/us/artist/gareth-halfacree/id545975179?mt=11&uo=4", "trackCensoredName":"Raspberry Pi User Guide", "formattedPrice":"$9.99", "artworkUrl100":"http://a4.mzstatic.com/us/r30/Publication/v4/ba/a8/2c/baa82ce0-2ac7-7026-04da-6f74bc97b403/9781118464496.100x100-75.jpg", "trackViewUrl":"https://itunes.apple.com/us/book/raspberry-pi-user-guide/id559783692?mt=11&uo=4", "averageUserRating":2.5, "userRatingCount":5}]
}
I would like to save the artistName, Description, an image (would i need paperclip for this?) and the trackName
Can anyone offer some advice on how i go about this, obviously I create a model and setup the table columns (I understand that the column names can be anything?) but after this Im a little lost
If anyone could proviede an Example that would be great as I could then follow the process and understand what is going on
Any help appreciated
One option would be to create a before_filter on your controller, you can list the controller actions that you want it performed for, ie. your API calls.
Within the method called from the before filter you can save the details of the request to a model. This would avoid the need for manually saving the information.
The image based on your example response has a URL to the image so you could just save that to your model assuming you are confident the image URL will not change. Should you want to save the image itself, yes I would recommend something like paperclip or carrierwave.
If you don't want to do it this way then an alternative, and in my opinion less tidy way would be to post the JSON back with a button to a controller action that does what I mentioned above.
EDIT: So to save to you model, for example called ApiCall you could create a new db entry each time your controller action is hit. Say your controller action is called get_info and it is passed the params that enables you to build the JSON response that you have described. You could do something like below.
json_response = JSON.parse(your_response_object)
ApiCall.create(:artist_name => json_response["results"]["artistName"])
You could obviously include any/all the information you had. Alternatively you could store the whole response as a YAML string in one db attribute and parse the information when retrieving it, up to you.
yaml = your_response_object.to_yaml
ApiCall.create(:payload => yaml)

Resources