I am trying to connect my bot with chatbase.
For that I have generated the API key and connected it with after that I have set my intent with function sendChatbaseHandledMessage and sendChatbaseNotHandledMessage.
While I use sendChatbaseNotHandledMessage it gives this error:
The message cannot be set as not_handled and not be of type user.
at MessageStateWrapper.exportCreatePayload (/home/runner/node_modules/#google/chatbase/lib/MessageSink.js:426:14)
at Promise (/home/runner/node_modules/#google/chatbase/lib/MessageStateWrapper.js:145:29)
at new Promise (<anonymous>)
at MessageStateWrapper.send (/home/runner/node_modules/#google/chatbase/lib/MessageStateWrapper.js:141:12)
at sendChatbaseNotHandledMessage (evalmachine.<anonymous>:36:143)
at evalmachine.<anonymous>:39:3
at Script.runInContext (vm.js:74:29)
at Object.runInContext (vm.js:182:6)
at evaluate (/run_dir/repl.js:133:14)
at ReadStream.<anonymous> (/run_dir/repl.js:116:5)
As I can understand, the issue is with the chatbase node_modules with some library.
Can I get some solution for it?
Reposting the response from our engineer to the internal thread for reference.
It looks like the error is:
message cannot be set as not_handled and not be of type user
Not handled messages in the chatbase API can only by of type user so one would need to say:
var msg = chatbase.newMessage('my-api-key', 'my-user-id')
msg.setAsTypeUser().setAsNotHandled().send()...
In the chatbase API one cannot set agent messages as not handled, so the following is not allowed:
msg.setAsTypeAgent().setAsNotHandled()
Related
I am not sure what mistake I am doing. I have create a ChatBot in google dialog flow and did setup of WebHook in my local. Once I am hitting from dialogbox then reuqest is landing to code and processed successfully but in Dialogflow response I am getting failure due to some TimOut exception, there a way to fix this . I am facing WebHook call failed. Error: DEADLINE_EXCEEDED, State: URL_TIMEOUT, Reason: TIMEOUT_WEB calling from node.
Below is the index.json snippet :
Below is the console log
At the end of the function you need to resolve the promise.
return Promise.resolve();
Additionally, you're probably already handling errors but in a Firebase Function, if you need to throw an error, you can do that simply this way:
throw new functions.https.HttpsError(
'internal',
'Woops, that should not happen.',
);
I am using Dialogflow ES and once I got the webhook setup, I haven't been having issues. But after a few months, I just started getting a random error. It seems to be inconsistent as in sometimes I get it for a specific web call and other times it works fine. This is from the Raw API response:
"webhookStatus": {
"code": 3,
"message": "Webhook call failed. Error: [ResourceName error] Path '' does not match template 'projects/{project_id=*}/locations/{location_id=*}/agent/environments/{environment_id=*}/users/{user_id=*}/sessions/{session_id=*}/contexts/{context_id=*}'.."
}
The webhook is in GCP Functions in the same project. I have a simple "ping" function in the same agent that calls the webhook. That works properly and pings the function, records some notes in the function log (so I know the function is being called), and returns a response fine, so I know the webhook is connected and working for other intents in the same agent before and after I get the error above.
Other intents in the same agent work (and this one WAS working), but I get this error now. I also tried recreating the intent and I get the same behavior.
The project is linked to a billing account and I have been getting charged for it, so I don't think it is an issue with being on a trial or otherwise. Though the Dialogflow itself is in "trial", but the linked webhook function is billed.
Where can I find what this error means or where to look to resolve it?
After looking at this with fresh eyes, I found out what was happening.
The issue was a mal-formed output context. I was returning the bad output context sometimes (which explained why sometimes it worked and sometimes it didn't). Specifically, I was returning the parameters directly into the output context without the output context 'name' or 'parameters'. Everything looked like it was working and I didn't get any other errors, but apparently, when Dialogflow receives a bad web response, it generates the unhelpful error above.
I'm trying to process a push notification from Gmail by follow the instruction from this link. I modified some code to read from historyId instead of most recent message like recommended in the guide.
It's normally work find but sometime the problem occurred after received a push notification. The script failed to call Gmail API:
gmail-watch-fs yv1ke4cc0tk8 Error: Not Found
at Gaxios.<anonymous> (/srv/node_modules/gaxios/build/src/gaxios.js:73:27)
at Generator.next (<anonymous>)
at fulfilled (/srv/node_modules/gaxios/build/src/gaxios.js:16:58)
at <anonymous>
at process._tickDomainCallback (internal/process/next_tick.js:229:7)
Here is the line that cause error:
const historyRes = await gmail.users.history.list({
userId: "me",
startHistoryId: historyId,
historyTypes: ["messageAdded"],
})
I found a Japanese site suggest to enable IAM API but it's already enabled in my case. Can anyone help me with this?
The problem is because I try to listen to many subscribed email address by only one Cloud Function instance. It is solved by generate more Cloud Function (one per each subscribed email).
I'm using an event handler, where each event code is in it's own files. I'm attaching the events to the client, so when that file has the event emitted, it will run that code:
// looping through all event files
client.on(file.split('.')[0], require(`events/${file}`).bind(null, client, Util);
If the event file was message.js, it would be similar to:
client.on('message', require('events/message.js').bind(null, client, Util);
So when the message event is emitted, it runs the message.js file, passing along the client and Util classes.
I also have a function that is attached to the client called report. It basically reports when there is an error. I would like it so whenever any event from the client has an error, it will run that function.
I've done this slightly with the commands: command.run(...).catch(error => client.report(error)).
Is there a similar way to do this, instead of having to put a try-catch around all code in all the event files?
Try this way
client.on('error', require('events/report.js').bind(null, client, Util);
Error handling should be context driven. This means your bot's response to the error should be dependent on what it was doing, in what channel, etc - both for debugging and for the end user's information on what happened. You'll miss out on all of the context by letting errors just travel all the way up into an uncaught exception, and without the ability to create an error message, the user will just see the bot not respond and think it's down or the command is broken.
My suggestion: Create helper methods for your most common error producing functions that wrap them with error handling. I did this mostly for sending messages, as there's a myriad of things that could cause a message send to fail out of your control and the handling consists of generating an error message and attempting to send it in the channel or DM it to the user if that fails.
I am using appRTC to make demo app. I have setup following things successfully but got stack with JSON format that return in response of Turn-server API.
Use SSL for secure connect to make it work on Google Chrome (Done)
Implement custom WebSockets (Done)
Develop custom API for TurnServer (Done)
I am getting following error in console log.
Create PeerConnection exception: Failed to construct 'RTCPeerConnection': Malformed RTCIceServer
Failed to start signaling: Cannot read property 'addStream' of null
I have tried following responses as ice server object
Current object:
{"iceServers":[{"urls":["stun:stun.l.google.com:19302"]},{"urls":["turn:domain.com:8080?transport=udp","turn:domain.com:8080?transport=tcp","turn:domain.com:8080"],"username":"test","credential":"password"}],"lifetimeDuration":"86400s","blockStatus":"NOT_BLOCKED","iceTransportPolicy":"all"}
Have also tried:
[{"urls":["stun:stun.l.google.com:19302"]},{"urls":["turn:domain.com:8080?transport=udp","turn:domain.com:8080?transport=tcp","turn:domain.com:8080"],"username":"test","credential":"password"}]
and also tried this one:
[{"urls":["turn:domain.com:8080?transport=udp","turn:domain.com:8080?transport=tcp","turn:domain.com:8080"],"username":"test","credential":"password"}]
You have a typo here:
[{"urls":["stun:stun.l.google.com:19302"}
trying to close urls without closing the array.
This should be
[{"urls":["stun:stun.l.google.com:19302"]}
This doesn't result in an error about malformed RTCIceServer though.
Based on your comment it seems to be a result of calling
new RTCPeerConnection({"iceServers":[{}]})
-- an empty object is not a valid RTCIceServer.
I would also recommend not passing
"lifetimeDuration":"86400s","blockStatus":"NOT_BLOCKED"
to the RTCPeerConnection as it doesn't know about these.