对于“测试意图”,我启用了Enable Webhook Call for this intent
我已经正确设置了与机器人的Telegram集成。
在完整代码中,我使用的是Payload对象的构造方法(https://dialogflow.com/docs/reference/fulfillment-library/rich-responses#new_payloadplatform_payload)and,我指定了指示有效负载目标平台的字符串。请在欢迎功能下面的代码中查看:
const {WebhookClient} = require('dialogflow-fulfillment');
const {Text, Card, Image, Suggestion, Payload} = require('dialogflow-fulfillment');
exports.dialogflowFirebaseFulfillment = functions.https.onRequest((request, response) => {
const agent = new WebhookClient({ request, response });
function test(agent) {
agent.add(new Payload(agent.TELEGRAM, {
"text": "Please click on button below to share your number",
"reply_markup": {
"one_time_keyboard": true,
"resize_keyboard": true,
"keyboard": [
[
{
"text": "Share my phone number",
"callback_data": "phone",
"request_contact": true
}
],
[
{
"text": "Cancel",
"callback_data": "Cancel"
}
]
]
}
}));
}
// Run the proper function handler based on the matched Dialogflow intent name
let intentMap = new Map();
intentMap.set('test Intent', test);
agent.handleRequest(intentMap);
});
Dialogflow不会将实现代码中的有效负载响应返回给意图调用时的电报。 我看了一下项目功能日志,但是没有错误被记录。 他们没有理由不让我的代码无效
dialogflow中是否弃用了有效负载类?
答案 0 :(得分:0)
我今天遇到了同样的问题,并且现在正在运行
var pl_tl = {
"telegram": {
"text": "Please click on button below to share your number",
"reply_markup": {
"one_time_keyboard": true,
"resize_keyboard": true,
"keyboard": [
[
{
"text": "Share my phone number",
"callback_data": "phone",
"request_contact": true
}
],
[
{
"text": "Cancel",
"callback_data": "Cancel"
}
]
]
}
}
}
let pl = new Payload(agent.TELEGRAM, pl_tl, { sendAsMessage: true, rawPayload: true });
答案 1 :(得分:0)
在Dialogflow实现Web钩子逻辑中使用的dialogflow WebhookClient返回 包含send方法的Express HTTP响应对象。我迷上了这个方法,将响应发送回dialogflow的webhook实现API。参见下面的代码。
function telegramIntegration(agent) {
const ClientResponse=
{
"ClientResponse": [
{
"payload": {
"telegram":
{
"text": "Please share your contact",
"reply_markup": {
"keyboard": [
[
{
"text": "Share my phone number",
"callback_data": "phone",
"request_contact": true
}
],
[
{
"text": "Cancel",
"callback_data": "Cancel"
}
]
],
"one_time_keyboard": true,
"resize_keyboard": true
}
}
}
}
]
};
response.send(JSON.stringify(ClientResponse));
}
但是,此替代方法不能回答我的问题“ 是否已弃用Dialogflow有效载荷类?”