I tried to use Rich responses to show buttons, cards as responses from the webhook with dynamic content.
agent.add(new Card({
title: <RICH UI>,
imageUrl: '<IMAGE URL>',
text: '<CARD TEXT>',
buttonText: '<BUTTON>',
buttonUrl: '<BUTTON URL>'
})
);
agent.add(new Suggestion('<SUGGESTION 1>'));
agent.add(new Suggestion('<SUGGESTION 2>'));
It seems this is not supported for web-based Dialogflow agents.
How can it be achieved like this guy is doing with his agent?
I want to control the UI from webhook and not by intercepting and updating via frontend code.
I asked the Dialogflow support team. Got a reply that it is currently not supported and I need to write my own UI code to handle this.
Related
I am trying to launch a web url that will act as a deeplink for my app to launch it, it there a way to launch a URL in DialogFlow or in Actions Google using there fulfilment or the webhook for the Google Actions, I have created a custom intent and against that intent I like to launch specific feature of my app but it is not triggering the intent as it do in case of Build In Intents so as an alternative if Google Assistant launch that URL the purpose will be served.
I found some code that looks useful but unfortunately it doesn't work for me. Below is the code
const app = dialogflow({debug: true});
app.intent('welcome', (conv) => {
conv.ask('Welcome! Do you want me to change color or pause spinning?');
conv.ask(new HtmlResponse({
url: 'https://your-web-app.com',
}));
});
Thanks in advance.
Can we use SSML in dialogflow JSON Response from webhook i.e. without using Google Assistant client library.
Basically I would like to return SSML subalias in the response from my webhook hosted on AWS Lambda.
I tried to search if it is possible using dialogflow JSON response, but not able to find it anywhere.
Added the following in
"textToSpeech": '<speak><sub alias="Indian Premier League"> IPL</sub></speak>'
I'm trying to write a simple Stripe integration using Express. My code creates the customer and charge and completes, appearing in my dashboard. However I'm struggling to understand how to handle the response from Stripe. The following just outputs the whole response from Stripe - what I would like is to be able to output a friendly message dependent on the content of this response:
stripe.customers.create({
card: stripeToken
})
.then(customer =>
stripe.charges.create({
amount: fee,
description: "Client Ref: " + clientref,
currency: "gbp",
customer: customer.id,
metadata: {
'allocation:': allocate
}
}))
.then(charge => response.send(charge))
.catch(err => {
console.log("Error:", err);
response.status(500).send({error: "Purchase Failed"});
});
How can I look at the response and handle it accordingly? I've tried using the response.send promise and I can get it to display parts of the response, but is this a 'charge' page? How can I display this as html and not just plaintext??
I have looked in the Stripe docs and haven't found anything similar. I want to be able to account for failed payments, declines etc as well as successful charges.
Any help or other examples much appreciated!
Thanks
edit: ok I handle the 'errors' in the catch block. I didn't realise Stripe doesn't throw exceptions, so that makes life easier. My point about formatting the messages still stands however. '/charge' just outputs plain text.
How can I look at the response and handle it accordingly?
The Stripe docs clearly show you what the response for a successful charge is here: https://stripe.com/docs/api/node#create_charge (under Example response). It gives you back a large JSON object.
You need to figure out what part of that response is useful to you to display in your client-side application. If none of the information is needed, then you can simply ignore the response.
(...) but is this a 'charge' page? How can I display this as html and not just plaintext??
What you are doing now is simply sending the whole JSON object to your client via res.send. And you are not doing anything with the response other than simply sending it back as plain text. You need to configure your view to display the response: http://expressjs.com/en/guide/using-template-engines.html
Or if your producing an API for others to consume, then use res.json to send back the JSON you got back from Stripe. http://expressjs.com/en/4x/api.html#res.json
I want to be able to account for failed payments, declines etc as well as successful charges.
Then you need to handle the error that occurs. You are handling the error via .catch, but you aren't inspecting the error object. Again, the stripe have documentation on errors as well: https://stripe.com/docs/api#errors
And they even tell you how to handle errors as well: https://stripe.com/docs/api#handling-errors
When a facebook messenger user start a conversation I want to get the data like name, photo, etc ... and send to my API.
But I'm doubtful when I should do this.
It would be in the:
bot.on('conversationUpdate', (session) => {
// On here??
})
Facebook doesn't support the conversationUpdate event. It won't send events when you start a conversation, however you could solve your issue in two different ways.
Create a custom middleware that checks if you already have the userData from Facebook and retrieve it when you don't have it yet.
Create a custom middleware that translates Facebook's callbacks to intents
I already created those for NodeJS, which you can use in your bot. BotBuilder-FacebookExtensions
If you need more guidance, you can read the blogs I wrote about this:
How to retrieve User Data from Facebook /
How to process Facebook Messenger callbacks
there is a website that works with virtual items for an online game. I made a chrome extension that automates some actions on that website. Since I'd like to make this run on my raspberryPi (and chromium with the extension seems to be too slow and unefficient) I am trying to move this into node.js.
The login for the website works with Steam OpenID. It allows you to select items from a list, click a few buttons, then it sends you a tradeoffer on steam.
My extension works with the website while I was logged in there. It receives their database with jQuery getJSON, loops through the array, pushes some values into an array and then sends a post request telling the website which items I want and which items I am offering.
Here is how I am sending the request from chrome:
function withdrawXHR(botId, playerItems, botItems) {
$.ajax({
url: websiteURL,
type: 'post',
data: {
"steamid": botId,
"peopleItems": playerItems,
"botItems": botItems
},
success: function (data) {
console.error('>> Done: ' + data)
console.log("")
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
console.error('>> Error: ' + errorThrown)
console.log("")
}
});
}
I can do everything in node so far like receiving their database, working through it, filter out the values I need, but I can't manage to send a working request. The problem is probably the login / how the website knows who I am.
I used wrapAPI (a chrome extension) to catch the request that is being sent when manually working with the website. Here is what it looks like:
So these are the things I am wondering about:
How would I send this request from node?
How does the website know who I am? They obviously know, because they are sending me an offer, but I can't see any "personal" data in that request.
Would I need to log into Steam OpenId from Node in some way? Is that possible?
What is a CF-RAY? (See the end of the captured request).
I am quite new to JS and requests in general and even "newer" to Node.js. I don't fully understand how the background of sending requests works. I would just need some tips, ideas on how to achieve my goal here.
Any help is greatly appreciated! Thank you! :)
You cannot use XMLHttpRequest for resources across domains. ( incidentally, unless you are using an extension)
I would look into grabbing express.js, and something called CORS. CORS permits cross-domain requests.
Here: http://enable-cors.org/server_expressjs.html
And here is some information on XHR requests in browser extensions: https://developer.chrome.com/extensions