@dabblelab/autopilot-helper

1.0.0-beta.1 • Public • Published

autopilot-helper

List of helper functions

  • Response generator
var helper = require("autopilot-helper");

var rsp = new helper.response();

rsp.say("abc");
rsp.handoff("channel", "url", "method");
rsp.remember({ name: "John doe" });
rsp.play("url", 1); //audio url , loop count
callback(null, rsp.generate());

output:

{
    actions: [
        {
            say: 'abc'
        },
        {
            handoff: {
                channel: 'channel',
                uri: 'url',
                method: 'method'
            }
        },
        {
            remember: {
                name: 'John doe'
            }
        },
        {
            play: {
				loop: 1,
				url: 'url'
			}
        }
    ]
}
  • List of response methods supported

    • say(text)
    • collect(name, questions, redirect)
    • listen(tasks = false)
    • play(url, loop_count = 1)
    • redirect(url, method = false)
    • handoff(channel, url, method, voice_status_callback_url = false, voice_status_callback_method = false)
    • handoff_task_flex(channel, task_url, wait_url = false, wait_url_method = false, action = false, priority = false, timeout = false)
    • remember(remember_object)
    • show(body, images = false)
  • Filter field values

event = {
    Field_dept_var_Type: "dept",
    Field_dept_var_Value: "sales",
    Channel: "sms"
};

var fields = helper.fields(event);
console.log(fields[dept_var]);

output:

sales
  • Random response
var event = {
    Field_dept_var_Type: "dept",
    Field_dept_var_Value: "sales",
    Channel: "sms",
    Memory: { name: "John doe" }
};
var responses = ["Hey {name} ,i am from {dept_var} department", "Which {dept_var}"];

var random = helper.random(responses, event);
console.log(random);

output:

Hey John doe ,i am from sales department

Package Sidebar

Install

npm i @dabblelab/autopilot-helper

Weekly Downloads

1

Version

1.0.0-beta.1

License

MIT

Unpacked Size

8.41 kB

Total Files

7

Last publish

Collaborators

  • stevetingiris
  • khalid0807