缺少用于在新 Actions SDK 上进行交易的 conversationId
Missing conversationId for making Transactions on the new Actions SDK
我正在尝试 POST 向 https://actions.googleapis.com/v3/packages/{packageName}/skus:batchGet
发送请求,如第 2 部分所述。在 non-consumable digital transactions guide。在此处粘贴相关片段:
return jwtClient.authorize((err, tokens) => {
if (err) {
throw new Error(`Auth error: ${err}`);
}
const packageName = 'com.example.projectname';
request.post(`https://actions.googleapis.com/v3/packages/${packageName}/skus:batchGet`, {
'auth': {
'bearer': tokens.access_token,
},
'json': true,
'body': {
'conversationId': conversationId,
'skuType': 'APP',
// This request is filtered to only retrieve SKUs for the following product IDs
'ids': ['nonconsumable.1']
},
}, (err, httpResponse, body) => {
if (err) {
throw new Error(`API request error: ${err}`);
}
console.log(`${httpResponse.statusCode}: ${httpResponse.statusMessage}`);
console.log(JSON.stringify(body));
});
});
});
请求正文应该有一个 conversationId
字段。据我所知,此字段存在于 Dialogflow and legacy Actions SDK, it's missing from the new Actions SDK webhook requests 中。
新的 Actions SDK 文档链接到该数字交易指南,因此我认为它应该是兼容的,但没有发现需要进行调整才能使用它。
所以我的问题是,当从满足新 Actions SDK 请求的 webhook 进行交易时,如何获取 conversationId
?
文档中提供的片段不正确。
请使用会话 ID。您可以通过 conv.session.id
.
访问此值
我正在尝试 POST 向 https://actions.googleapis.com/v3/packages/{packageName}/skus:batchGet
发送请求,如第 2 部分所述。在 non-consumable digital transactions guide。在此处粘贴相关片段:
return jwtClient.authorize((err, tokens) => {
if (err) {
throw new Error(`Auth error: ${err}`);
}
const packageName = 'com.example.projectname';
request.post(`https://actions.googleapis.com/v3/packages/${packageName}/skus:batchGet`, {
'auth': {
'bearer': tokens.access_token,
},
'json': true,
'body': {
'conversationId': conversationId,
'skuType': 'APP',
// This request is filtered to only retrieve SKUs for the following product IDs
'ids': ['nonconsumable.1']
},
}, (err, httpResponse, body) => {
if (err) {
throw new Error(`API request error: ${err}`);
}
console.log(`${httpResponse.statusCode}: ${httpResponse.statusMessage}`);
console.log(JSON.stringify(body));
});
});
});
请求正文应该有一个 conversationId
字段。据我所知,此字段存在于 Dialogflow and legacy Actions SDK, it's missing from the new Actions SDK webhook requests 中。
新的 Actions SDK 文档链接到该数字交易指南,因此我认为它应该是兼容的,但没有发现需要进行调整才能使用它。
所以我的问题是,当从满足新 Actions SDK 请求的 webhook 进行交易时,如何获取 conversationId
?
文档中提供的片段不正确。
请使用会话 ID。您可以通过 conv.session.id
.