我正在使用 Dialogflow 构建 Telegram 聊天机器人。 我正在使用 Node.js 和 Dialogflow 的内联编辑器来实现。
我希望我的机器人问“我还能为您提供其他帮助吗?”在我的意图之后有“是”和“否”按钮。这是实现我的意图之一的函数:
function form(agent) {
agent.add(
new Card({
title:
"Ok, here's the registration form. Click the button and download the file.",
buttonText: `Form`,
buttonUrl: formDownloadUrl,
})
);
const help = new Payload({
"telegram": {
"text": "Can I help you with anything else?",
"reply_markup": {
"inline_keyboard": [
[
{
"callback_data": "yes",
"text": "1 - Yes",
},
{
"text": "2 - No",
"callback_data": "no",
},
],
],
},
},
});
agent.add(help);
}
在 Google Cloud 日志中,当我尝试调用相同的意图时,出现以下错误:
Dialogflow fulfillment error : Webhook call failed. Error: UNAVAILABLE, State: URL_UNREACHABLE, Reason: UNREACHABLE_5xx, HTTP status code: 500.
当我只有卡时,该功能工作正常,但是当我尝试添加有效负载时,它停止工作,现在给出上述错误。
有效负载的语法是否正确? Dialogflow Fulfillment 不支持 Telegram 自定义负载吗?
然后我将此意图设置为事件,并使用 setFollowupEvent() 方法在我的“表单”函数中调用它,但这仅显示“帮助”问题,跳过“表单”卡。
请从您的有效负载中删除电报节点,并通过将电报作为平台发送来将有效负载添加到代理。
const help = new Payload({
"text": "Can I help you with anything else?",
"reply_markup": {
"inline_keyboard": [
[
{
"callback_data": "yes",
"text": "1 - Yes",
},
{
"text": "2 - No",
"callback_data": "no",
},
],
],
},
});
agent.add(new
Payload(agent.TELEGRAM, help,
{rawPayload: false, sendAsMessage:
true}));