简体   繁体   English

如何在履行对话框流中从 Twilio 获取电话号码

[英]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.

相关问题 如何从nodejs中的内部函数调用外部函数? 我正在为 Google 对话流实现编码 - How to call outer function from inner function in nodejs? I am coding for Google dialogflow fulfillment 我可以在 Inline Fulfillment Dialogflow 编辑器中跨对话存储计数器吗? - Can I store a counter across conversation in Inline Fulfillment Dialogflow editor? 如何使用dialogflow实现来获取设备的精确位置 - how to get device precise location using dialogflow fulfillment 如何在环境Dialogflow->实现中发出http请求? - How do I make a http request in the environment Dialogflow -> Fulfillment? 如何在对话流实现中使用 OR 运算符 - How to use OR operator in dialogflow fulfillment 如何使用对话流实现从列表响应的上下文中提取参数 - how to extract parameters from the context for list response using dialogflow fulfillment 如何使用Firebase中的Dialogflow实现来获取数据 - How to fetch data using Dialogflow Fulfillment from Firebase 在没有Twilio的情况下如何发送现有电话号码的SMS? - How can you send SMS for an existing phone number without Twilio? 获取原始参数输入-Dialogflow实现 - Get original parameter input - Dialogflow Fulfillment 从过去的意图访问参数 Dialogflow Fulfillment - Access parameters from past intents Dialogflow Fulfillment
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM