im creating a telegram bot using nodejs and telegrafjs
i want to know how to create this menu button i cant find anywhere in documents.
it opens up a menu like this one
Check this examples
bot.command('your command', async (ctx) => {
return await ctx.reply('this is text', Markup
.keyboard([
['button 1', 'button 2'], // Row1 with 2 buttons
['button 3', 'button 4'], // Row2 with 2 buttons
['button 5', 'button 6', 'button 7'] // Row3 with 3 buttons
])
.oneTime()
.resize()
)
})
Related
I have connected Dialogflow agent to a Facebook page, and i'm displaying Facebook card response using the fulfillment feature in Dialogflow. i can't figure out how to catch the card button click event. I need the chat to move to the next intent on button click. However button click doesn't trigger anything.
Here's the fulfillment code used to create button
function getState(agent){
state = agent.parameters.State;
return getAd()
.then(result => {
for(const item of result.result){
agent.add(new Card({
title: item.nmi,
imageUrl: 'url',
text: item.structuredAddress.singleAddressLine,
buttonText: item.nmi,
buttonUrl: 'uri'
})
);
}
})
.catch(() => {
agent.add(`I'm sorry.`);
});
}`
You can use the payload field in the postback button to send a
specific message back to dialogflow when the button is clicked.
If you combine this with the parameters, you can use them to trigger
specific intents, or just to send the information of the product
clicked
check the original answer Here
I need add two action into submit button, I succeed on that but because I can't find correct function from API, there is two buttons. Like this
I want it like this:
What I have tried
form.addSubmitButton({ label: 'Action 1'});
form.addSubmitButton({ label: 'Action 2'});
And
form.addSubmitButton({ id : 'action', label: 'Action 1'});
form.addSubmitButton({ id : 'action', label: 'Action 2'});
And
form.addSubmitButton({ id: 'action1', label: 'Action 1'});
var test = form.addSubmitButton({ id: 'action2', label: 'Action 2'});
test.isHidden = true;
Something that worked for me was adding the name attribute to each submit button using client script. That way when the user clicks it will send the name as a parameter.
When using the telegram API (in my case using telebot:https://github.com/kosmodrey/telebot)
How can link to a bot_command with a parameter ?
For example i want a bot that shows information about some fruits and i have
['apples','pears','bananas']
i can do /show [fruit] to show details about each fruit and /list to
show a list of all fruits.
When i do /list i want to show it like this:
You currently have 3 fruit:
APPLES PEARS BANANAS
However i want these to be clickable and once the user clicks a fruitname, he
will be directed to /show [clicked fruit].
i tried with a normal a href in { parse_mode : HTML } but that doesn't
seem to work.
Use inline buttons. They work the way you described. For example:
var options = {
reply_markup: JSON.stringify({
inline_keyboard: [
[
{text: 'button 1', callback_data: '1'},
{text: 'button 2', callback_data: '2'},
{text: 'button 3', callback_data: '3'},
],
]
})
};
bot.sendMessage(chatId, 'Pick action:', options);
You can think of them as anchor tags. They appear along with the text in chat window, and scroll with the text, but you can click on them. Non-inline buttons are more like a permanent menu.
Example above is using this library.
I'm trying to add a colorbutton in a TinyMCE dialog box to replace my old color selector which was initially created with a select input.
See : ColorButton : API 4.X
This class creates a color button control. This is a split button in which the main button has a visual representation of the currently selected color. When clicked the caret button displays a color picker, allowing the user to select a new color.
I can add and see the new colorbutton in the dialog box but it doesn't show the colorpicker when clicked.
Here is my code:
editor.windowManager.open( {
title: 'Choose color',
body: [
{
type: 'listbox',
name: 'bg-color',
label: 'Color (select)',
'values': [
{text: 'White', value: '#FFF'},
{text: 'Black', value: '#000'},
{text: 'Silver', value: 'silver'},
]
},
{
type: 'ColorButton',
name: 'bg-color2',
label: 'Color (colorpicker)',
},
],
onsubmit: function(e) {
// Do something here
}
});
And you will find a tinymce fiddle here to illustrate this issue:http://fiddle.tinymce.com/sfeaab
Since my debugger doesn't show any JS error, is there something wrong in this code or is there another way to add a colorpicker in a dialogbox?
Thanks!
#MavBzh I think you've a wrong perception on how the color button works. The ColorButton UI is only help with rendering a button which not much difference with PanelButton UI. you can see this example http://fiddle.tinymce.com/sfeaab/3 in this fiddle I use textcolor plugin example.
So, in order to use color button you're required to specify the Panel to hold the color picker.
{
type: 'colorbutton',
name: 'color',
text: 'Color',
selectcmd: 'ForeColor',
panel: {
role: 'application',
ariaRemember: true,
html: renderColorPicker,
onclick: onPanelClick
},
onclick: onButtonClick
}
then later set onclick callback action and render the color picker HTML output yourself, the renderColorPicker function is used as the panel content, then assigned onPanelClick callback to put the color to the text placeholder in the ColorButton.
PS: in the fiddle I used v4.0.21
I'm following this tutorial to create a Sencha Touch Application,
I want to create 2 buttons on the same screen and each button redirect to another page when clicked, on the tutorial it use Form panel and only one button to redirect to another page, but if I link 2 Form Panels to the Navigator View, it only appear one form panel, I want to know a way to add 2 buttons on the same screen and call one userAlias for each button to redirect to the another page.
What I do ? Add 2 buttons on the same FormPanel ? If yes, how I call one diferent page for each button, because I use only one userAlias on the form panel with this function:
button.up('navigationview').push({
xtype: 'step3',
title: 'Step 3'
});
Thanks for the help
use two different handlers for the buttons.
Example :: Button 1 ::
{
xtype : 'button',
text : 'button 1',
handler : function(){
alert('do something');
this.up('navigationview').push({ . . . . });
}
}
Example :: Button 2 ::
{
xtype : 'button',
text : 'button 2',
handler : function(){
alert('do something else');
this.up('navigationview').push({ . . . . });
}
}