wit.ai capture free text from whatever the user gives you - wit.ai

I have the following problems.
I have several points into the conversation where I have to capture "free" text.
Ex: what are your thoughts on xyz ? why do you want xyz ?... They are opened questions and the user can answer whatever they want.
How to I enable this ? because I tried different combinations and the bot either repeats some questions or skips some ?
Thank you

If you're using the converse api you can try to set a corresponding context property before you send the response back to wit.ai and then use the updated context in your story.
For instance, I created a test story for you (the app is empty - just created the whole thing from scratch):
As the result I was able to get into this point during the conversation:
So what you need to do is to define an action like captureUserInput in my example and instruct your bot to await for a certain key in your context. In my example it's represented by the user_input key.
In your client app, you need to react to a corresponding action (captureUserInput in my example) appropriately.
When sending the POST to wit.ai converse API set the corresponding key. For instance:
$ curl -XPOST 'https://api.wit.ai/converse?v=20160526&session_id=some_session_id' \
-d '{"user_input":"put what the user responded here"}' \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H 'Authorization: Bearer $TOKEN'
The wit.ai engine should capture your context and take it into account when responding back to you (like This is what you said: {user_input} in my example)
I hope this will work for you. I based my findings on the following:
https://wit.ai/docs/quickstart - see the step 4
and the wit.ai reference for the converse api.

I got the same problem and ended up solving it client-side by setting a certain context. I have an older bot that doesn't have the "Stories" interface, so this solution may not apply to your case, but maybe it is of some help.
When the bot sends an open question, it should also set a special context i.e. open_question_xyz or something like that, and send it back to the client app.
When the client app receives the context, save it to some var.
Before processing the next user input, your app first checks if the open_context_xyz var is set, and if it is, instead of sending the query directly to wit.ai, it captures the raw text, and also sets a context like resolved_open_question_xyz so the bot knows where to pick up the conversation.

Related

How to define API Key in google apis explorer?

I am just testing out the Google Sheets API at:
https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets.values/append
I'm using the Try this API section to fill in the request parameters and execute the request (appending a row to a sheet).
I have followed Step 1 here:
https://developers.google.com/sheets/api/quickstart/js
In order to:
Enable Google Sheets API
Create an API Key
I therefore have:
Client ID
Client Secret
API Key
In the Try this API > Credentials section, there are two checkboxes:
Google OAuth 2.0
API key
I tried to uncheck the Google OAuth 2.0 option so that i could just make the request using the API Key - however I cannot see where I can enter the API Key.
How can I define the API Key in the Try this API section so that I can make a request with only the API Key (and not Google OAuth 2.0 ).
How about this answer?
Issue and workaround:
Unfortunately, in the current stage, "Try this API" cannot be directly used by manually inputting the API key and access token. But in this case, there is a workaround. Please see the below figure.
This is the window of "Try this API". When you see this, you can see the clickable square box at the upper right as shown in the figure. Please click it. By this, you can see the expanded "Try this API" as following figure.
Here, please input the required parameters you want to use. By this, you can see the curl sample as follows.
curl --request POST \
'https://sheets.googleapis.com/v4/spreadsheets/SPREADSHEETID/values/RANGE:append?valueInputOption=USER_ENTERED&key=[YOUR_API_KEY]' \
--header 'Authorization: Bearer [YOUR_ACCESS_TOKEN]' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '{"values":[["sample value"]]}' \
--compressed
By using this command, you can use the API by manually inputting the API key and access token.
But, here, there is an important point. At Google API, the API key cannot be used for the method except for GET method. The API key can use only GET method for the publicly shared contents. Please be careful this. So when you want to use "Method: spreadsheets.values.append" in Sheets API by manually inputting the API key and the access token, please use the access token. Because this method uses the POST method. By this, you can test the API. Also, you can see the required scopes at the official document.
By the way, when you want to use only the API key, you are not required to use --header 'Authorization: Bearer [YOUR_ACCESS_TOKEN]'. And also, when you want to use only the access token, you are not required to use &key=[YOUR_API_KEY].
At the expanded "Try this API", you can also see HTTP request and the sample script of Javascript there.
Note:
When you want to request the Sheets API using the API key, please publicly share the Spreadsheet. By this, the value can be retrieved using the GET method like "Method: spreadsheets.values.get", "Method: spreadsheets.get" and so on.
When you want to see the method for retrieving the access token, you can see it at the official documents like here, here.
Reference:
Method: spreadsheets.values.append
I think the correct answer to this question is: It is not possible to use the API Explorer to actually send a request to a Google API if that API requires any sort of API key. The Explorer appears to be for creating requests that you then copy and use in your code. There does not appear to be any way to add the API key (or anything else) directly to the Explorer interface.
This all begs the question of why the Explorer has an "EXECUTE" button if you cannot execute anything (except perhaps API requests that do not require any sort of access credentials).
It is bizarre. I would love to be proven wrong, but I don't think I am.

Where to use the API authorisation key in this API?

I am working with the following api:
https://www.football-data.org/documentation/api
I have gotten myself an api key and I tried to make the example request:
https://api.football-data.org/v2/teams/86/matches?status=SCHEDULED
of course I get the error
{"message":"The resource you are looking for is restricted. Please pass a valid API token and check your subscription for permission.","errorCode":403}
So the question is, is how do I give the website my api key to allow me to make these requests?
Looking at the python snippet they create a dictionary with the the api key as a value and pass that to the request. How can I make this in my browser?
I tried
https://api.football-data.org/v2/teams/86/matches?status=SCHEDULED&%22X-Auth-Token%22=%22MYAPIKEY%22
and it did not work.
You are passing your API key as a query parameter, which is not in line with the API specification.
The API needs the key as an HTTP header. You cannot easily do that in a web browser. I'd suggest getting something like Postman or to do it on the command-line:
curl -i -H "X-Auth-Token: MYAPIKEY" "https://api.football-data.org/v2/teams/86/matches?status=SCHEDULED"
You might have figured it out by now, but I am dropping this for anyone else looking on how to do it in Python:
import requests
from pprint import pprint
token = "" # Write the api key emailed to you here
headers = {
'X-Auth-Token': token,
}
r = requests.get('http://api.football-data.org/v2/competitions/EC/teams', headers=headers).json()
pprint(r, indent=2, depth=1, compact=True)
If you're using postman like #Jakob Löhnertz suggested.
You want to first enter the api
Then go over to the Headers tab, put in "X-Auth-Token" as your Key and your unique API token as your value. Hit send and you should be all good.
Finally, be sure to go through here to see the list of available competitions for a free account.

Podio filter results missing external_id

Items returned by filter have their external_id set to null for one of our apps. For example, running this:
curl -X POST -H 'Content-Type: application/json' -H 'Authorization: OAuth2 [Token]' -d '{"limit":1}' 'https://api.podio.com/item/app/[App ID]/filter?fields=items.view(micro).fields(external_id)'
Returns all the requested data for one app:
{"filtered":119,"total":119,"items":[{"sharefile_vault_url":null,"title":"Title...","app_item_id":119,"link":"https:\/\/podio.com\/...","item_id":1234,"sharefile_vault_folder_id":null,"app_item_id_formatted":"VJD119","external_id":"share_1234","revision":0}]}
The same request returns this for another app:
{"filtered":138,"total":138,"items":[{"sharefile_vault_url":null,"title":"Title...","app_item_id":149,"link":"https:\/\/podio.com\/...","item_id":5678,"sharefile_vault_folder_id":null,"external_id":null,"revision":16}]}
Do I need to configure anything in Podio to get it to provide an external_id for the items? The first app is just a copy of the second one so it shouldn't be configured differently.
I've redacted some of the returned data, let me know if any of that is needed to help debug. We're actually using the PHP library for this, but since directly calling the API as above has the same issue I don't think that's relevant.
Most likely items from your second app have no external_id, and that's why Podio API returns null.

Survey Monkey API- Getting Long Lived Access Token

I am currently unable to figure out how to obtain my long-lived access token so I can create an API data feed from Survey Monkey to Alteryx.
Thus far I have been able to:
1) Go to the OAUTH page
https ://api.surveymonkey.net/oauth/authorize?redirect_uri=https:// www.surveymonkey.com&client_id=[MY-CLIENT-ID]&response_type=code
2) Authenticate access (I am not a robot: reCAPTCHA)
3) Get the Authentication Response with the short-lived code
https: //www. surveymonkey.com/home/?code=[CODE-FROM-RESPONSE]
4) Got stuck
From: https://developer.surveymonkey.com/docs/guides/oauth-guide/
To make the exchange, simply create a form-encoded ( Content-Type: application/x-www-form-urlencoded) HTTP POST request to https://api.surveymonkey.net/oauth/token?api_key=YOUR_API_KEY with the following encoded form fields: client_secret, code, redirect_uri and grant_type. The grant type must be set to "authorization_code".
This is not a "simply" for me, and would really appreciate the expression so I can enter that into my browser so I can retrieve my long-lived access token.
End goal is that I am using Alteryx to pull in the Survey Monkey data via API and creating a blended data set with additional system data. The combined data set will then feed a Tableau Dashboard. I'm sure it is a long-shot, but if anyone has an Alteryx workflow for Survey Monkey API that would solve all of my issues at once.
Thank you in advance for your insights/ guidance.
With gratitude,
Drew
(Note- I added spaces to a few of the links, as I do not have 10 reputation points; yet).
There is an example cURL request at the side of the docs here. You need to make a POST request to /oauth/token. It'll look something like this:
curl -X POST -H "Content-Type: application/x-www-form-urlencoded" -d 'code=<code>&client_id=<client_id>&client_secret=<client_secret>&redirect_uri=<redirect_uri>&grant_type=authorization_code' "https://api.surveymonkey.net/oauth/token"
Filling in the values in <>. Or in Python, something like this should work:
import requests
url = "https://api.surveymonkey.net/oauth/token"
payload = {
"code": "<code>",
"client_id": "<client_id>",
"client_secret": "<client_secret>",
"redirect_uri": "<redirect_uri>",
"grant_type": "authorization_code"
}
headers = {
'content-type': "application/x-www-form-urlencoded"
}
response = requests.request("POST", url, data=payload, headers=headers)
I'm pretty sure the requests library will automatically convert the body to the right type, but if not payload just looks like URL params:
payload = "code=<code>&client_id=<client_id>&client_secret=<client_secret>&redirect_uri=<redirect_uri>&grant_type=authorization_code"
Essentially though, you just need to make a POST request to /oauth/token with the payload provided above (code, client_id, client_secret, redirect_uri, and grant_type). The main confusing part is you can't send in a JSON body, it has to be a form body that looks like my example above.
Hope that helps.
You should be able to take the response that General Kandalaft has provided and enter each of those into the Download Tool in Alteryx. Create a field for each of client id, client secret, code, redirect_uri & grant_type and then tick those fields on the Payload Tab.
Set the HTTP Action to POST on the same tab.
There are also some examples of Oauth processes on the Alteryx Community and Gallery.
In general, when converting cURL requests to the Download Tool, -d/-F will be payload tab and -H of course will be Headers tab. form encoded etc is normally correct already and only needs to be added/changed very occasionally.
As another note, if you can't figure out the conversion of a cURL request or it's more complicated (i.e. attaching a PEM file to the call), you will find a copy of cURL in your Alteryx install directory and you can use the Run Command Tool to run that.
Kane

Can I retrieve Salesforce data out of SF using the REST API?

I'm having a bad time figuring out if I can retreive an authenticated user's data using the REST API.
I have managed to authenticate using OAuth 2.0, retrieve all the SObjects ( and each object instances description) using the REST API, but can't figure out how can I can I retrieve the actual data for each object instances.
I have read the article on "which API should I use?" but it's just not clear enough.
Does any of this makes sense?
You can use the SOQL Query REST endpoint /services/data/{version}/query?q={soqlQuery}, e.g. with curl
curl -v https://na1.salesforce.com/services/data/v34.0/query?q=SELECT+ID,NAME+FROM+ACCOUNT -H "Authorization: Bearer $SID"
If you've already got the SObject definitions then you can use the object/field info to programmatically build the queries (there's no select *, so you need to include every field you want)
you may want to use
URI something like /vXX.X/sobjects/SObjectName/updated/?start=startDateAndTime&end=endDateAndTime
SObjectName can be Account, Opportunity,OpportunityLineItem