Chat-bots in Lua ================ TinyBrain (TinyBrain.de) now offers a way of creating a chat-bot (a program you can talk to) using very simple Lua code. Software installation required on your machine: none. All you need is a browser. Your chat-bots will be available on the Internet instantly. To create a chat-bot, upload a snippet of Lua code to the TinyBrain snippets database (http://tinybrain.de:8080/tb/). Choose type "Lua code - Chat-bot" and make the snippet public by ticking the appropriate checkbox. Remember the snippet's ID, e.g. #123 and enter the ID on the front page (http://tinybrain.de). That's all! How to write the code ===================== You'll get the user's last input in the variable "input". So a simple, stateless bot can look like this: return(input == "" and "Say something!" or "You just said: "..input) Yes, that's only one line of code. :) Stateful bots ============= Of course it is nice to have the bot remember something between user lines. To do this, use the "cookies" table, which is a Lua map (with string keys and string values). Here's an example from snippet #27 (http://tinybrain.de/27): if input ~= "" and cookies.name == nil then cookies.name = input end if cookies.name then return("Hello "..cookies.name.."!") else return "What's your name?" end Yes, that's all. btw, the cookies are totally persistent - even between server restarts. Sandbox ======= The Lua scripts run in a very tight sandbox. There is literally nothing "bad" you can do, not even writing endless loops. If you write more complex examples, you'll probably need more Lua libraries (only very few functions are available in the sandbox right now). If you have such a need, just write a mail (stefan.reich.maker.of.eye@gmail.com). Cheers! -Stefan
A tutorial/reference :)
Travelled to 12 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
ID | Author/Program | Comment | Date | |
---|---|---|---|---|
1368 | anonymous | </html> | 2018-04-04 10:24:10 | delete |
951 | #1000604 (pitcher) | 2015-08-20 15:28:24 | ||
950 | #1000610 | Edit suggestion: !636 !629 main { static Object androidContext; static String programID; public static void main(String[] args) throws Exception { Chat-bots in Lua ================ TinyBrain (TinyBrain.de) now offers a way of creating a chat-bot (a program you can talk to) using very simple Lua code. Software installation required on your machine: none. All you need is a browser. Your chat-bots will be available on the Internet instantly. To create a chat-bot, upload a snippet of Lua code to the TinyBrain snippets database (http://tinybrain.de:8080/tb/). Choose type "Lua code - Chat-bot" and make the snippet public by ticking the appropriate checkbox. Remember the snippet's ID, e.g. #123 and enter the ID on the front page (http://tinybrain.de). That's all! How to write the code ===================== You'll get the user's last input in the variable "input". So a simple, stateless bot can look like this: return(input == "" and "Say something!" or "You just said: "..input) Yes, that's only one line of code. :) Stateful bots ============= Of course it is nice to have the bot remember something between user lines. To do this, use the "cookies" table, which is a Lua map (with string keys and string values). Here's an example from snippet #27 (http://tinybrain.de/27): if input ~= "" and cookies.name == nil then cookies.name = input end if cookies.name then return("Hello "..cookies.name.."!") else return "What's your name?" end Yes, that's all. btw, the cookies are totally persistent - even between server restarts. Sandbox ======= The Lua scripts run in a very tight sandbox. There is literally nothing "bad" you can do, not even writing endless loops. If you write more complex examples, you'll probably need more Lua libraries (only very few functions are available in the sandbox right now). If you have such a need, just write a mail (stefan.reich.maker.of.eye@gmail.com). Cheers! -Stefan }} | 2015-08-20 06:41:45 | delete |
Recognizer | Recognition Result | Visualize | Recalc |
---|---|---|---|
#308 | 1861 | [visualize] |
Snippet ID: | #28 |
Snippet name: | Writing chat-bots in Lua |
Eternal ID of this version: | #28/1 |
Text MD5: | 44a8cc4315edc3eedc47e4e16653c3f7 |
Author: | stefan |
Category: | documents |
Type: | Document |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2013-12-12 23:37:34 |
Source code size: | 1861 bytes / 53 lines |
Pitched / IR pitched: | No / Yes |
Views / Downloads: | 4116 / 390 |
Referenced in: | [show references] |