I'm having problems writing a custom payload on DialogFlow to get a Kik bot to send video's. I wrote my own custom payload, but will not send no matter where the videourl is coming from. Here's what I already have:
{
"kik": {
"type": "video",
"videoUrl": "https://6oifeq.bn.files.1drv.com/y4m2tTfznJjwSNUR5OknxluI1LUdv5-EFVdpSNDNouEaEEA6ftWVOBoJ20jsrln7xXb0BrUZ_PC2EuUSCVq1l4P2h1z3TbZLD2vqvCmNY0ebgwUTVRrvF5qyvQ6eUJbvIgPlTtQW6rHcIDDl4IU5lqCw62kBfFv2R4j7zYgV6fz-aev4jXqgivj6QR5MrcelkeZ/5fcf21c1-b250-4366-9810-3f98c716026a.mp4?psid=1?",
"video-should-be-muted":false
}
}
Using Dialog Flow to send Videos on Kik with a custom payload.
The custom payload on Dialog Flow to send videos on Kik is solved. Follow this format:
"kik": {
"type": "video",
"videoUrl": "https://6oifeq.bn.files.1drv.com/y4mPnHGxDM_GoQ4oo9nEBx27nqrnfA3H_uRQPY0m2WI91qoPy75o1Y3RHpV3TXta_CM3mMpWpP20VzEmUS9_ruiEmrU7c8G15oclWBH7BmfZgzPoa38B63pT86RdJOkv8V9FvEIu4wYjGiyzE0IZT4nWhlIL9bE4T2wgDzBf7U5haulPNTBBH8DkLY7_MzkL0iu/5fcf21c1-b250-4366-9810-3f98c716026a.mp4?psid=1?",
"autoplay": true
}
}
Related
I am trying to upload a text file to OneDrive using Graph APIs and I also want to update it in the same request using JSON batch.
My JSON request body is below:
{
"requests":[
{
"id":"1",
"method":"PUT",
"url":"/drives/b!ddubdQaackeT9nu3x4onivgPxHH2-
gpFsk_mo9hryZabqK7w279YSpMqiNodZDaa/items/01BTTSDZ56Y2GOVW772
5BZO354PWSELRRZ:/abc2.txt:/content",
"headers":{
"Content-Type":"application/octet-stream",
"Content-Length":"21"
},
"body":{
"content":"Test content for body"
}
},
{
"id":"2",
"method":"PATCH",
"url":"/drives/b!ddubdQaackeT9nu3x4onivgPxHH2-
gpFsk_mo9hryZabqK7w279YSpMqiNodZDaa/items/01BTTSDZ56Y
2GOVW7725BZO354PWSELRRZ:/abc2.txt",
"headers":{
"Content-Type":"application/json; charset=utf-8"
},
"body":{
"fileSystemInfo":{
"lastModifiedDateTime":"2020-08-09T00:49:37.7758742+03:00"
}
},
"dependsOn":["1"]
}
]
}
When I send this request from my code, I always get a response "Invalid body for request id: 1. The body must be a valid base64 string or JSON.".
Postman refused to run the above request with the message "Method not allowed".
In the above example, I am uploading and updating text files but my code will have to handle all file types (e.g. images, videos, etc.)
Not sure if I am correctly specifying all the JSON fields. Unfortunately unable to find much info on this. Any help would be appreciated.
I'm just doing the preparation for an integration with EasyPost's Shipping API, which will be server side C#, but we always build a PostMan collection for new integrations, so that we can test data separately from the application if there's an issue.
While I do love the fact that EP provide C# libraries and examples, I'm struggling to find anything that just gives me a list of required headers and the raw JSON format for the body of any requests. It feels a bit like they're just being a little too helpful.
I'll be looking at the Orders endpoint probably.
I've got an account, I've checked all their documentation and searched the internet but haven't found anything so I'm hoping I'm not the first developer to want to use a client application for testing outside my code.
Update:
EasyPost now does have a public workspace https://www.postman.com/easypost-api
with at least 1 public collection
The curl examples are basically the same as json:
For the Address creation example:
-d "address[street1]=417 MONTGOMERY ST"
is the equivalent of
{ "address": { "street1": "417 MONTGOMERY ST" } }
(you might have to escape some characters to be valid json).
Check out How to stimulate cURL request to a request using postman for postman with HTTP Basic Auth.
EasyPost does not provide a public Postman collection; however, here is an example of a shipment Postman body (raw) that could be used. You can adjust the values, actions, objects, etc to your needs.
Using the following, you shouldn't need to pass any headers. You'll pass your API key under the username field with the Basic Auth authorization type.
{
"shipment": {
"to_address": {
"id": "adr_123..."
},
"from_address": {
"id": "adr_123..."
},
"parcel": {
"id": "prcl_123..."
},
"carrier_accounts": {
"id": "ca_123..."
},
"options": {
"address_validation_level": "0"
}
},
"format": "json",
"controller": "shipments",
"action": "create"
}
I have:
An JavaScript Azure Function in an HTTP webhook configuration; the Function provides a URL; the Function performs an action
A webhook configured in the software I hope to receive notifications from
An Azure Logic App with an HTTP/webhook step that provides a URL for the webhook notification to go to
My goal is that the Azure Function's URL receives notifications from the software's webhook and performs an action. The Azure Logic App is for testing only.
What works
When the the Azure Logic App's URL is used in the software's webhook configuration, the desired action is performed. All works as expected.
The Azure Logic App's logging shows the JSON output from the incoming webhook. I expect (but believe this may be where I am going wrong) that this is the JSON the webhook is sending to the Azure Logic App's URL. When this JSON is used in the Azure Function UI's "Test" tab > "Request body" field, the desired action is performed. All works as expected.
When the Azure Function's URL and the JSON is in a Postman request, the desired action is performed. All works as expected.
What doesn't work
When the Azure Function's URL is used in the software's webhook configuration, no action is performed. This is of course my goal. From everything I have read, I understand that this URL as a webhook endpoint should work.
Azure Function's URL
This is from Get function URL > default (Function key).
https://<app_name>.azurewebsites.net/api/content?code=<api_key>
Other Azure Function config settings
Allowed HTTP methods: GET, POST
Authorization level: Function
The JSON I believe to be coming over the webhook
{
"headers": {
"Expect": "100-continue",
"Host": "redacted",
"X-Telligent-Webhook-Sender": "redacted",
"Content-Length": "16908",
"Content-Type": "application/json; charset=utf-8"
},
"body": {
"events": [{
"TypeId": "ec9da4f4-0703-4029-b01e-7ca9c9ed6c85",
"DateOccurred": "2018-12-17T22:55:37.7846546Z",
"EventData": {
"ActorUserId": 9999,
"ContentId": "redacted",
"ContentTypeId": "redacted",
"ForumReplyId": 9999,
"ForumThreadId": 9999,
"ForumId": 9999
}
}]
}
}
I also tried with the following test code for the same results. It aligns more closely with the sample payload data provided by the software company:
What I tried
{
"events": [{
"TypeId": "ec9da4f4-0703-4029-b01e-7ca9c9ed6c85",
"DateOccurred": "2018-12-17T22:55:37.7846546Z",
"EventData": {
"ActorUserId": 9999,
"ContentId": "redacted",
"ContentTypeId": "redacted",
"ForumReplyId": 9999,
"ForumThreadId": 9999,
"ForumId": 9999
}
}]
}
Sample payload data
{
"events": [
{
"TypeId": "407ad3bc-8269-493e-ac56-9127656527df",
"DateOccurred": "2015-12-04T16:31:55.5383926Z",
"EventData": {
"ActorUserId": 2100,
"ContentId": "4c792b81-6f09-4a45-be8c-476198ba47be"
}
},
{
"TypeId": "3b75c5b9-4705-4a97-93f5-a4941dc69bc9",
"DateOccurred": "2015-12-04T16:48:03.7343926Z",
"EventData": {
"ActorUserId": 2100,
"ContentId": "4c792b81-6f09-4a45-be8c-476198ba47be"
}
}
]
}
I do not know how to determine why the Azure Function is not triggered by the webhook. The software's API documentation does not seem to provide a way to look at the JSON being sent over the webhook, although in my inexperience I may be wrong.
Is there a mechanism within Azure, or Postman, or another tool that lets me see what JSON is being sent over the webhook? Or perhaps is there another approach to determining the cause of the issue?
Thank you for any help.
This is how I got the JSON file from Azure alerts.
Install Ruby on the server
Install Sinatra with following command gem install sinatra
Create file webhook.rb and paste code bellow
require 'sinatra'
set :port, 80
set :bind, '0.0.0.0'
post '/event' do
status 204 #successful request with no body content
request.body.rewind
request_payload = JSON.parse(request.body.read)
#append the payload to a file
File.open("events.txt", "a") do |f|
f.puts(request_payload)
end
end
Run the web service with command ruby webhook.rb
JSON fill be written to file events.txt
I am trying to access the office 365 calendar api to create an event. The steps i followed are
Created app and registered it in azure
Gave permisissions to the app
Hitting https://login.microsoftonline.com/{{tenantid}}/oauth2/token to get the access token
body :
{
"grant_type":"client_credentials",
"client_id": "*****",
"client_secret": "****",
"resource":"https://outlook.office.com"
}
Response :
{
"token_type": "Bearer",
"expires_in": "3600",
"ext_expires_in": "262800",
"expires_on": "1532026206",
"not_before": "1532022306",
"resource": "https://outlook.office.com",
"access_token":"******"
}
When i pass this access token to https://outlook.office.com/api/v2.0/me/events which creates events. it gives me 401 unauthorised. Body of the request is as shown below. Someone please assist.
{
"Subject": "Discuss the Calendar REST API",
"Body": {
"ContentType": "HTML",
"Content": "I think it will meet our requirements!"
},
"Start": {
"DateTime": "2019-02-02T18:00:00",
"TimeZone": "Pacific Standard Time"
},
"End": {
"DateTime": "2019-02-02T19:00:00",
"TimeZone": "Pacific Standard Time"
},
"Attendees": [
{
"EmailAddress": {
"Address": "arulvelug#hexabot.onmicrosoft.com",
"Name": "Arulvelu G"
},
"Type": "Required"
}
]
}
To do authorization of office 365 and use REST API via Postman, here is a solution for your reference:
First: get security Token
Access [https://login.microsoftonline.com/extSTS.srf] via Http Post method. The content of the http request is as follows.
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope"
xmlns:a="http://www.w3.org/2005/08/addressing"
xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-
utility-1.0.xsd">
<s:Header>
<a:Action
s:mustUnderstand="1">http://schemas.xmlsoap.org/ws/2005/02/trust/RST/Issue</a:Action>
<a:ReplyTo>
<a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address>
</a:ReplyTo>
<a:To s:mustUnderstand="1">https://login.microsoftonline.com/extSTS.srf</a:To>
<o:Security s:mustUnderstand="1"
xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<o:UsernameToken>
<o:Username>[username]</o:Username>
<o:Password>[password]</o:Password>
</o:UsernameToken>
</o:Security>
</s:Header>
<s:Body>
<t:RequestSecurityToken xmlns:t="http://schemas.xmlsoap.org/ws/2005/02/trust">
<wsp:AppliesTo xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
<a:EndpointReference>
<a:Address>[endpoint]</a:Address>
</a:EndpointReference>
</wsp:AppliesTo>
<t:KeyType>http://schemas.xmlsoap.org/ws/2005/05/identity/NoProofKey</t:KeyType>
<t:RequestType>http://schemas.xmlsoap.org/ws/2005/02/trust/Issue</t:RequestType>
<t:TokenType>urn:oasis:names:tc:SAML:1.0:assertion</t:TokenType>
</t:RequestSecurityToken>
</s:Body>
</s:Envelope>
The demonstration screenshot in Postman:
And the response content will include a security token as below, we can use this security token to get Access Token of office 365.
Second: get Access Token
Here i show you how to get access token, I get it of my SharePoint using the security token.
Access [https://yourdomain.sharepoint.com/_forms/default.aspx?wa=wsignin1.0] via http Post method. The content of the request is the security token that we have got above as below.
And the response as below:
We can see that there are two cookie, rtFa and FedAuth in response header, and these two cookie need to be added to the request in subsequent request.
Third: get Request Digest
Access [https://yourdomain.sharepoint.com/_api/contextinfo] via http Post method with that two cookies which we have got above.
And the response as below:
This is the final Token we want!
Then we can use REST API of our app in O365, like SharePoint , we only need to add this token and the previous two cookie, as shown in the following figure.
I am setting up a Chatbot for my Facebook page with Google Dialogflow handling the conversations.
For a specific Intent, I need to send 2 responses.
A regular statement with User's name put in.
A Persistent menu with 3 buttons
I understand that for a single Intent, I can't send the first response via Fulfillment code and the 2nd response setup through Dialogflow console UI. Hence, I need to write code to send both the responses.
I am able to send the first Response. But couldn't get to send a Rich message content. The DialogFlow documents show snippets of code, but it is unclear how the snippets of code from different pages fit it.
Here is my code (just posting actionHandlers) in an attempt to send a statement and an Audio (https://dialogflow.com/docs/rich-messages#custom_payload)
const actionHandlers = {
'input.welcome': () => {
const speechText = 'Hi ' + userProfile['first_name'] + ', This is Eva, digital assistant of LMES Academy. Since my people are busy working on the content for the next video, I\'d like to help you with your needs 😃';
const responsePayload = {
'speech': speechText,
'outputContexts': [{
'user-name': userProfile.first_name
}],
"data": {
"facebook": {
"attachment": {
"type": "audio",
"payload": {
"url": "http://incompetech.com/music/royalty-free/mp3-royaltyfree/Funk%20Game%20Loop.mp3"
}
}
}
}
};
sendResponse(responsePayload);
},
// The default fallback intent has been matched, try to recover (https://dialogflow.com/docs/intents#fallback_intents)
'input.unknown': () => {
sendResponse('I\'m having trouble, can you try that again?'); // Send simple response to user
}
};
The text response is working but the Audio is not. Am I doing the right way? Any help appreciated.
Update 1: Audio is working, after changing the mp3 link. But text response is not working.
Log of the object that is sent to response.json() in my Cloud function.
{
"speech": "Hi Saiyasodharan, This is Eva, digital assistant of LMES Academy. Since my people are busy working on the content for the next video, I'd like to help you with your needs 😃",
"displayText": "Hi Saiyasodharan, This is Eva, digital assistant of LMES Academy. Since my people are busy working on the content for the next video, I'd like to help you with your needs 😃",
"data": {
"facebook": {
"attachment": {
"type": "audio",
"payload": {
"url": "http://66.90.93.122/ost/death-note-original-soundtrack/bowkqzxs/01%20Death%20note.mp3"
}
}
}
},
"contextOut": [{
"user-name": "Saiyasodharan"
}]
}
In above code, I expect
displayText to be displayed immediately -> which is not working
audio response to happen -> This is now working, after changing the mp3 link
I believe I need to give the text response, audio response via data property. Let me try and update here.
If you use a payload for a given integration, the text of the response will be ignored. You'll need to add your message with the attribute text to the facebook payload for it to be surfaced in Facebook messenger. For example:
{
"contextOut": [
{
"user-name": "Saiyasodharan"
}
],
"data": {
"facebook": {
"attachment": {
"payload": {
"url": "http://66.90.93.122/ost/death-note-original-soundtrack/bowkqzxs/01%20Death%20note.mp3"
},
"type": "audio"
},
"text": "Hi Saiyasodharan, This is Eva, digital assistant of LMES Academy. Since my people are busy working on the content for the next video, I'd like to help you with your needs 😃"
}
},
"displayText": "Hi Saiyasodharan, This is Eva, digital assistant of LMES Academy. Since my people are busy working on the content for the next video, I'd like to help you with your needs 😃",
"speech": "Hi Saiyasodharan, This is Eva, digital assistant of LMES Academy. Since my people are busy working on the content for the next video, I'd like to help you with your needs 😃"
}