简体   繁体   English

自动驾驶仪和功能收集数据他

[英]Autopilot and Functions collecting data he

I have a task in autopilot that collects data from a caller then calls a function using a redirect.我在自动驾驶仪中有一个任务,它从调用者那里收集数据,然后使用重定向调用 function。 I cant seem to access the post variables.我似乎无法访问帖子变量。 please assist.请协助。

so when run this I get the following error所以当运行这个我得到以下错误

Error - 82002错误 - 82002

Error on Twilio Function response Twilio Function 响应错误

produced by this line of code这行代码产生的

var first_name = memory.twilio.collected_data.lead_qual.lead_qual_first; var first_name = memory.twilio.collected_data.lead_qual.lead_qual_first;

remove that line and it works fine just no access to the collected data.删除该行,它可以正常工作,只是无法访问收集的数据。

following are the dependencies I have included, the task code and the function.以下是我包含的依赖项、任务代码和 function。

looks like this.. Dependencies......>看起来像这样..依赖项......>

lodash 4.17.11 twilio 3.29.2 fs 0.0.1-security got 9.6.0 moment-timezone 0.5.14 moment 2.29.1 xmldom 0.1.27 twilio/runtime-handler 1.0.1 util 0.11.0 request 2.87.0 lodash 4.17.11 twilio 3.29.2 fs 0.0.1-security got 9.6.0 moment-timezone 0.5.14 moment 2.29.1 xmldom 0.1.27 twilio/runtime-handler 1.0.1 util 0.11.0 request 2.8.7

Task......>任务……>

    {
"actions": [
{
"collect": {
"name": "lead_qual",
"questions": [
{
"question": "What is your first name?",
"name": "lead_qual_first",
"type": "Twilio.FIRST_NAME"
},
{
"question": "What is your last name?",
"name": "lead_qual_last",
"type": "Twilio.LAST_NAME"
},
{
"question": "If we are disconnected what is the best phone number to reach you on??",
"name": "lead_qual_phone",
"type": "Twilio.PHONE_NUMBER"
},
{
"question": "What is your date of birth?",
"name": "lead_qual_dob",
"type": "Twilio.DATE"
},
{
"question": "Are you currently covered by disability, yes or no?",
"name": "lead_qual_disability",
"type": "Twilio.YES_NO"
},
{
"question": "Do you have any form of federal medicare, yes or no?",
"name": "lead_qual_medicare",
"type": "Twilio.YES_NO"
},
{
"question": "Do you have medicaid or another state sponsored insurance, yes or no?",
"name": "lead_qual_medicaid",
"type": "Twilio.YES_NO"
},
{
"question": "Finally, Are you currently insured, yes or no?",
"name": "lead_qual_insured",
"type": "Twilio.YES_NO"
}
],
"on_complete": {
"redirect": {
"method": "POST",
"uri": "https://health-agent-3097.twil.io/Evaluate-Answers"
}
}
}
}
]
}
 

Function......> Function......>

// This is your new function. To start, set the name and path on the left.

exports.handler = function(context, event, callback) {

// Require the component used to post.

const got = require("got");

// Time zone for EST to check times with.

let moment = require('moment-timezone');

const now = moment().tz('America/New_York');

// initialize the return object

var responseObject = {};

var first_name = memory.twilio.collected_data.lead_qual.lead_qual_first;

responseObject =

{

"actions":[

  {

    "say":"Force Override result"

  },

  {

    "redirect": {

      "method": "POST",

      "uri": "task://goodbye"

    }

  }

]
}

// This callback is what is returned in response to this function being invoked.

callback(null, responseObject);}

Twilio developer evangelist here. Twilio 开发人员布道师在这里。

memory is not one of the arguments passed to a Twilio Function. memory不是传递给 Twilio Z86408593C34AF77FDD1Z0DF932F8B526 的 arguments 之一You are passed event , context and callback .你被传递eventcontextcallback You are using the callback correctly and the context includes your environment variables.您正在正确使用callback ,并且context包含您的环境变量。

The event object is what you need here though.不过,您在这里需要event object。 The event includes all the parameters sent to the Function.event包括发送到 Function 的所有参数。 According tothe documentation on the Autopilot request you will be sent a Memory parameter.根据Autopilot 请求的文档,您将收到一个Memory参数。 That Memory will be a JSON string that needs parsing.那个Memory将是一个需要解析的 JSON 字符串。 So instead, try accessing:因此,请尝试访问:

const memory = JSON.parse(event.Memory);
const firstName = memory.twilio.collected_data.lead_qual.lead_qual_first;

Let me know how you get on with that.让我知道你是怎么做到的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用函数对 Autopilot 进行多次出站调用 - 运行时应用程序超时 - Multiple Outbound Calls to Autopilot using Functions - runtime application timed out 节点中的回调混淆和数据收集 - Callback Confusion and Collecting Data in Node 从 vscode 扩展收集数据 - collecting data from vscode extension NodeJs Mongoose循环收集数据 - NodeJs Mongoose collecting data in loop Dtrace没有为NodeJS收集任何数据 - Dtrace is not collecting any data for NodeJS 使用Promise收集大小未知的分页数据 - Collecting paginated data of unknown size using promises 使用jetbrains变量调试node.js会显示“正在收集数据…” - Debugging node.js with jetbrains variables show 'Collecting data…' Node js任务,收集数据,服务Web以及从Beaglebone发送数据 - Node js tasks, collecting data, serving web and sending data from beaglebone 使用 express 循环遍历 mongoose 模式函数,将数据收集到一个数组中并最终使用所有数据渲染页面 - using express to loop through a mongoose schema function ,collecting data into an array and rendering the page finally with all the data NodeJ:使用http.get()跨多个“数据”事件收集数据 - NodeJs: Collecting data across multiple “data” events using http.get()
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM