Skip to content

Instantly share code, notes, and snippets.

@sergiogama
Last active October 26, 2023 20:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save sergiogama/d8e99143e06720396aa2730d8015e4c0 to your computer and use it in GitHub Desktop.
Save sergiogama/d8e99143e06720396aa2730d8015e4c0 to your computer and use it in GitHub Desktop.
Telegram ChatBot using IBM Watson Conversation

This flow uses TelegramBot node and IBM Watson Conversation

[
{
"id": "3e0a95af.e5f08a",
"type": "function",
"z": "8c07c84c901460eb",
"name": "Save context",
"func": "context.flow.chatId = msg.payload.chatId;\ncontext.flow.type = msg.payload.type;\nmsg.payload = msg.payload.content;\nreturn msg;",
"outputs": 1,
"timeout": "",
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 310,
"y": 100,
"wires": [
[
"24ebd36b.04d1e4"
]
]
},
{
"id": "24ebd36b.04d1e4",
"type": "watson-conversation-v1",
"z": "8c07c84c901460eb",
"name": "",
"workspaceid": "0a1df2e1-faa4-4607-9641-63e8b56a46c5",
"multiuser": false,
"context": true,
"empty-payload": false,
"service-endpoint": "https://api.us-south.assistant.watson.cloud.ibm.com/instances/d38f0242-f900-4813-90c0-136552c8a516",
"timeout": "",
"optout-learning": false,
"x": 480,
"y": 100,
"wires": [
[
"3c133c0c.807744"
]
]
},
{
"id": "3c133c0c.807744",
"type": "function",
"z": "8c07c84c901460eb",
"name": "Restore context",
"func": "msg.payload.chatId = context.flow.chatId;\nmsg.payload.type = context.flow.type;\nmsg.payload.content = msg.payload.output.generic[0].text;\nreturn msg;",
"outputs": 1,
"timeout": "",
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 660,
"y": 100,
"wires": [
[
"106e3553196519f9"
]
]
},
{
"id": "10222f18.29e139",
"type": "function",
"z": "8c07c84c901460eb",
"name": "Not authorized user",
"func": "msg.payload.content = \"You're not authorized user\";\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 490,
"y": 180,
"wires": [
[
"106e3553196519f9"
]
]
},
{
"id": "c61665b5.dc1d8",
"type": "comment",
"z": "8c07c84c901460eb",
"name": "Read.me",
"info": "1) Create a Watson Conversation 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) Baixe o nó node-red-contrib-telegrambot\n Configure o nó receiver com o token dado\n pelo Botfather\n ",
"x": 100,
"y": 40,
"wires": []
},
{
"id": "fe94e8a123af9817",
"type": "telegram receiver",
"z": "8c07c84c901460eb",
"name": "",
"bot": "15f92a8235375ec0",
"saveDataDir": "",
"filterCommands": false,
"x": 120,
"y": 100,
"wires": [
[
"3e0a95af.e5f08a"
],
[
"10222f18.29e139"
]
]
},
{
"id": "106e3553196519f9",
"type": "telegram sender",
"z": "8c07c84c901460eb",
"name": "",
"bot": "15f92a8235375ec0",
"haserroroutput": false,
"outputs": 1,
"x": 860,
"y": 100,
"wires": [
[]
]
},
{
"id": "15f92a8235375ec0",
"type": "telegram bot",
"botname": "gama-fiap",
"usernames": "",
"chatids": "",
"baseapiurl": "",
"updatemode": "polling",
"pollinterval": "300",
"usesocks": false,
"sockshost": "",
"socksprotocol": "socks5",
"socksport": "6667",
"socksusername": "anonymous",
"sockspassword": "",
"bothost": "",
"botpath": "",
"localbotport": "8443",
"publicbotport": "8443",
"privatekey": "",
"certificate": "",
"useselfsignedcertificate": false,
"sslterminated": false,
"verboselogging": false
}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment