WebhookClient doesn't work when i call api - node.js

I'm working on an app for Google Home with DialogFlowV2 but I've got a problem.
I'm using Google Cloud Functions, I've defined 3 functions, welcome, fallback and getTVShow.
The third one is the interesting one, i'm getting data from an API and send it with the add method of webhookClient.
I got this error when I call it :
Error: No responses defined for undefined
at V2Agent.sendResponse_ (/user_code/node_modules/dialogflow-fulfillment/v2-agent.js:140:13)
at WebhookClient.send_ (/user_code/node_modules/dialogflow-fulfillment/dialogflow-fulfillment.js:225:19)
at promise.then (/user_code/node_modules/dialogflow-fulfillment/dialogflow-fulfillment.js:285:38)
at process._tickDomainCallback (internal/process/next_tick.js:135:7)
I've looked into the source code and this is corresponding to the request source which is undefined after getting the data from the source in originalDetectIntentRequest from the request body.
So, i've done a console.log on the request.body.originalDetectIntentRequest and the result is :
{ payload: {} }
Therefore, it's normal to have an error but i don't want it.
Can someone help me, please ?
UPDATE
I’ve find out it only happens when i use the “playground” from DialogFlow. It's the "Try it now" input at https://console.dialogflow.com/ right side.
I've post an issue about this on the GitHub repo.
UPDATE 2
It was all about a forgotten return. When using async requests, we need to return the promise.

Related

How to integrate twilio sms verification into my Node.js application

As I am integrating Twilio into my website. It is first of all not working. My code is this
and app crashes. my userController where I am implementing the code is here
I am not getting what I want. This is what I am getting on my front UI
You see the error because you didn't supply a to parameter. This probably happens when the first function argument of sendSms() is null or undefined.
You call sendSms(User.newphone) which is probably the mistake as you call the property of what I assume is a class but instead you should try sendSms(user.newphone) or sendSms(newphone).
Tip: Don't use the same variable name to avoid this in the future.

How do I manually refresh-token while creating apps using Zapier CLI

I want to perform refresh token but my gateway gives HTTP response 403 instead of 401 so I cannot use 'autoRefresh' feature of Zapier.
I tried throwing 'RefreshTokenException' when the response status is 403 as given below:
return responsePromise
.then((response) => {
if (response.status == 403) {
throw new RefreshTokenException();
}
...
});
But upon doing this I get an Error from Zapier (while creating zaps) stating:
RefreshTokenException is not defined
Can anyone help me with manually refreshing token using Zapier CLI platform for app creation?
David here, from the Zapier Platform team. Sorry for the slow reply, we're just now seeing some of these.
It's not defined because that's not an error we define. You've got the right idea, you just need to use RefreshAuthError instead. See these docs.
​Let me know if you've got any other questions!

Nodejs + Solution for [wit] [converse] Error: Model not found (404) in 2017?

I'm try to run node-wit/messenger.js and get error:
[wit] [converse] Error: Model not found (404)
Google tells me I must create a story for the bot.
But it was solved in 2016. For now, WIT notification Stories and POST /converse have been deprecated. This will break in February 2018!
So, anyone can help me to pass it please? Any solution for this problem in 2017?
Ps: I'm trying use 'context' in GET /message to save the value.
If you want to use wit.ai then you need to create your intent and then use the API directly to extract it.
const client = new WIT({accessToken: <WIT_API_TOKEN>});
client.message(message, context)
.then((body) => {
})
.catch(console.error);
You need to parse the content of 'body'. This will contain the intent and your entities.
Your Bot will then need to handle the different replies based on what was parsed.

Node.js Issues with TwitterBot

I created a twitter bot via the instructions here:
https://medium.freecodecamp.com/easily-set-up-your-own-twitter-bot-4aeed5e61f7f#.5ifmh6ihn
I keep getting an error "Cannot read property 'id_str' of undefined Query String". I don't know much about node.js and just want this thing to work. I googled the error and didn't find much help. I left a comment on the post and haven't received any response there. Any help?

How to send POST variables with Nipple on NodeJS

I am trying to use nipple to post to an url within my nodejs application, which itself is running on hapi.js
The documentation essentially doesn't seem to spell it out.
(https://www.npmjs.com/package/nipple)
I tried passing it as payload inside options but that, while not returning an error, returns a 400. Can someone provide a correct example doing a post using nipple?
Essentially, I have two variables that I need to send - let's call the var1 and var2.
Thanks!
That link says that the project has been renamed to wreck. On wreck's github, several of the tests are for a post requests, including this one:
https://github.com/hapijs/wreck/blob/master/test/index.js#L68
If you are still scratching your head, you could also try using curl or postman to sanity check your URL, regardless of any nipple/wreck errors. If that also gives you a 400, nipple/wreck may not be the culprit.

Resources