Get Facebook user's name fram DialogFlow - dialogflow-es

The following was described to me as a solution to my problem:
In the fulfillment code, parse the parameter of fulfillment request and retrieve the value of originalDetectIntentRequest JSON field. For more information about OriginalDetectIntentRequest.
However, I don't know where to start in actually implementing this. What should it look like?

You cannot get things like the user's first_name from DialogFlow. To do that first you need to get the PSID from DialogFlow webhook JSON:
PSID = originalDetectIntentRequest -> payload -> data -> sender -> id
Then you need to make a post request to FB Graph for Retrieving a Person's Profile.
Something like this:
curl -X GET "https://graph.facebook.com/<PSID>?fields=first_name,last_name,profile_pic&access_token=<PAGE_ACCESS_TOKEN>"
You can find more details about getting messenger user's data in:
https://developers.facebook.com/docs/messenger-platform/identity/user-profile/#fields

Related

Google Form API - unable to retrieve a respondent email

I am using Google Form API to create a sample project to create, update & get responses to a form.
I am using the following documentation for reference and understanding:
https://developers.google.com/forms/api/reference/rest/v1/forms.responses
It mentions that a single response body (using response ID) includes the respondent email, but each time I trigger the API, the respondent email is undefined and hence does not get returned in the response body.
What am I doing wrong?
Please note I am not using the Apps Script. I am using the API in a node.js project.
Thank you

How do you call a 3rd party API from inside watson assistant?

Creating a chatbot using IBM's Watson Assistant, and I need to make a determination I'm trying to send the zip code to a third party API that will return the city and state so I know where the client is located so I can (a) know which services are available and (b) have a better idea on how to direct the conversation from there. But I am at a loss as to how to do this.
I can do this from within Python, but trying to code it in a JSON editor doesn't work.
Webhooks are used to do this from inside the Dialog skill in an Assistant.
IBM Watson Assistant webhooks documentation
The docs do not mention it, but the Assistant will POST to the URL with a JSON body containing the parameters you specify as key value pairs. For example if in the Dialog Node the context variable $zipcode equals '99501' and you specify the parameters "key" = zipcode and "value" = "$zipcode".
Then the HTTP post body is
{ "zipcode" : "99501" }
The response from the service is put into another context variable, and this can then be used for other things. For example in the Dialog Node which calls the webhook, in the "Return variable" section put webhook_result_zipcode to put the response into that context variable.
You can also in the dialog node Assistant responds section, return a message which contains some part of the webhook response. For example in the Dialog Node editor
"If assistant recognizes" $webhook_result_zipcode "Respond with" The code is "$webhook_result_zipcode.response.result.sent" This will tell the user the code which is returned deep within the webhook response in response.result.sent in the response body.
You can also click the Cog next to the response, and in the dialog, click ... next to "Assistant responds" and open the context editor. This opens a context editor (at the top of the dialog) which allows setting of another context variable from part of the webhook response. For example under "Then set context" for "Variable" set zipcode and for "Value" set "$webhook_result_zipcode.response.result.sent.zipcode". This will extract a zipcode value from deep within the webhook response and place it in the context variable zipcode.
Of course then you must find a zipcode location service which accepts a HTTP post and looks for the code in the body.

Vimeo API - get all videos from a channel

I'd like to get all Vimeo's videos from a channel.
I looked to the Vimeo API, created a key for my app but I found no simple method to get all videos with for example the id of the channel...
How to do that ?
Thx.
To get the list of videos in a channel, make an authenticated GET request to https://api.vimeo.com/channels/[channel_id]/videos. The endpoint documentation can be found here: https://developer.vimeo.com/api/reference/channels#GET/channels/{channel_id}/videos
If you don't know the channel_id of a channel, you can substitute the id with the custom url of the channel. For instance, with the Staff Picks channel at https://vimeo.com/channels/staffpicks, make an authenticated GET request to https://api.vimeo.com/channels/staffpicks
That said, it's best practice to use the channel_id instead of the shortcut url name wherever possible. The Staff Picks channel, for example, returns "uri":"/channels/927"
The answer above is correct, but I found myself looking for a solution on how to get the channel id.
There two options(that I found) to get the channel id
If you have access to run js in the browser(like in Puppeteer) - run the following js
vimeo.config.channel.id
and it will return the id of the channel.
Another option is to get it via regex
\"channel\"\:\{\"id\"\:\"(\d*)\"
It's taking the following part from the tag
vimeo.config = _extend((vimeo.config || {}), {"channel":{"id":"164226","url":"\/channels\/fenwn"},"sticky_topnav":{"excluded_pages":["Vimeo\\Controller\\AboutController:main","Vimeo\\Controller\\AboutController:profe

Slack RTM API post from a given username

I have integrated the Slack RTM API into my program, and I am able to post to Slack as well as receive new messages from Slack.
The one problem I am having is when posting to Slack, the post comes from my username. I know it is possible to change the posting user in the Web API by setting the "username" and "as_user" field, so I am not sure why this would be any different. Below is my message that I am using. Comment.user.name is a string.
var message =
{
id : 1,
type : "message",
channel : self.channel,
text : comment.text,
thread_ts : self.timestamp,
username : comment.user.name,
as_user : false
};
self.websocket.send(JSON.stringify(message));
Is this possible with the way I am doing it, or is there a better way? Thanks.
It is not possible in the Slack Web API to set a user in that way. There is only one way to achieve this: Obtain an API token for the user you want to post as and use it when making your API request.

How do you set the avatar of API-triggered messages?

Looking at the slack api, I can't see any way to set the avatar of things posted through the API, although they show many examples of api messages coming with avatars, like this
I'm using chat.postMessage to post messages as my app. I can alter the username, but I can't figure out any way to set the icon.
My posts just end up looking like this:
When sending messages through a web-request - you can supply the icon_emoji property with a supported emoji name, such as:
{
..
"icon_emoji":":ghost"
}
Or, with an icon_url property:
{
..
"icon_url":"<your valid url>"
}

Resources