AWS PinPoint - SMS Message From Postman - amazon-web-services

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!

Related

How to test StartChatContact API in Postman? | "Unable to determine service/operation name to be authorized"

I am trying to start AWS connect chat from a third-party application. I have implemented StartChatContact in Postman, which gives a participant token that is further used in CreateParticipantConnection.
StartChatContact
Body
{
"ContactFlowId": "cd1a0465-0a02229-4a1a-9894-fb14945548264",
"InstanceId": "84ece66549-184a-400f-babf-59888d7c8fd04",
"ParticipantDetails": {
"DisplayName": "Customer"
}
}
This is working fine and returns the participant token.
CreateParticipantConnection
Body
{
"ConnectParticipant": true,
"Type": [ "WebSocket" ]
}
When I placed the token in CreateParticipantConnection, it throws an error that is mentioned below:
Error
{
"message": "Unable to determine service/operation name to be authorized"
}
Kindly provide me your valuable guidance. I am following StartChatContact and CreateParticipantConnection documentations.
I haven't tested but I believe the type needs to be "WEBSOCKET" not "WebSocket" i.e. it is case sensitive.

Google my business not fetching reviews correctly

I'm currently using Google's api for fetching reviews of a Google My Business Account. We do this for our clients, which have to enable oauth for us, so we can have an access token and a refresh token.
The response we get, has the following structure:
url: https://mybusiness.googleapis.com/v4/accounts/{account_id}/locations/{location_id}/reviews
{
"reviews": [
{
"reviewId": "some-id,
"reviewer": {
"profilePhotoUrl": "some-url",
"displayName": "Some Sample Name"
},
"starRating": "FOUR",
"comment": "Some long comment left by the user.",
"createTime": "2021-02-15T14:35:19.252Z",
"updateTime": "2021-02-15T14:35:19.252Z",
"reviewReply": {
"comment": "Some long reply by the business.",
"updateTime": "2021-03-04T16:49:32.973Z"
},
"name": "accounts/{account_id}/locations/{location_id}/reviews/{review_id}"
},
...
],
"averageRating": 4.5,
"totalReviewCount": 1312,
"nextPageToken": "some-page-token"
}
The problem is, for some set of clients, we are getting just an empty object (literally, we are receiving {} as the response body). We are not sure why this is happening, since we are able to see reviews on the client's web site, and we are not getting any error. We've refreshed tokens and refreshed tokens without any success.
I've tried posting a support ticket with GCP in order to get some guidance, but it seems that you don't get any help in this kind of issues if you don't have the right support plan.
Anyhow, any help on this issue (why is happening? can it be fixed? is it a setup problem? etc.) is very much appreciated.

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)

AWS Pinpoint/Ionic - "Resource not found" error when trying to send push through CLI

I am new at programming with AWS services, so some fundamental things are pretty hard for me. Recently, I was asked to develop an app that used Amazon Pinpoint to send push notifications, as a test for considering future implementations.
As you can see in another question I posted in here (Amazon Pinpoint and Ionic - Push notifications not working when app is in background), I was having trouble trying to send push notifications to users when my app is running in the background. The app was developed using Ionic by following these steps.
When I was almost giving up, I decided to try sending the pushes directly through Firebase, and it finally worked. Some research took me to this question, in which another user described the problem as only happening in AWS Console, so the solution would be to use CLI. After searching a little about it, I found this tutorial about how to sending pinpoint messages to users using CLI, that seems to be what I wanted. Combining it with this documentation about phonegap plugin, I was able to generate a JSON I thought could be a solution:
{
"ApplicationId":"io.ionic.starter",
"MessageRequest":{
"Addresses": {
"": {
"BodyOverride": "",
"ChannelType": "GCM",
"Context": {
"": ""
},
"RawContent": "",
"Substitutions": {},
"TitleOverride": ""
}
},
"Context": {
"": ""
},
"Endpoints": {"us-east-1": {
"BodyOverride": "",
"Context": {},
"RawContent": "",
"Substitutions": {},
"TitleOverride": ""
}
},
"MessageConfiguration": {
"GCMMessage": {
"Action": "OPEN_APP",
"Body": "string",
"CollapseKey": "",
"Data": {
"": ""
},
"IconReference": "",
"ImageIconUrl": "",
"ImageUrl": "",
"Priority": "High",
"RawContent": "{\"data\":{\"title\":\"sometitle\",\"body\":\"somebody\",\"url\":\"insertyourlinkhere.com\"}}",
"RestrictedPackageName": "",
"SilentPush": false,
"SmallImageIconUrl": "",
"Sound": "string",
"Substitutions": {},
"TimeToLive": 123,
"Title": "",
"Url": ""
}
}
}
}
But when I executed it in cmd with aws pinpoint send-messages --color on --region us-east-1 --cli-input-json file://test.json, I got the response An error occurred (NotFoundException) when calling the SendMessages operation: Resource not found.
I believe I didn't write the JSON file correctly, since it's my first time doing this. So please, if any of you know what I am doing wrong, no mattering which step I misunderstood, I would appreciate the help!
"Endpoints" field in the Message request deals with the endpoint id (the identifier associated with an end user device while registering to pinpoint and not the region.)
In case if you haven't registered any endpoints with Pinpoint, you can use the "Addresses" field. After registering the GCM Channel in Amazon Pinpoint, you can get the GCM device token from your device and specify it here.
Here is a sample for sending direct messages using Amazon Pinpoint Note: The example deals with sending SMS message. You should have registered a SMS channel first and created an endpoint with the endpoint id as "test-endpoint1". Otherwise, you can use the "Addresses" field instead of "Endpoints" field.
aws pinpoint send-messages --application-id $APP_ID --message-request '{"MessageConfiguration": {"SMSMessage":{"Body":"hi hello"}},"Endpoints": {"test-endpoint1": {}}}
Also Note: ApplicationId is generated by Pinpoint. When you visit the Pinpoint console and choose your application, the URL will be of the format
https://console.aws.amazon.com/pinpoint/home/?region=us-east-1#/apps/someverybigstringhere/
Here "someverybigstringhere" is the ApplicationId and not the name you give for your project.

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);