Get current project.js endpoint URI in app.js


#1

project.js can have different endpoints based on local or stage:

{
endpoint: ‘${JOVO_WEBHOOK_URL}’,
stages: {
local: { endpoint: ‘${JOVO_WEBHOOK_URL}’ },
dev: { endpoint: ‘arn:aws:lambda:us-east-2:XXXXXX:function:MyFunction’ }
}
}

How can I get the current endpoint URI from within intent handlers in app.js?


#2

Hi @vguruv, welcome to the Jovo Community :wave:

The project.js is not deployed to the hosting service (e.g. Lambda), only the src folder is.This is why we don’t have a feature right now that fetches the current project config depending on stage.

May I ask what you need this functionality for? Maybe we offer something else that fits your use case


#3

I want to avoid hard coding the Twilio autopilot redirect URL like this in app.js:

if (this.$autopilotBot)
this.$autopilotBot.setActions([
{
// list actions here

                    "on_complete": {
                        "redirect": {
                            "method": 'POST',
                            "uri": 'https://webhook.jovo.cloud/xxxx-xxxx-xxx-xxxxx-xxxxxxxx'
                        }
                    }
                }

#4

Answering my own question - I redirected to an autopilot task to avoid hard coding the URL:

“redirect”: “task://myAutopilotTask”