dialogflow / dialogflow-fulfillment-nodejs

Dialogflow agent fulfillment library supporting v1&v2, 8 platforms, and text, card, image, suggestion, custom responses
Apache License 2.0
597 stars 281 forks source link

Unable to create context in axios #280

Open Ashwin-Kapes opened 4 years ago

Ashwin-Kapes commented 4 years ago

I'm trying to create a context inside axios response but it's not working. Here's my code:

function AuthToken(agent) {     
      axios.post(URL HERE, PAYLOAD HERE)
            .then(function(response) {
               agent.context.set({
                    "name": 'token',
                    "lifespan": 5,
                    "parameters": { "access_token": response.data.access_token }
                });
                return console.log(response);
            })
            .catch(function(error) {                
                return console.log(error);
            });

 agent.add(`Hello`);
    }