How to show Rich Response Buttons (''Chips) Using Dialogflow Fulfillment? - google-cloud-platform

Based on the online example I wanted to try to add Rich Response Buttons and Basic cards using Dialogflow Fulfillment and Inline editor, but I'm not getting anything rendered in the Dialogflow Messenger client. Are rich responses not fully supported?

According to the readme file, the Dialogflow Fulfillment library is no longer being maintained; therefore, it seems that you can't use rich response in Dialogflow messenger directly with this library.
Based on this, if you want to use rich responses with Dialogflow messenger, you can create a webhook service. To start testing this, I recommend you do the following:
1- Use Cloud Functions to create an HTTP function. This documentation mentions the process to create one from the Cloud Console. Please take in account this considerations in the second step:
Runtime: Python 3.8
Entry point: entry_function
Inside the inline editor, copy and paste the following code:
from flask import jsonify
def entry_function(request):
response_json = jsonify(
fulfillment_text="This message is from Dialogflow's testing!",
fulfillment_messages=[
{
"payload": {
"richContent": [[{
"actionLink": "https://assistant.google.com/",
"subtitle": "This is the body text of a card. You can even use line\n breaks and emoji! 💁",
"title": "Title: this is a card title",
"type": "info"
}]]
}
}
]
)
return response_json
Deploy the function. Afther that, enter to your function and in the 'TRIGGER' section copy the Trigger URL
2- Enable and manage fulfillment in Dialogflow
3- Test your Dialogflow messenger.

Related

How can I return hyperlinked text in a Lexresponse?

So I am building a lex chatbot and I am trying to return a response with hyperlinked text. I have the chatbot sitting on a front end but I cant seem to find a way to return responses with hyperlinks. Heres what I have so far
https://imgur.com/N6Bp2fX
https://imgur.com/zbnUsrH
Now Ive read that the responses from lex are formatted to where the chatbot is sitting. For example, in the chatbot test window on the Amazon site, returning hyperlinks is impossible, but skype automatically hyperlinks URLs. But I have mine sitting on a browser but I still cant get a hyperlinked response in the bot.
Would love if anyone could help me out! Thanks in advance!
The test console window of Lex does not support html rendering. You can instead deploy your chatbot to a channel like facebook or slack, and it will be rendered correctly.
You can use the custom markup option to send a response in the following json format to format it by your client.
{
"text": "Check out the following link",
"type":"hyperlink",
"links":[{
"linkText":"Google",
"url":"https://google.com"
}]
}
Lex can return any response that you want, but it's the responsibility of chat client to parse that response and show accordingly.
So you need to write your logic to parse hyperlink and show them.
In your case you can send response from Lex like : Please visit [link]www.google.com[\link].
Then you can write your logic to show the text in anchor tag <a> in your chat window so that it is parsed as hyperlink.
Hope it helps.

AWS .NET Core Lambda - Image Upload Broken

I'm in the process of building a Web API with AWS Lambda using .NET Core.
I have run into a problem, where the code piece below work as expected on my Windows machine (Echo the image back), but when deployed to AWS Lambda, the returned image is broken. After further investigation, the echoed back file's size is nearly double the size of the sending file when deployed on AWS?
[HttpPost]
public async Task<IActionResult> Post(IFormFile file)
{
using (var tmpStream = new MemoryStream())
{
await file.CopyToAsync(tmpStream);
var fileExtension = Path.GetExtension(file.FileName);
return File(tmpStream.ToArray(), file.ContentType);
}
}
Am I missing some configuration or overlooking something? AWS Gateway??
(I'm testing the issue via Postman)
Did you look at the contents of the file? My guess it is the html error result or something.
In this blog post (Serverless ASP.NET Core 2.0 Applications) they mention:
If your web application displays images, we recommend you serve those images from Amazon S3. This is more efficient for returning static content like images, Cascading Style Sheets, etc. Also, to return images from your Lambda function to the browser, you need to do extra configuration in API Gateway for binary data.
See API Gateway for binary data for how to configure that.
Incase anyone is looking for a solution, in addition to adding "multipart/form-data" as binary media type in the API Gateway settings, you need to add a model in the method request body of the resource.
Details can be found at https://github.com/aws/aws-lambda-dotnet/issues/635#issuecomment-616226910
Steps:
Add "multipart/form-data" as binary type in LambdaEntryPoint.cs file (if that is how it is named).
public class LambdaEntryPoint : APIGatewayProxyFunction
{
/// <summary>
/// The builder has configuration, logging and Amazon API Gateway already configured. The startup class
/// needs to be configured in this method using the UseStartup<>() method.
/// </summary>
/// <param name="builder"></param>
protected override void Init(IWebHostBuilder builder)
{
RegisterResponseContentEncodingForContentType("multipart/form-data", ResponseContentEncoding.Base64);
builder.UseStartup<Startup>();
}
}
Add BinaryMediaTypes in the settings section of the AWS API Gateway as shown
here - BinaryMediaTypes in API Gateway.
Create a new model for the API Gateway with the configuration as
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "MediaFileUpload",
"type": "object",
"properties": {
"file": { "type": "string" }
}
}
Update the method request step by adding an entry in "Request Body" using the created model as a content type of "multipart/form-data"( as shown in API Gateway Resource).
Make sure that you deploy the API so that the changes take effect.
EDIT: Added code, and additional steps for clarity, as comment by #JeremyCaney
Add BinaryMediaTypes "multipart/form-data" in the settings section of the AWS API Gateway. Deploy the Api (If you have done it before, do it again after changing the settings).

Autodesk Data Management API 403-Error

I am trying to receive data via Autodesk Data Management API. So far I've created an Forge-App and connected it with a BIM360 Integration.
Then I wanted to get a list of all hubs, but when I do so, I receive an JSON-Object which contains a warning:
warnings: [{
"AboutLink":null,
"Detail":""You don't have permission to access this API",
"ErrorCode": "BIM360DM_ERROR",
"HttpStatusCode": "403",
...
}]
I called the webservice via AJAX wich looks like that:
this.getToken(function(token) {
$.ajax({
url: "https://developer.api.autodesk.com/project/v1/hubs",
beforeSend: function(xhr) {
xhr.setRequestHeader("Authorization", "Bearer "+token);
}
}).done(...);
The token is a 3-legged one. I am not sure which API I do not have permission for because I am pretty sure, that I have permission for BIM360.(I created the Integration as an administrator).
In addition to was ZHong mentioned, I would suggest you try this sample. It will ask you to provision your Forge Client ID under your BIM 360 settings, just follow the steps that the app will present.
On both 2- or 3-legged, the app accessing the data (Forge Client ID) needs authorization from the account admin. Without that, the Hubs endpoint will not return your BIM 360 hub, and inside that, the sample applies for Projects endpoint.
Does everything else work fine? For example, can you get all the hubs successfully? I just verified on my side, and I can see the response including the same warning as you mentioned, but the hubs are listed correctly, and you can get the projects/items/versions without problem. I pasted my postman response as follow.
If you check the blog https://forge.autodesk.com/blog/tutorial-using-curl-3-legged-authentication-bim-360-docs-upload, it also has the same warning, but seems no impact to the following operation. I am not exactly sure what the warning means, l will check and update the details, but so far, it seems you can ignore it for now.

Sending SMS with cordova-sms-plugin hangs

I used cordova-sms-plugin 0.1.11 "Cordova SMS Plugin" for my ionic2 app to send text message. I just wanted to simply open the default SMS app on user's device. Below is my code:
public sendSMS(phoneNumber){
var option = {
replaceLineBreaks: false,
android: {
intent: 'INTENT'
},
ios: {
intent: 'INTENT'
}
};
SMS.send(phoneNumber, "", option)
.then(()=>{
//this.showAlert("Message sent!", "");
alert("Message sent");
}, (err)=>{
console.log("sms fail:"+err);
})
}
The code works as expected to open the SMS app on user's device. However, on the opened SMS, my users need to tap on the recipient to make the "soft keyboard" to show up and users can no longer use the functions the sms provided (like attaching photos).
Plus, users could only send one message, and the sms app closed itself and "redirect" back to my app.
If users quit my app and open their SMS app independently, the SMS app works fine again.
I don't know what I did wrong on my code. Or is there any better cordova plugin I can use that fulfills my purpose?
Thank you for your help in advance :-)
This cordova plugin (cordova-sms-plugin) is better to be used if you want to send text messages from the "backend". e.g. Design your own text message box, send button...
If you just want to open the default SMS app use the code below:
import { DomSanitizer } from '#angular/platform-browser';
then add the service to constructor:
constructor(private sanitizer:DomSanitizer)
Then the method to call:
public sanitize(url: string):any {
return this.sanitizer.bypassSecurityTrustUrl(url);
}
the method: return type use any. Some said use SafeUrl, but somehow the new service doesn't have that.
Html view:
<a [href]="sanitize('sms:' + item.sms)">

Testing HelloSign API embedded signature

Hello I am using the HelloSign API, looking to test the embedded signing feature. How am I able to test the embedded document to sign on my test site? I am using the nodejs SDK along with AngularJS. Thank you in advance.
Here's the general walkthrough for embedded signing, which walks you through the server side and client side steps: https://app.hellosign.com/api/embeddedSigningWalkthrough
Here's an FAQ on testing locally: https://faq.hellosign.com/hc/en-us/articles/217048987-What-tools-can-I-use-to-test-the-API-and-callbacks-locally-
For greater detail, please write into apisupport#hellosign.com.
-First thing is create an account with Hellosign
Next thing is creating your API KEY from your registered account.
Create an API App with your registered hellosign account (This is important because during the setup it will ask for the URL where the Iframe will be created.)
Now to use it simply include this script (<script type="text/javascript" src="https://s3.amazonaws.com/cdn.hellosign.com/public/js/hellosign-embedded.LATEST.min.js"></script>).
And then finally do this in your client side component file
HelloSign.init("CLIENT_ID");
HelloSign.open({
url: "SIGN_URL",
allowCancel: true,
messageListener: function(eventData) {
// do something
}
});
And Voila..!! It will work.