Can HowdyAI's Botkit listen for attachment contents? - botkit

Attempting to use BotKit to have a custom integration react to a 3rd party integration. The 3rd party integration only communicates via replies as attachments.
Is there a way to have the my custom integration 'hear' attachments? I haven't been able to locate this in the documentation if it does exist already.

The answer was present in the comments on the issue.
Essentially:
controller.on('bot_message', function(bot, message) {
console.log('message.attachments: ' + message.attachments);
var attachment = message.attachments[0];
console.log('attachments.title: ' + attachment.title);
console.log('attachments.text: ' + attachment.text);
});

Related

Sending Google Form Responses from Unity 401 Unauthorized

Is it still possible to programmatically send "responces" to Google Forms. Preferably without users logging in. I think they changed the protocol.
In a unity application, I need to setup a survey, and the obvious choice was google forms, since a friend of mine did in the past. However, after implementing some test code from a tutorial, I can't get responses through and not receiving any data despite following a tutorial. Instead it complains about 401 unauthorized error. Heres some code :
private string target_url =
"https://docs.google.com/forms/myForm/formResponse";
private IEnumerator RoutineSendActual()
{
WWWForm form = new WWWForm();
form.AddField( "entry.689820410", "code test" );
var www = new WWW( target_url, form.data );
Debug.Log( www.url );
yield return www;
Debug.Log( "sent " + www.error + " " + www.isDone + " " + www.responseHeaders);
foreach ( var responseKey in www.responseHeaders.Keys )
{
Debug.Log( responseKey + "|" + www.responseHeaders[responseKey] );
}
Debug.Log( www.text );
yield break;
}
Instead www.error is giving me 401 unauthorized error. I've followed the following tutorial https://www.youtube.com/watch?v=z9b5aRfrz7M
and the following questions has it working How to add value on another section in google form in Unity3d
but for me, I get 401 unauthorized. I even made sure the Forms and spreadsheet where made public and editable to everyone (which i'm worried about because could hack the data).
Also, should I instead be looking into Google Apps Script to act as an intermediary between unity web request and the actual form.
{ Note: I'm copying this from another question I answered, but I considered it an answer to my own question }
Unfortunately, it seems that this method of posting info to google forms is unreliable, as it's not well documented at all progress here is from looking at the html page code. I've followed the same tutorial and also having trouble.
But fortunately, I've found a better solution that gives you better control and access to google forms.
https://developers.google.com/apps-script/
https://developers.google.com/apps-script/reference/forms/
Instead of guessing the post API, using Google Apps Script, you can setup and deploy a web app from googles own servers in javascript, and interface with forms directly. From there you just have to design JSON payload. I got it working already using Postman to simulate the web request that will be sent from unity.
Check that the Google Form has public permissions. Maybe you have set them to a single user or to a single organization.

Send mail with Nuxt trough Sendgrid

I have a simple vuetify contact form and I want to send this forms by email.
I have tried to use a method to send the email, but it does not work, because its on client side. So I get CORS issues.
Here's my code:
async send() {
if (this.$refs.form.validate()) {
try {
const sgMail = require("#sendgrid/mail");
sgMail.setApiKey(process.env.SENDGRID_API_KEY);
const msg = {
to: "test#example.com",
from: "me#mydomain.com",
subject: "Sending with SendGrid is Fun",
text: "and easy to do anywhere, even with Node.js",
html: "<strong>and easy to do anywhere, even with Node.js</strong>"
};
sgMail.send(msg);
}
}
}
Is Express (or an other backend) required? Is there a way to make it work using a middleware?
EDIT
Apparently, it's just not possible: https://github.com/sendgrid/sendgrid-nodejs/issues/730
The CORS policy from Sendgrid does not allow you to use their API from the browser (The 'Access-Control-Allow-Origin' header has a value 'https://sendgrid.api-docs.io').
Quoted from https://sendgrid.com/docs/for-developers/sending-email/cors/ :
In SendGrid's case, we do not allow our customers to make a browser-based call to our v3/mail/send endpoint. (...)
You can create a server-based application, which will protect your API keys from being released to the world. Languages like NodeJS, PHP, Ruby, Python, C#, Go, and Java, and others can be implemented to make calls to the API from the security of a locked down server environment.
You have to send the email from a server, which is a good thing since your API Key would be exposed by the browser otherwise.
If you are using Nuxt in SSR mode (with Node running), I guess you could create a "Server Middleware" ( https://nuxtjs.org/api/configuration-servermiddleware ), for example with a path like "/api/mail", that will send the email.
If you are using nuxt-generate to create a static site, you can use a "function as a service", with something like "https://webtask.io/", to create a small node script; that you can trigger by url from your client to send the email.

Message Type on Facebook Messenger using Bot Framework

According to this documentation (https://developers.facebook.com/docs/messenger-platform/reference/send-api/) there will need to be a "messaging_type" property needed to be added to the payload for use on Facebook Messenger bots. Will this be automatically injected into the payload, or is this something we need to handle as a developer?
I stumbled upon this as I am researching how to add certain "tags" to the payload for pro-active messaging.
This issue Will Bot Framework support Facebook messaging_types? states the messaging_type is already set on every message and by default it's set to 'Response' and you can change this using ChannelData.
FranciscoPonceGomez on GitHub
We already support It. It defaults to ‘Response’ and can be changed via ‘messaging_type’ in channeldata.
I will send you a link with the updated documentation soon.
In C# you set the messaging_type like this:
activity.ChannelData = JObject.FromObject(new
{
messaging_type = "MESSAGE_TAG"
});
If you have successfully set the tag could you post your solution as it would really be of help to me and others :-)

SAPUI5 parameter transfer to web transaction

I am trying to open a transaction through the SAPUI5 event (eg. list item click).
While opening that transaction, parameters from the selected list item element in the SAPUI5 will be sent to that transaction and will fill specific input fields in the transaction such as material number, plant and so on.
Questions:
First of all, what is the best way to navigate from SAPUI5 to sap-web-transactions?
Second, how do I navigate while sending parameters? (gateway I suppose but how)
The following is an example of opening a SAP Transaction via Webgui from a SAPUI5 button event, the event shows one of many ways to attach additional parameters to the url
var sURL = 'http://my_sap_server:8000/sap/bc/gui/sap/its/webgui?~transaction=SU01';
var oButton = new sap.ui.commons.Button("b1");
oButton.setText("DDIC"); //Call Transaction SU01 and pass username as param
oButton.attachPress(function() {
var newURL = sURL + ' USR02-BNAME=' + oButton.getText( );
window.open(newURL);
});
Without knowing anything about your systems and/or code, it really depends on your use case...
If you have a J2EE webserver such as SAP HANA Cloud Platform, you could use JCO API to perform the call server side, and use a REST service to make the request from your client UI
If you have SAP NetWeaver CE, you could use the CAF framework instead of JCO, and still use REST.
However, from your question I assume you have SAP Gateway at your disposal, so I would recommend reading this paper by Bertram Ganz on how to consume Gateway OData services http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/40d59930-791c-3010-2abd-ac7793ad6c57?QuickLink=index&overridelayout=true&59017145615734

Adding "web version link" in email by sendgrid

How do I add a link to a web version of my sendgrid emails like "having trouble reading this email, click here"?
[EDIT]
I use a php sendgrid library
include "sendgrid-php-master/SendGrid_loader.php";
And I use this code and it doesn't work :
$mail = new SendGrid\Mail();
....
$mail->setHtml('View this email in your browser<br />'.$sg_html_code);
...
Just to confirm what Lirianna said, here you have the answer from Sendgrid support team to the same question:
Using [Weblink] will only be supported when using our Marketing Campaigns tool. To use this in a transactional template, you would need to create and host that link yourself.
Please be aware that SendGrid terminated the [weblink] and [unsubsribe] in 2017 (30/09/2017). You need to migrate with the new migrating toolkit.
Read more from SendGrid here
It's the latter half of 2021 and I tried using {{Weblink}} (capitalisation important) and it works just fine for me using the Dynamic Templates option.. YMMV
As per the official SendGrid documentation {{Weblink}} is available.
Refer: SendGrid docmentation link