You can do this with contexts.
In your first intent you do something like this:
function firstIntentHandler(agent){
return axios.get(`https://yourserver.com`)
.then(function (response) {
agent.add(response.data.sessionId);
const context = {'name': 'yourcontextname', 'lifespan': 3, 'parameters':
{'sessionid': response.data.sessionId }};
agent.setContext(context);
}).catch(function (error) {
agent.add("An error occured.");
});
}
sessionId is the variable name in your json data sent by your server.
In your other intent you can access this data like this:
function otherIntentHandler(agent) {
const context = agent.getContext("yourcontextname");
const sessionid = context.parameters.sessionid;
// do something with this session id
});
}
Be careful with camelcase for your context name. I have the feeling that uppercase letters are stored as lowercase...