How to show options in telegram bot? - telegram-bot

I want to write a bot telegram.How to put possible option in my bot.I insert a picture of sample bot with this functionality.

For that, you have to talk to BotFather.
In the Telegram App, open the chat with BotFather.
Send him /setcommands. He will present you with a list of your bots.
Pick the bot for which you want to set the command menu.
Compose and send the command list. Using your image as an example, these 4 lines should do:
start - Description 1
menu - Description 2
help - Description 3
stop - Description 4
Note that command part of each line(left side of - signs) must have just lowercase characters, and no slashes. There should also be spaces around the - sign.
Once you complete this process, exit and kill the Telegram App. Re-open it, go to the chat with your target bot, type a / (or tab on the / button next to the text field), the command menu should come up.

New dynamic way to set commands
Telegram introduced a separate method setMyCommands which allows you to set commands via API directly from your code.
{
"commands": [
{
"command": "start",
"description": "Start using bot"
},
{
"command": "help",
"description": "Display help"
},
{
"command": "menu",
"description": "Display menu"
}
],
"language_code": "en"
}
Moreover, it allows you to customize commands per language code with language_code parameter

Without json.dumps([]) I get error response from Tlg: {'ok': False, 'error_code': 400, 'description': "Bad Request: can't parse commands JSON object"}
The code below works as expected.
{
"commands": json.dumps([
{
"command": "start",
"description": "Start using bot"
},
{
"command": "help",
"description": "Display help"
},
{
"command": "menu",
"description": "Display menu"
}
])
}

<?php
$comandos = [
["command" => "a", "description" => "aaa"],
["command" => "b", "description" => "bbb"],
["command" => "c", "description" => "ccc"],
];
defineMenuOptions($comandos);
function defineMenuOptions($comandos) {
$comandosEnc = "setMyCommands?commands=" . json_encode($comandos);
$retorno = file_get_contents(API_URL.$comandosEnc);
}
?>

Related

jira res-api create issue with bullets list in description

Hi i want to create a jira issue with bullet list and other formating from rest-api
Right know i am testing this code, but it returns
{
"errorMessages": [],
"errors": {
"description": "Operation value must be a string"
}
}
Body looks like this
{
"fields": {
"project": {
"key": "DWH"
},
"issuetype": {
"name": "Story"
},
"summary": "auto created datatask",
"description": "description": ["Pro:<fil pro and activity number provided>.",
"Tablename:<fill table name>.",
"Table view:<fill table view name>.",
"endpoint:<fill knudepunkt>.",
"Task to do.",
"*Copy attached document to metadata/new folder.",
"* Run job to create the table.",
"* Test the data in Production when ready.",
"* Create extra userstory"],
"assignee": {
"key": "bdmdwhdata",
"name": "bdmdwhdata",
"emailAddress": "dwhdata#bankdata.dk"
},
"labels": ["DATA"]
}
}
Is it possible to create multiline decription from REST-API in jira issues
I i jost write a single line in description it works fine.
For adding new lines, try using \n in the description. For more information, kindly check this documentation.

Netcore server respond to slack interactive message

I am trying to build Slack application with asp net core server. Currently, I have added Slash command which makes a request to my local server through ngrok. Once my server receives that request, it makes a post request to configured slack webhook to display interactive message which looks like pic from attachment.
I want user to be able to select yes or no and receive the result in my controller, but I can't realize how to tell Slack where should it make a post request. I attach the code of this message which is posted through weebhook into Slack:
{
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "This is a section block with a button."
}
},
{
"type": "actions",
"block_id": "actionblock789",
"elements": [
{
"type": "button",
"text": {
"type": "plain_text",
"text": "Yes"
},
"style": "primary",
"value": "yes"
},
{
"type": "button",
"text": {
"type": "plain_text",
"text": "No"
},
"value": "no"
}
]
}
]
}
What I have in netcore is TestController with route /api/test which I suppose should receive from Slack a payload where information about selected button is set, but I couldn't find a way where specify a url in this json code.
You can not configure a URL in the JSON code. That is not how it works with the Slack API.
Slack will send all responses to interactive message - like when someone clicks on a button - to the configured request URL of your Slack app. Check out this link how to find that parameter: documentation

How do I change the background image on an Alexa Show skill card?

I'm new to programming Alexa skills, especially with the Echo Show. I am trying to change the background image of the skill card from the default dark grey to something else. I know there has to be a way to do this because when I say, "Alexa, tell me a joke." that skill's background is red. And when I say, "Alexa, tell me about LeBron James." Alexa changes the background to LeBron James and the text auto scrolls. Any help on this would be great.
You can indeed change the background of an Alexa Show skill. Unfortunately, at this time Amazon does not offer a bunch of styling functionality beyond that for the Show skills.
The display interface reference is the documentation that you should read. It will give you an understanding of how all your calls and responses will be sent/received as JSON objects. In order to change the background you must choose one of the few template options they have available and add the background key and value to your JSON response structure.
For example, check out the following response structure you should send back from your AWS lambda function. It renders BodyTemplate2 which displays an image on the side of the screen with text on the other side. (This was taken from the display interface reference). Look at the key, "backgroundImage" and the following value.
{
"type": "Display.RenderTemplate",
"template": {
"type": "BodyTemplate2",
"token": "A2079",
"backButton": "VISIBLE",
"backgroundImage": {
"contentDescription": "Textured grey background",
"sources": [
{
"url": "https://www.example.com/background-image1.png"
}
],
"title": "My Favorite Car",
"image": {
"contentDescription": "My favorite car",
"sources": [
{
"url": "https://www.example.com/my-favorite-car.png"
}
]
},
"textContent": {
"primaryText": {
"text": "See my favorite car",
"type": "PlainText"
},
"secondaryText": {
"text": "Custom-painted",
"type": "PlainText"
},
"tertiaryText": {
"text": "By me!",
"type": "PlainText"
}
}
}
}
}

How do I create an event using the SocialTables API?

I'm trying to use the /4.0/legacyvm3/teams/{team}/events endpoint to create an event. I'm running into some trouble with spaces.
I used the /4.0/legacyvm3/teams/{team}/venues endpoint to get a list of venues. I chose one to include in the spaces section and posted this:
{
"name": "Event via API Test 04",
"category": "athletic event",
"public": true,
"attendee_management": true,
"start_time": "2017-04-05T16:13:54.217Z",
"end_time": "2017-04-05T16:13:54.217Z",
"uses_metric": false,
"venue_mapper_version": 0,
"spaces": [
{
"venue_id": 128379,
"name": "Snurrrggggg"
}
]
}
The endpoint returns a 400 code and this error:
{
"code": 400,
"message": "Cannot read property 'toLowerCase' of undefined"
}
I tried including the wizard section, but each time it would return this error:
{
"message": "Access Denied to this feature"
}
After some experimentation, this body succeeded:
{
"name": "Event via API Test 03",
"category": "athletic event",
"public": true,
"attendee_management": true,
"start_time": "2017-04-05T16:13:54.217Z",
"end_time": "2017-04-05T16:13:54.217Z",
"uses_metric": false,
"venue_mapper_version": 0,
"spaces": [
{
"name": "Fake News Room"
}
]
}
But the application itself would not display the diagram, and the newly created room did not show up in my list of venues. Perhaps it did not assign permissions to it?
In any case, I don't actually want to create a new venue/space. I want to pass in an existing venue/space. How do I do that?
The short answer is to create a working diagram in 4.0 you will need to POST some data to the /4.0/diagrams endpoint.
The room you create doesn't map to the same concept as venues. When you create an event as you did, it creates a new space entity. The spaces endpoints can return information on those.

Testing in-app purchases in Kindle Fire application

I am not able to test in app purchases even with Amazon Appstore SDK Tester.
public void onPurchaseResponse(final PurchaseResponse purchaseResponse)
purchaseResponse always has "INVALID_SKU" even if I have amazon.sdktester.json file with fake JSON.
file content:
{
"test" : {
"itemType": "CONSUMABLE",
"price": 0.99,
"title": "More Clicks!",
"description": "Click your button ten more times!",
"smallIconUrl": "http://www.google.com/images/srpr/logo3w.png"
},
"com.amazon.buttonclicker.ten_clicks" : {
"itemType": "CONSUMABLE",
"price": 0.99,
"title": "More Clicks!",
"description": "Click your button ten more times!",
"smallIconUrl": "http://www.google.com/images/srpr/logo3w.png"
},
"com.amazon.buttonclicker.blue_button" : {
"itemType": "ENTITLED",
"price": 0.99,
"title": "Blue Button",
"description": "Button Clicker - Now in Blue!",
"smallIconUrl": "http://www.google.com/images/srpr/logo3w.png"
}
}
Even sample application does not work.
Do you have any suggestions how to test application? It seems that Amazon SDK Tester does not intercept requests.
Here's how I got the In App purchases to work on Kindle Fire (after several hrs of struggle...)
adb install AmazonSDKTester.apk (Install SDKTester on Kindle Fire)
Create a file amazon.sdktester.json in the SDCARD directory (The connected KF shows up as SDCARD in Finder on ur Mac)
Contents of amazon.sdktester.json - {
"com.yourcompany.yourpkgname.200_coins" : {
"itemType": "CONSUMABLE",
"price": 0.99,
"title": "200 COINS",
"description": "2 COINS",
"smallIconUrl": "http://www.yourcompany.com/icon.png"
}
}
Press the power button on KF & press "Disconnect" button - Now KF is no longer a mounted drive on ur Mac.
Run the AmazonSDKTester app on KF.
Run your app from Eclipse. Make sure the package name in the JSON matches the In App Item SKU on Amazon's website & in the PurchasingManager.initiatePurchaseRequest("com.yourcompany.yourpkgname.200_coins");
Now you should see the In App interstitials showing up.
Still doesn't work - Force Close both your app & AmazonSDKTester on KF; Hard Reset KF ; Restart Eclipse & Restart from Step 1
Don't forget the outer enclosing {} braces in your json.
It took me 3 hours until I figured that out...
It looks like magic but hard reset resolved all my problems.
Make sure to hit the disconnect button after you connect the usb cable to your pc, otherewise the SDK tester will not be able to read the JSON file you moved over since the device is mounted at that point. Found this out the hard way.
I have faced with the issue that the same as your, the key is: in your java code, your item id must equal to your SKU in json file, in this case, it must be: com.amazon.buttonclicker.ten_clicks or com.amazon.buttonclicker.blue_button
Here is the example json file for SampleIAPConsumablesApp and SampleIAPEntitlementsApp sample project provied by Amazon:
{
"com.amazon.sample.iap.consumable.orange" : {
"itemType": "CONSUMABLE",
"price": 0.99,
"title": "More Clicks!",
"description": "Click your button ten more times!",
"smallIconUrl": "http://some/image.jpg"
},
"com.amazon.sample.iap.entitlement.level2" : {
"itemType": "ENTITLED",
"price": 0.99,
"title": "Blue Button",
"description": "Button Clicker - Now in Blue!",
"smallIconUrl": "http://some/image.jpg"
}
}
Goodluck!