[英]How can I get the phone number from Twilio in fulfillment dialogflow
I'm working in a whastapp bot between Twilio and Dialogflow.我在 Twilio 和 Dialogflow 之间的 whastapp 机器人中工作。 In one of the intents, I'm sending media files from dialogflow to the user.
在其中一个意图中,我从 dialogflow 向用户发送媒体文件。 Here it's the problem, now it's working with my mobile number hardcoded, but I need to access to the user phone number in each case to send the media file.
这就是问题所在,现在它可以使用我的手机号码进行硬编码,但我需要在每种情况下访问用户电话号码才能发送媒体文件。
I develop this in fulfillment dialogflow, inline editor, using some nodejs code, but there I can't access to the user number.我在实现对话框流、内联编辑器中使用一些 nodejs 代码开发了它,但在那里我无法访问用户编号。
Fulfillment node js履行节点js
function sendAudioMensaje(agent) {
client.messages.create({
body: 'Body message',
to: 'whatsapp:+34---------', // Text to this number
from: 'whatsapp:+14155238886', // From a valid Twilio number
mediaUrl: 'https://demo.twilio.com/owl.png'
}).then((message) => agent.add(message.sid));
}
I expect that the message would be sent to the current number in each conversation我希望消息会被发送到每个对话中的当前号码
Twilio developer evangelist here. Twilio开发人员布道者在这里。
As far as I can tell, the Dialogflow webhook request comes with a originalDetectIntentRequest
property in the JSON. 据我所知, Dialogflow webhook请求带有JSON中的
originalDetectIntentRequest
属性。 This contains a OriginalDetectIntentRequest
object, which has a payload
property that contains the original request. 它包含一个
OriginalDetectIntentRequest
对象,该对象的payload
属性包含原始请求。
I'd start by logging the contents of the webhook request to see what is fully available to you though. 我将从记录webhook请求的内容开始,以查看您完全可以使用的内容。
Let me know if that helps at all. 让我知道是否有帮助。
In the payload of the OriginalDetectIntent
request you will see a JSON like this in the webhook if it's enabled.在
OriginalDetectIntent
请求的负载中,如果启用,您将在 webhook 中看到类似这样的 JSON。
{
"source": "twilio",
"data": {
"SmsSid": "",
"Body": "",
"SmsStatus": "received",
"MessageSid": "",
"ApiVersion": "2010-04-01",
"From": "",
"AccountSid": "",
"NumMedia": "0",
"To": "",
"SmsMessageSid": "",
"NumSegments": "1"
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.