What sets apart a good agent is personalizing the experience for each user, adapting to their needs and offer the best experience for whichever device they are currently using. With Actions on Google (AoG) customizing the responses, storing information and manipulating the medium of the displayed response, can all be achieved by learning how to leverage the Conversation Object.

If you’re already familiar with the DialogflowConversation object and want to see the code in some real-world examples, jump here.

If you are starting with Actions on Google and DialogFlow now, you’re going to come across a lot of times to an object named conv ( DialogflowConversation ). You’re also going to see that the starting code you have at your project’s webhook, is quite different from the documentation. Both platforms are very new and constantly improving so that’s natural.

Snippet from the documentation:

function simpleResponse(conv) {

conv.data.count = 1;

conv.ask('Hi there, what can I help you with today?');

}

Starting code

// ... const agent = new WebhookClient({ request, response });



function welcome(agent) {

agent.add(`Welcome to my agent!`);

} let intentMap = new Map();

intentMap.set('Default Welcome Intent', welcome);

// ...

agent.handleRequest(intentMap);

});

So where do I find that conv object? It’s actually hidden inside your agent . All you need to do is add this line after you initialize the agent :

let conv= agent.conv();