图像出现在dialogflow聊天机器人中,但未显示在whatsapp聊天机器人中,并导致twilio错误

  

查看更新:部分解决方案

我正在使用dailogflow和twilio来制作whatsapp聊天机器人。

文本消息通常出现在dialogflow和whatsapp中。

图像仅出现在dialogflow聊天机器人中,但在whatsapp聊天机器人中不起作用,并且在twilio中出错

这是我要添加到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

有什么我可以解决的问题吗?


  

部分解决方案

部分解决方案

我能够通过对话框流程实现将图像发送到whats应用

首先,在“ package.json”中,我在依赖项中添加了twilio,“ twilio”:“ 3.37.1”(检查npm twilio的最新版本)

第二,我添加了以下代码,以使用其网址将图像发送到whatsapp,

const client = require('twilio')('YOUR_accOUNT_SID','YOUR_AUTH_TOKEN'); /* change YOUR_accOUNT_SID and YOUR_AUTH_TOKEN to your own twilio account data */

    client.messages
        .create({
            to: 'whatsapp:+13233633791',/* change it to your the number which you want to send the image to*/ 
            from: 'whatsapp:+18007778888',/* change it to your the number which twilio sandbox provide,you can find it here: https://www.twilio.com/console/sms/whatsapp/sandbox */
            body: "Hi Joe! Please find your boarding pass attached. Flight OA2345 departs at 11 pm PST.",mediaUrl: 'https://emerald-coral-3661.twil.io/assets/2-OwlAir-Upcoming-Trip.PNG',})
        .then((message) => console.log(message.sid));
  

现在的问题是:

在先前的代码中,to是必需的,这意味着我必须指定要将图像发送到的数字,看起来很奇怪,但是如果我没有指定{{ 1}}。

我需要知道的是如何更改:to可以将任何消息发送到to: 'whatsapp:+13233633791',

urboat19 回答:图像出现在dialogflow聊天机器人中,但未显示在whatsapp聊天机器人中,并导致twilio错误

我还面临着无法将媒体消息发送给当前正在使用聊天机器人的任何用户的相同问题。我在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);

}
本文链接:https://www.f2er.com/3079395.html

大家都在问