Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass answer content when the answer is func #75

Merged
merged 1 commit into from
Apr 18, 2020

Conversation

ereltapiro
Copy link

Pass answer content to callback when the answer is func

@dmitrizzle
Copy link
Owner

Hey, @ereltapiro thank you for the PR, I really appreciate it. Could you pls give me some detail on what this change fixes?

@ereltapiro
Copy link
Author

Its come to solve when your answer is a function and you want to create one function for multiple questions and still know which option he chose
for example, I want to create an "Answer function" that alerts my chose so I need to receive the content of the "replay question"
For example:

var convo = {
--
  | ice: {
  | says: ["Hi", "Would you like banana or ice cream?"],
  | reply: [
  | {
  | question: "Banana",
  |  
  | // instead of the key name for conversation block you can simply pass
  | // a name of the function you want to call
  | // it can not accept any parameters at this moment;
  | // this function has to be declared on this very document page
  | // this is for security;
  | answer: "genericFunction"
  | },
  | {
  | question: "Ice Cream",
  | answer: "genericFunction"
  | }
  | ]
  | },
  | "ice-cream": {
  | says: ["🍦"],
  | reply: [
  | {
  | question: "Start Over",
  | answer: "ice"
  | }
  | ]
  | }
  | }
  |  
  | // this function is called when user asks for banana or ice cream and recive the content of the answer (banana or ice cream)
  | genericFunction = function(theConentOfTheAnswer) {
  | alert("theConentOfTheAnswer")
  | chatWindow.talk(convo, "ice") // the conversation can be easily restarted from here.
  | }

@dmitrizzle
Copy link
Owner

Got it. Merging and releasing, thank you 🎉

@dmitrizzle dmitrizzle merged commit c770d1a into dmitrizzle:master Apr 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants