Image 图像显示在dialogflow chatbot中,但未显示在whatsapp chatbot和making twilio error中
请参阅更新:部分解决方案 我正在使用dailogflow和twilio制作whatsapp聊天机器人 文本消息通常出现在dialogflow和whatsapp中 图像仅出现在dialogflow聊天机器人中,但它在whatsapp聊天机器人中不起作用,并在twilio中出错Image 图像显示在dialogflow chatbot中,但未显示在whatsapp chatbot和making twilio error中,image,twilio,dialogflow-es,chatbot,whatsapp,Image,Twilio,Dialogflow Es,Chatbot,Whatsapp,请参阅更新:部分解决方案 我正在使用dailogflow和twilio制作whatsapp聊天机器人 文本消息通常出现在dialogflow和whatsapp中 图像仅出现在dialogflow聊天机器人中,但它在whatsapp聊天机器人中不起作用,并在twilio中出错 MESSAGE The URI scheme, of the URI null, must be equal (ignoring case) to 'http', 'https', 'ws', or 'wss' ......
MESSAGE
The URI scheme, of the URI null, must be equal (ignoring case) to 'http', 'https', 'ws', or 'wss'
......
HTTP retrieval failure
......
Possible Causes
Web server returned a 4xx or 5xx HTTP response to Twilio
Misconfigured Web Server
Network disruptions between Twilio and your web server
No Content-Type header attached to response
Content-Type doesn't match actual content, e.g. an MP3 file that is being served with Content-Type: audio/x-wav, instead of Content-Type: audio/mpeg
这是我添加到DialogFlow实现的内联编辑器中的代码部分:
agent.add(new Card({
title: `Title: this is a card title`,
imageUrl: 'http://examplesitelink.com/image_name.png',
})
下面是我在twilio中收到的错误消息
MESSAGE
The URI scheme, of the URI null, must be equal (ignoring case) to 'http', 'https', 'ws', or 'wss'
......
HTTP retrieval failure
......
Possible Causes
Web server returned a 4xx or 5xx HTTP response to Twilio
Misconfigured Web Server
Network disruptions between Twilio and your web server
No Content-Type header attached to response
Content-Type doesn't match actual content, e.g. an MP3 file that is being served with Content-Type: audio/x-wav, instead of Content-Type: audio/mpeg
我能做些什么来解决这个问题吗
部分解 低于部分解 我可以通过dialogflow将图像发送到whats应用程序 首先,在“package.json”中,我在依赖项中添加了twilio,“twilio”:“3.37.1”(查看npm twilio的最新版本) 其次,我添加了下面的代码,使用whatsapp的url将图像发送到whatsapp,它可以正常工作
const client=require('twilio')('YOUR_ACCOUNT_SID','YOUR_AUTH_TOKEN');/*将您的\u帐户\u SID和\u身份验证\u令牌更改为您自己的twilio帐户数据*/
客户端消息
.创造({
至:'whatsapp:+13233633791',/*将其更改为您想要将图像发送到的号码*/
from:'whatsapp:+18007778888',/*将其更改为twilio sandbox提供的号码,您可以在此处找到:https://www.twilio.com/console/sms/whatsapp/sandbox */
身体:“嗨,乔!请查收随附的登机牌。OA2345航班于太平洋标准时间晚上11点起飞。”,
mediaUrl:'https://emerald-coral-3661.twil.io/assets/2-OwlAir-Upcoming-Trip.PNG',
})
.then((message)=>console.log(message.sid));
现在的问题是:
在前面的代码中,to
是必需的,这意味着我必须指定要将图像发送到的号码,这看起来很奇怪,但是如果我没有指定to
,代码将无法工作
我需要知道的是,我如何更改:
到:'whatsapp:+13233633791',
到任何代码都可以将消息发送给当前使用whatsapp的用户。我还面临同样的问题,无法将媒体消息发送给当前使用聊天机器人的任何用户。我在youtube视频中找到了解决方案,他们从请求对象中提取了接收方手机号,如下所示-
const data = request.body.originalDetectIntentRequest.payload;
const To = data.From;
const From = data.To;
这里的请求对象是使用下面的“req”代码创建dialogflow代理时得到的对象-
app.post("/", express.json(), (req, res) => {
-------------------
-------------------
function handler() {
----------
}
intentMap.set("intent", handler);
}
并非每个平台都支持卡片-您可以在“感谢您的回复”上找到更多信息,有没有办法在没有卡片的情况下插入图像?