Take ID of the skill/actions from database/server


#1

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?


#2

You can use the following methods:

this.$alexaSkill.getSkillId();
this.$googleAction.getProjectId();

#3

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?


#4

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?


#5

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 :sweat_smile:

The code is:" console.log(“Get project id:”, this.$googleAction.getProjectId());"

I ask for it in the Launch


#6

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


#7

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

#8

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?


#9

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.


#10

Thank you