Giter Site home page Giter Site logo

Comments (3)

guidone avatar guidone commented on September 24, 2024

@gerardovf yes, I guess the node-red ui will eat all your special chars but you can prepare the payload in an upstream function node, something like

msg.payload = {
  message: 'The message with the buttons',
  buttons: [
    {
      value: 'text 1',
      label: 'label of the button 1',
      answer: 'this is the answer',
      alert: true,
      newLine: true
    },
    {
      value: 'text 2',
      label: 'another label',
      answer: 'this is the answer 2',
      alert: false
    }
  ]
}
return msg;

from node-red-contrib-chatbot.

gerardovf avatar gerardovf commented on September 24, 2024

@guidone You were right!! Now only the 'newLine' is still not working... (I wanted to show a 2x2 buttons keyboard)

I used this page to get the emoji conversion: http://www.fileformat.info/info/unicode/char/search.htm

Then in the upstream function node I inserted:

console.log(msg);
var chat = msg.chat();
var cloned = RED.util.cloneMessage(msg);
cloned.payload = {
type: "buttons",
content: 'The message with the buttons',
messageId: null,
chatId: chat.get('chatId'),
buttons: [
{
value: '\uD83D\uDD06\nON1',
label: 'label of the button 1',
answer: 'this is the answer',
alert: true,
newLine: false
},
{
value: '\u2B06\nON2',
label: 'another label',
answer: 'this is the answer 2',
alert: false,
newLine: true
},
{
value: '\uD83D\uDD05\nOFF1',
label: 'label of the button 3',
answer: 'this is the answer 3',
alert: true,
newLine: false
},
{
value: '\u2B07\nOFF2',
label: 'another label 2',
answer: 'this is the answer 4',
alert: false,
newLine: true
}
]
}
return cloned;

fancykbd

from node-red-contrib-chatbot.

gerardovf avatar gerardovf commented on September 24, 2024

@guidone I also checked that 'newLine' is working with "inline-buttons"

console.log(msg);
var chat = msg.chat();
var cloned = RED.util.cloneMessage(msg);
cloned.payload = {
type: "inline-buttons",
content: 'The message with the buttons',
messageId: null,
chatId: chat.get('chatId'),
buttons: [
{
value: '\uD83D\uDD06\nON1',
label: '\uD83D\uDD06\nON1',
answer: 'this is the answer',
newLine: false
},
{
value: '\u2B06\nON2',
label: '\u2B06\nON2',
answer: 'this is the answer 2',
newLine: true
},
{
value: '\uD83D\uDD05\nOFF1',
label: '\uD83D\uDD05\nOFF1',
answer: 'this is the answer 3',
newLine: false
},
{
value: '\u2B07\nOFF2',
label: '\u2B07\nOFF2',
answer: 'this is the answer 4',
newLine: true
}
]
}
return cloned;

fancybuttons

from node-red-contrib-chatbot.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.