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

How can I set up a rest endpoint without using socket.io? #10

Closed
yasinAtlibra opened this issue Oct 17, 2017 · 3 comments
Closed

How can I set up a rest endpoint without using socket.io? #10

yasinAtlibra opened this issue Oct 17, 2017 · 3 comments
Labels

Comments

@yasinAtlibra
Copy link

It would be great if you provide an example of restifying the bot.

@andersonba
Copy link
Owner

Sure! I will do it 👍

@andersonba
Copy link
Owner

andersonba commented Oct 19, 2017

@yasinAtlibra Did you check the web example?
You can define the rules using javascript or converting a yaml string (js-yaml), no need server.
If you want to save the user's answers in a database, you can just call the API using the bot events, like end or storeChanged.

new YveBot(rules)
  .on('end', (data) => {
    $.post('url', { data });
  })
  ...

But if you want to load the chat rules in server and keep the control of rules/sessions, step by step, like

User opens chat
  Client asks server for rule
    Server replies a rule
      Client answers
        Server receives and replies the next rule
          ... 

I recommend you to use socket.io because the chat conversation is async, you will need to implement sequential ajax requests to simulate the same behavior.

Which kind you're talking about?

@yasinAtlibra
Copy link
Author

Thanks for your answer, I been able to run the bot, but did not use rest point. Just followed your example 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants