It is possible edit simple slack message after it is sent? - postman

I have url of type https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX to which i send data (using postman for testing) like this:
{
"blocks": [
{
"type": "section",
"block_id": "section_id_123",
"text": {
"type": "mrkdwn",
"text": "hello world"
}
}
]
}
Is it possible to edit this "hello world" text, after the message is sent, via same url?

The link you are using to post the message is 'Incoming Webhook'
Incoming webhooks are one-way messaging and does not allow edit or deletes.
https://api.slack.com/messaging/webhooks#posting_with_webhooks

Related

How can I create a bot in Amazon Lex for getting weather update?

I am trying to get weather update. The Python code is working well but I am unable to embed it into Amazon Lex. It is showing received error response.
from botocore.vendored import requests
# using openweathermap api
api_address = 'http://api.openweathermap.org/data/2.5/weather?appid=__api_key_here__&q='
city = input("Enter city >> ")
url = api_address + city
json_data = requests.get(url).json()
formatted_data = json_data['weather'][0]['main']
desc_data = json_data['weather'][0]['description']
print(formatted_data)
print(desc_data)
# print(json_data)
Make sure api is running perfectly python code.
Depends on the next state you need to keep type as ElicitSlot or ElicitInten
If you are using lambda as backend for the lex, we need send the response in a below format.
You can refer the link for the Lambda response formats
Lambda response formats
{
"dialogAction": {
"type": "Close",
"fulfillmentState": "Fulfilled",
"message": {
"contentType": "PlainText",
"content": "Thanks, your pizza has been ordered."
},
"responseCard": {
"version": integer-value,
"contentType": "application/vnd.amazonaws.card.generic",
"genericAttachments": [
{
"title":"card-title",
"subTitle":"card-sub-title",
"imageUrl":"URL of the image to be shown",
"attachmentLinkUrl":"URL of the attachment to be associated with the card",
"buttons":[
{
"text":"button-text",
"value":"Value sent to server on button click"
}
]
}
]
}
}
}

AWS PinPoint - SMS Message From Postman

I'm trying to initiate a SMS message using Postman, but I keep getting a response indicating "Invalid Request Body". I can't seem to find a good example on the AWS documentation (Is it just me or does anyone else encounter this with AWS?)
Below is the request body I'm submitting with my request. Any help would be much appreciated!
{
"ApplicationId": "<MyApplicationID>",
"MessageRequest": {
"Addresses": {
"[{{Destination}}]": {
"BodyOverride": "Test",
"ChannelType": "SMS"
}
},
"MessageConfiguration": {
"SMSMessage": {
"Body": "Test",
"SenderId": "Test",
"MessageType": "TRANSACTIONAL",
"Keyword": "<MyKeyword>",
"OriginationNumber": "<Origination number in E.164 Format>"
}
}
}
}
Looking at the Amazon Pinpoint SendMessages REST API, the request body doesn't include either the application-id key or MessageRequest key.
Resolution:
You will need to put the Amazon Pinpoint application-id in the URI part (or create an environmental variable) and then specify the request body as shown below :
Hope this helps!

Clickatell - WhatsApp Template - One API

I try to send a WhatsApp template message using the Clickatell One API end point.
Here is my payload. I'm send this against the endpoint with POST.
{
"messages":[
{
"to":"***********",
"channel": "whatsapp",
"hsm" : {
"template":"welcome_notification_demo",
"parameters" : {
"1":"John",
"2":" Clickatell"
}
}
}
]
}
I receive the following response from them:
{
"messages": [
{
"error": {
"code": 23,
"description": "Invalid or missing parameter: HSM ."
},
"accepted": false,
"to": "*********"
}
],
"error": null
}
Can anyone tell me what I am missing in my payload?
(The documentation is not at all useful.)
Note: I used ********** to hide my phone number.
Thanks!
From the support team:
"The cause of the error is that you are attempting to send a Default Whatsapp Template from a verified Whatsapp Business Number. Please retest by using one of your approved custom templates and advise us if the issue continues."
So I tried with one of our custom templates and it worked!
(Would be nice if the documentation mentioned that you can't test with a default template)

How to display response messege as response card in Amazon aws lex?

I have created a simple chatbot with the following flow.
Bot: do you want to buy a book?
Human: yes
Bot: what kind of book are you interested? (Response card)
-drama
-crime
-action
Human: drama (on click or typing)
Bot: Here is list of available drama movies in store(response card)
- Django
- first man
-true story
The last part is problem , I can't figure out how I can achieve that.
Can some one please help me what do I need to do to get what I want? Similar demo or tutorial Will be appreciated.
Here you need to add a response card using your Lambda code because the values are dynamic (available movies).
Here is the example code of adding response card:
"dialogAction": {
"type": "Close",
"fulfillmentState": "Fulfilled or Failed",
"message": {
"contentType": "PlainText or SSML",
"content": "Message to convey to the user. For example, Thanks, your pizza has been ordered."
},
"responseCard": {
"version": "1",
"contentType": "application/vnd.amazonaws.card.generic",
"genericAttachments": [
{
"title":"card-title",
"subTitle":"card-sub-title",
"imageUrl":"URL of the image to be shown",
"attachmentLinkUrl":"URL of the attachment to be associated with the card",
"buttons":[
{
"text":"button-text",
"value":"Value sent to server on button click"
}
]
}
]
}
}
This is an example of adding response card in a fulfimmnet message, you can add this in elicit_slot as well. Play around it and let us know if you have any confusion.
Hope it helps.

Obtaining error while using amazon lex "Invalid Lambda Response: Received invalid response from Lambda"

I'm trying to develop a chatbot using AWS Lex. But unfortunately, I'm getting an error while building the chat on Lex. I'm using one intent and 2 slots. For some reason, when the lambda function is connected to the chat, the second value of the slot is saved as null. But when I run it in lambda as a test case, it's successful.
Right now, all I want to do is show a response message after the details of the slot is entered.
This is my code
public class LexBot implements RequestHandler<Map<String, Object>, Object> {
#Override
public Object handleRequest(Map<String, Object> input, Context context) {
// LexRequest lexRequest = LexRequestFactory.createLexRequest(input);
String content = "Request came from the bot: ";
Message message = new Message("PlainText", content);
DialogAction dialogAction = new DialogAction("Close", "Fullfiled", message);
return new LexRespond(dialogAction);
}
}
And this is the error I'm getting in AWS Lex:
An error has occurred: Invalid Lambda Response: Received invalid
response from Lambda: Can not construct instance of Message, problem:
content must not be blank at [Source:
{"dialogAction":{"type":"Close","message":{"contentType":"PlainText","some_respond_message":"Request
came from the bot: "}}}; line: 1, column: 122]
If you are using amazon lexv2, then amazon lex expecting a different JSON response compared to lexv1.
Sample lambda response which is accpeted by lex:
{
"sessionState": {
"dialogAction": {
"type": "Close"
},
"intent": {
"confirmationState": "Confirmed",
"name": "SearchProducts",
"state": "Fulfilled",
},
},
"messages": [
{
"contentType": "PlainText",
"content": "Select from the list",
}
]
}
Check here for the full response structure https://docs.aws.amazon.com/lexv2/latest/dg/lambda.html
According to the docs, below is the correct format for constructing the final response:
{
"sessionAttributes": session_attributes,
"dialogAction":{
"type":"Close",
"fulfillmentState":"Fulfilled",
"message":{
"contentType":"PlainText",
"content":message
}
}
}
Use this format for constructing the response to avoid the error.
You spelled "fulfilled" incorrectly - you typed "Fullfiled" as pasted in below:
DialogAction dialogAction = new DialogAction("Close", "Fullfiled", message);