如何构造 JSON 动作模式

How to structure JSON Action Schema

我想要一个 Autopilot 机器人将其内存数据发送到我的一个 webhook 文件(在 PHP 中)并在 return 中(作为回调)只打印一条消息说 "Received"。 但是每次,我都会收到一条错误消息 "It does not match with Action Schema."

所以我想知道是否有人可以给我一个很好的例子来说明如何做到这一点?

我试过阅读 Debugger 中提供的 ActionSchema.json 文件,但我根本无法理解它。

我试过这样

echo '"definitions": {
    "say": {
      "anyOf": [
        {
          "type": "strdfghing"
        }';

我希望 Twilio Autopilot 在将其内存事件发送到 webhook 文件后回复 "Got it!"。

这里是 Twilio 开发人员布道者。

欢迎使用 Whosebug!

所以您可能 Collect flow, where you can use the Say verb to respond with "got it!" at the end in the on_complete of a Redirect。您的 Autopilot 任务可能如下所示:

"actions": [
        {
            "collect": {
                "name": "collect_clothes_order",
                "questions": [
                    {
                        "question": "What is your first name?",
                        "name": "first_name",
                        "type": "Twilio.FIRST_NAME"
                    },

                ],
                "on_complete": {
                    "redirect": "your-web-server-ie-a-twilio-function-maybe"
                    }
                }
            }
        ]

然后,在您的Twilio Function(或使用您选择的语言的其他网络服务器)中,您可以接收内存数据(在本例中,是用户响应的名字),并且return Say 包含 "got it!":

exports.handler = function(context, event, callback) {
    let responseObject = {};
    let memory = JSON.parse(event.Memory);

    console.log(memory.twilio.collected_data);
     let first_name = memory.twilio.collected_data.collect_clothes_order.answers.first_name.answer;
    console.log(first_name); //collected data from memory
    responseObject = {"actions":[
        { "say": { "speech": "Got it!" } }
    ]};
    callback(null, responseObject);
};

如果这有帮助,请告诉我!