我遇到了一些问题,我无法从对话框流的上下文中访问我的参数,我只是尝试使用agent.getContext
但agent.context.get
仍然无法正常工作。
有我设置上下文的代码
function noTelp(agent){
const telp = agent.parameters.phoneNumber;
let query = db.collection('pelanggan').where('no_telp','==',telp);
return query.get().then(snapshot => {
if (snapshot.empty) {
agent.add('Mohon Maaf data no telepon '+telp+' tidak ditemukan');
agent.add('untuk menambahkan data kamu silahkan tuliskan nama kamu');
agent.setContext({ >set the context
name : 'tambahData',
lifespan : 2,
parameters : {noTelp : telp}
});
console.log('No matching documents.');
return;
}
}
这用于调用上下文
function tambahData(agent){
const context = agent.getContext('tambahData'); >get the context
const telp = context.parameters.noTelp; >get the parameters from context
const nama = agent.parameters.nama;
agent.add(nama+telp); >test calling parameters
}