If I have several skills, moreover with the same code but with some small changes, and I want to use only one endpoint for all of them, is it possible to understand from which skill I’m calling that endpoint each time?
Take ID of the skill/actions from database/server
You can use the following methods:
this.$alexaSkill.getSkillId();
this.$googleAction.getProjectId();
When I use this command with Alexa in the launch it works and returns the correct one
When I use it with Google Actions in the launch it returns undefined.
Why is this happening?
Hm, this line of code should be responsible for it: https://github.com/jovotech/jovo-framework/blob/eea2446683e6d8a05264b0a5b54d4659f65a7600/jovo-platforms/jovo-platform-googleassistantconv/src/core/GoogleAction.ts#L273
Can you share a request JSON where this doesn’t work?
From the JSON request, I just have my console log undefined.
The log is: “Get project id: undefined”, but I don’t think that this log could be useful
The code is:" console.log(“Get project id:”, this.$googleAction.getProjectId());"
I ask for it in the Launch
My solution to this problem is:
const projectId = require('../project');
console.log(test['googleAction']['projectId']);
Is this actually the same? Or this can cause problem in production?
Because I want to have the same webhook for multiple actions
Oh yeah.
The new Conversational Actions doesn’t provide the projectId in the payload. The workaround is to set the the projectId query param in the endpoint url.
Here’s an example with the Jovo Webhook. But it also works with any other urls.
https://webhook.jovo.cloud/MYID?projectId=PROJECT1
This should work then:
console.log('Get project id:', this.$googleAction.getProjectId()); // returns PROJECT1
Oh, okay, nice to know.
How can I add that to my endpoint in my app.js ? Or are you saying that I should add it in project.js?
Yes, you add it to your project.js. If you add the webhook urls manually you have to change it in the platform developer consoles.