This flow is to be used as orchestrator / controller of chatbot to be deployed on Telegrama, using as NLP Watson Assistant. Also this flow can receive voice from telegram, so uses Watson STT to convert voice to text.
-
-
Save sergiogama/d217dbd45323a902b53d527a92b14d74 to your computer and use it in GitHub Desktop.
Telegram ChatBot with Watson Assistant and STT to receive voice
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[{"id":"65916592.4d718c","type":"watson-conversation-v1","z":"8ba8e00b.f51c6","name":"","workspaceid":"8da116df-ab65-4936-a04d-a4c6eaf40b89","multiuser":false,"context":true,"empty-payload":false,"default-endpoint":true,"service-endpoint":"https://gateway.watsonplatform.net/conversation/api","timeout":"","optout-learning":false,"x":320,"y":318,"wires":[["8cd4ff73.aa632"]]},{"id":"8cd4ff73.aa632","type":"function","z":"8ba8e00b.f51c6","name":"Restore context","func":"for(x=0;x<msg.payload.output.text.length;x++)\n{\n msg.payload.chatId = flow.get(\"chatId\");\n msg.payload.type = \"message\" //flow.get(\"type\");\n msg.payload.content = msg.payload.output.text[x];\n node.send(msg);\n}\nreturn null;","outputs":1,"noerr":0,"x":500,"y":318,"wires":[["f33f7435.01f528"]]},{"id":"822cfffc.0c69e","type":"function","z":"8ba8e00b.f51c6","name":"Not authorized user","func":"msg.payload.chatId = flow.get(\"chatId\");\nmsg.payload.type = \"message\" //flow.get(\"type\");\nmsg.payload.content = \"Você não está autorizado\";\nreturn msg;","outputs":1,"noerr":0,"x":508.125,"y":481.4375305175781,"wires":[["f33f7435.01f528"]]},{"id":"69ef2432.8f3f7c","type":"comment","z":"8ba8e00b.f51c6","name":"Read.me","info":"1) Create a Watson Assistant and Watson Speach to Text on IBM Cloud (https://www.bluemix.net)\n2) Create a Telegram Bot:\n Open web.telegram.org\n find BotFather (contact)\n send /newbot\n Give a name for your bot (Botfather will ask it)\n Give a user name for it, which should have in the end \"Bot\"\n The BotFather will give you a token.\n3) Install node-red-contrib-telegrambot ","x":77,"y":55,"wires":[]},{"id":"f5df240c.5ae6d8","type":"watson-speech-to-text","z":"8ba8e00b.f51c6","name":"","alternatives":1,"speakerlabels":false,"smartformatting":false,"lang":"pt-BR","langhidden":"pt-BR","langcustom":"NoCustomisationSetting","langcustomhidden":"","custom-weight":"","band":"NarrowbandModel","bandhidden":"NarrowbandModel","keywords":"","keywords-threshold":"","word-confidence":false,"password":"","apikey":"josj9cmi9JBfDRSpxyQCR-VWniJ-rjZrH3tRMdXGP_n6","payload-response":true,"streaming-mode":false,"streaming-mute":false,"auto-connect":false,"discard-listening":false,"disable-precheck":false,"default-endpoint":true,"service-endpoint":"https://stream.watsonplatform.net/speech-to-text/api","x":480,"y":215,"wires":[["65916592.4d718c"]]},{"id":"7dbc3625.78c1e8","type":"switch","z":"8ba8e00b.f51c6","name":"","property":"type","propertyType":"flow","rules":[{"t":"eq","v":"voice","vt":"str"},{"t":"eq","v":"message","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":417,"y":83,"wires":[["2e274d4d.5a0f42"],["3c280c4d.20c974"]]},{"id":"2e274d4d.5a0f42","type":"change","z":"8ba8e00b.f51c6","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.weblink","tot":"msg"},{"t":"set","p":"audio","pt":"flow","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":579,"y":77,"wires":[["f5df240c.5ae6d8"]]},{"id":"342134d0.40ab8c","type":"function","z":"8ba8e00b.f51c6","name":"Save context","func":"flow.set(\"chatId\", msg.payload.chatId);\nflow.set(\"type\", msg.payload.type);\nflow.set(\"content\",msg.payload.content);\nflow.set(\"weblink\",msg.payload.weblink);\nflow.set(\"audio\",false);\nreturn msg;","outputs":1,"noerr":0,"x":275.125,"y":83.3125,"wires":[["7dbc3625.78c1e8"]]},{"id":"3c280c4d.20c974","type":"change","z":"8ba8e00b.f51c6","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.content","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":140,"y":318,"wires":[["65916592.4d718c"]]},{"id":"50de1c4e.6ff4c4","type":"telegram receiver","z":"8ba8e00b.f51c6","name":"","bot":"19b68e7a.18b0e2","saveDataDir":"","x":96.125,"y":89.3125,"wires":[["342134d0.40ab8c"],["822cfffc.0c69e"]]},{"id":"f33f7435.01f528","type":"telegram sender","z":"8ba8e00b.f51c6","name":"","bot":"19b68e7a.18b0e2","x":698,"y":318,"wires":[[]]},{"id":"19b68e7a.18b0e2","type":"telegram bot","z":"","botname":"hdidemobot","usernames":"","chatids":"","baseapiurl":"","updatemode":"polling","pollinterval":"300","usesocks":false,"sockshost":"","socksport":"6667","socksusername":"anonymous","sockspassword":"","bothost":"","localbotport":"8443","publicbotport":"8443","privatekey":"","certificate":"","useselfsignedcertificate":true,"verboselogging":true}] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment