I am in the process of migrating my Parse push notification data to CleverTap. The problem that I am having is that the documentation is not very good about it and the examples that they give don't cover push notifications.
Anyone have an example of how to send pushes with CleverTap API using Python or at least evidence that this is possible?
The documentation now covers how to migrate your Parse installations to CleverTap. For example, say we are creating a push notification to be sent to users subscribed to the "yankees" and "mets" channels.
curl -H "Content-Type:application/json"
-H "X-CleverTap-Account-ID: Your CleverTap Account ID"
-H "X-CleverTap-Passcode: Your CleverTap Account Passcode"
--data "#payload"
"https://api.clevertap.com/1/targets/create.json"
Payload
"name": "My API Campaign",
"where": {
"common_profile_prop": {
"profile_fields": [
{
"name": "channels",
"value": ["yankees", "mets"]
}
]
}
},
"content":{
"title": "Breaking News",
"body": "Yankees Win 5-4",
"platform_specific": {
"ios": {
"deep_link": "example.com",
"sound_file": "example.caf",
"category": "reactive",
"badge_count": 1,
"key": "value_ios"
},
"android": {
"background_image": "http://example.jpg",
"default_sound": true,
"deep_link": "example.com",
"key": "value_android"
}
}
},
"devices": [
"android",
"ios",
],
"when": "now"
}
Response
{
"status": "success",
"id": 1457433898,
"estimates": {
"android": 90,
"ios": 300
}
}
Hope this helps. More documentation can be found here -
https://github.com/CleverTap/parse-migrate
Related
I'm very new to development, I'm writing a Python Flask app which is executing a POST request to log a new ticket on a system, I just need someone to verify how I structure this request as I'm really not sure.
The documentation says, for example:
curl api/v3/requests
-X POST
-H "Accept: application/vnd.manageengine.sdp.v3+json"
-H "Authorization: Zoho-Oauthtoken 1000.7xxx98976ab0xxxxxx19901e7551be57.bxxxx921ed64c04f79622bebcfxxxxxx"
-H "Content-Type: application/x-www-form-urlencoded"
-d input_data= '{
"request": {
"subject": "Need an External Monitor",
"resolution": {
"add_to_linked_requests": false,
"content": "The following is the resolution to the above request"
}
}
It's expecting input_data key, followed by the JSON array of info to submit.
The documentation is (here)
My code:
#app.route("/log", methods=["GET"])
def log():
"""Fetching a protected resource using an OAuth 2 token.
"""
servicedesk = OAuth2Session(client_id, token=session['oauth_token'])
headers = {"Authorization": "Bearer " + token, "Accept": "application/vnd.manageengine.sdp.v3+json", "Content-Type": "application/x-www-form-urlencoded"}
data = {
"request": {
"subject": "New Incident",
"mode": {
"name": "E-Mail",
},
"group": {
"name": "Incident"
},
"requester": {
"name": "Sarah Curtis Test"
},
"status": {
"name": "Open",
},
"template": {
"name": "Report an Incident"
},
"request_type": {
"name": "Incident",
},
"description": "This is a test. please ignore",
"category": {
"name": "Incident"
}
}
}
requests.post('https://sdpondemand.manageengine.eu/api/v3/requests?input_data=', data=data, headers=headers)
I don't have access to logs on the server to see what it is receiving either as it's a cloud service (unless there's a way to echo back the original raw POST request?)
The ticket isn't being logged when I try and do so via my app. It does work through Postman app to test the API request, when I add the JSON above into the x-www-form-urlencoded section on the body tab and put input_data into the key.
I need to know how to structure the POST request in my code. Any help appreciated! Thanks
I'm working on an Alexa skill using the Alexa Skills Kit, and when the user says an invalid utterance, it replies with 'There was a problem with the requested skill's response'.
I've tried using the AMAZON.Fallback intent, but looking at the json output in the test window shows that it hasn't been triggered.
My backend is python 2.7 in Lambda and I'm using the locale en-gb (I've tried copying the interaction model into en-us but had the same results).
Is fallback intent the right thing to use to handle invalid utterances, or is there another way to achieve similar results?
Here is the Json input:
{
"version": "1.0",
"session": {
"new": false,
"sessionId": "amzn1.echo-api.session.bb6cd858-2128-44d2-8c43-ed6c501e0be4",
"application": {
"applicationId": "amzn1.ask.skill.0fbcbd10-17ee-49ea-9f7a-30401dc26a56"
},
"user": {
"userId": "amzn1.ask.account.AHL5Q4YLTSH3CHSILRWTE6FBK3XLKFE3XR6D6KY45IW6QVKJOW6ZWUAWMVS23YRY6EVWM45DKXPJSOXFP5AJ47TJTFD3JRHGEMUVAMKVZ4GGFJZ35JGAJV22RRDKP534OKVE46QPI32H5T6IJFHDVPP4TC3W6QXDJ2XPTYUL3U2MLQ2NYSG63UE2Q3MJZGJ7GEA5MIKSJCWUPEQ"
}
},
"context": {
"System": {
"application": {
"applicationId": "amzn1.ask.skill.0fbcbd10-17ee-49ea-9f7a-30401dc26a56"
},
"user": {
"userId": "amzn1.ask.account.AHL5Q4YLTSH3CHSILRWTE6FBK3XLKFE3XR6D6KY45IW6QVKJOW6ZWUAWMVS23YRY6EVWM45DKXPJSOXFP5AJ47TJTFD3JRHGEMUVAMKVZ4GGFJZ35JGAJV22RRDKP534OKVE46QPI32H5T6IJFHDVPP4TC3W6QXDJ2XPTYUL3U2MLQ2NYSG63UE2Q3MJZGJ7GEA5MIKSJCWUPEQ"
},
"device": {
"deviceId": "amzn1.ask.device.AGBUICDG5CR3PRTAM43NOEG3QDWUIIPF723CFMXHZILFXJY4CNAUNFVQGH33BL6VRU4DXG667KBEIE66XIO4ZW44DL2O67ALKIJDVV2YF7JPPAZAUZRGI2EHH34KVEHSPZRM3TMLPIAREL4LSTWFSI3MU2JA",
"supportedInterfaces": {}
},
"apiEndpoint": "https://api.eu.amazonalexa.com",
"apiAccessToken": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImtpZCI6IjEifQ.eyJhdWQiOiJodHRwczovL2FwaS5hbWF6b25hbGV4YS5jb20iLCJpc3MiOiJBbGV4YVNraWxsS2l0Iiwic3ViIjoiYW16bjEuYXNrLnNraWxsLjBmYmNiZDEwLTE3ZWUtNDllYS05ZjdhLTMwNDAxZGMyNmE1NiIsImV4cCI6MTU1MDU5Nzg5OCwiaWF0IjoxNTUwNTk3NTk4LCJuYmYiOjE1NTA1OTc1OTgsInByaXZhdGVDbGFpbXMiOnsiY29uc2VudFRva2VuIjpudWxsLCJkZXZpY2VJZCI6ImFtem4xLmFzay5kZXZpY2UuQUdCVUlDREc1Q1IzUFJUQU00M05PRUczUURXVUlJUEY3MjNDRk1YSFpJTEZYSlk0Q05BVU5GVlFHSDMzQkw2VlJVNERYRzY2N0tCRUlFNjZYSU80Wlc0NERMMk82N0FMS0lKRFZWMllGN0pQUEFaQVVaUkdJMkVISDM0S1ZFSFNQWlJNM1RNTFBJQVJFTDRMU1RXRlNJM01VMkpBIiwidXNlcklkIjoiYW16bjEuYXNrLmFjY291bnQuQUhMNVE0WUxUU0gzQ0hTSUxSV1RFNkZCSzNYTEtGRTNYUjZENktZNDVJVzZRVktKT1c2WldVQVdNVlMyM1lSWTZFVldNNDVES1hQSlNPWEZQNUFKNDdUSlRGRDNKUkhHRU1VVkFNS1ZaNEdHRkpaMzVKR0FKVjIyUlJES1A1MzRPS1ZFNDZRUEkzMkg1VDZJSkZIRFZQUDRUQzNXNlFYREoyWFBUWVVMM1UyTUxRMk5ZU0c2M1VFMlEzTUpaR0o3R0VBNU1JS1NKQ1dVUEVRIn19.d7N14qfFSfWL41vR6xkYpQFM_88giqltFbj_e1UTJLYR6amkifNnqX91uNqksGukWoGs6Jnync_wLG6WDddTKS2UOUJo2ZriUTN4xs7tM0hq_j-taezLV86d-J7Azq_sDWMDiuQs9pm-Y5kOU4x2HJbVqmkVj_xJHQQivM8_juK-hX_9FqDgYrnNmUz3erehtd7P_Euf9uiMXQgN5uF1NCwh0GscxnD_XPQ6b98I3hJnze-OHIFfEkla1THH180Op6O4Q47vlMHZWgl4cDQJneATUSOcHXOq8NnN9vfP_z2Q33g7n3BJmPvz-6vWsgbSrEajX-3xHs8rjIcdxvnc-w"
},
"Viewport": {
"experiences": [
{
"arcMinuteWidth": 246,
"arcMinuteHeight": 144,
"canRotate": false,
"canResize": false
}
],
"shape": "RECTANGLE",
"pixelWidth": 1024,
"pixelHeight": 600,
"dpi": 160,
"currentPixelWidth": 1024,
"currentPixelHeight": 600,
"touch": [
"SINGLE"
]
}
},
"request": {
"type": "SessionEndedRequest",
"requestId": "amzn1.echo-api.request.33d7948c-e4de-4ec9-9490-8e66c460d8f7",
"timestamp": "2019-02-19T17:33:18Z",
"locale": "en-GB",
"reason": "ERROR",
"error": {
"type": "INVALID_RESPONSE",
"message": "Invalid SSML Output Speech for requestId amzn1.echo-api.request.14165ddf-86dc-4cd2-b636-94df1ddfd835. Error: Fatal error occurred when processing SSML content. This usually happens when the SSML is not well formed. Error: Unexpected character 'T' (code 84) in prolog; expected '<'\n at [row,col {unknown-source}]: [1,1]"
}
}
}
If you're working with a skill that in English or German yes, you should use fallback intent. Other locales do not support it yet.
For en-GB or en-US you need to make sure that AMAZON.FallbackIntent is defined in your voice interaction model (front-end) and that you have an handler in the back-end (eg lambda) to catch intent requests named AMAZON.FallbackIntent
This definitely sound like a problem in your backen-end processiong the fallback intent (you might not be catching it properly)
I'm trying to make confirmation slack button while running slash command. e.g. I run slash-command (/test) it sends the POST request to my python app which sends back 2 buttons (Confirm, Cancel). User presses one of the buttons slack triggers an action and sends another POST request to my app. All is working fine before this step - I cannot handle the data from 2nd POST request correctly.
In the Slack documentation I found this:
When an action is invoked, a request will be sent to the app's Request URL as configured above; the request body will contain a payload parameter that your app should parse for JSON.
When I do
data=json.loads(request.form["payload"])
return jsonify(data)
I get
{
"action_ts": "XXXX",
"actions": [
{
"name": "confirm",
"type": "button",
"value": "confirm"
}
],
"attachment_id": "X",
"callback_id": "XXXX",
"channel": {
"id": "XXXX",
"name": "XXXX"
},
"is_app_unfurl": false,
"message_ts": "XXXX",
"response_url": "XXXX",
"team": {
"domain": "XXXX",
"id": "XXXX"
},
"token": "XXXX",
"trigger_id": "XXXX",
"type": "interactive_message",
"user": {
"id": "XXXX",
"name": "XXXX"
}
}
After when I call
data=json.loads(request.form["payload"])
action=data["actions"]
return jsonify(action)
I get
[
{
"name": "confirm",
"type": "button",
"value": "confirm"
}
]
Now when I'm trying to get value of "name" with action["name"] I receive the error
TypeError: list indices must be integers or slices, not str
I tried json.dumps(action) and json.dumps(action["name"]) neither of them worked.
How to read that values? I need to check value of name and then do the rest with it.
[
{
"name": "confirm",
"type": "button",
"value": "confirm"
}
]
is a list containing one element - the dictionary. Access the name like data["actions"][0]["name"]
I'm looking for a way to set service/status/loadBalance/ingress-ip after creating k8s service of type=loadbalancer (as appears in 'Type LoadBalancer' section at the next link https://kubernetes.io/docs/concepts/services-networking/service/ ).
My problem is similiar to the issue described in following link (Is it possible to update a kubernetes service 'External IP' while watching for the service? ) but couldn't find the answer.
Thanks in advance
There's two ways to do this. With a json patch or with a merge patch. Here's how you do the latter:
[centos#ost-controller ~]$ cat patch.json
{
"status": {
"loadBalancer": {
"ingress": [
{"ip": "8.3.2.1"}
]
}
}
}
Now, here you can see the for merge patches, you have to make a dictionary containing all the Object tree (begins at status) that will need some change to be merged. If you wanted to replace something, then you'd have to use the json patch strategy.
Once we have this file we send the request and if all goes well, we'll receive a response consisting on the object with the merge already applied:
[centos#ost-controller ~]$ curl --request PATCH --data "$(cat patch.json)" -H "Content-Type:application/merge-patch+json" http://localhost:8080/api/v1/namespaces/default/services/kubernetes/status{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "kubernetes",
"namespace": "default",
"selfLink": "/api/v1/namespaces/default/services/kubernetes/status",
"uid": "b8ece320-76c1-11e7-b468-fa163ea3fb09",
"resourceVersion": "2142242",
"creationTimestamp": "2017-08-01T14:00:06Z",
"labels": {
"component": "apiserver",
"provider": "kubernetes"
}
},
"spec": {
"ports": [
{
"name": "https",
"protocol": "TCP",
"port": 443,
"targetPort": 6443
}
],
"clusterIP": "10.0.0.129",
"type": "ClusterIP",
"sessionAffinity": "ClientIP"
},
"status": {
"loadBalancer": {
"ingress": [
{
"ip": "8.3.2.1"
}
]
}
}
This is my first time with paypal and I need some help to finish payment integration. I've already tried to contact the paypal support but with no success. Here is my question and I really hope to get some help.
Something very strange grinds my gears and I cannot find why this do that. It's about the user authorization, and specially about paypal json responses. I'm using python sdk but that doesn't matter in this case. Here is my input.
paypalrestsdk.configure({
'mode': 'sandbox',
'client_id': 'XXX',
'client_secret': 'XXX'
})
payment = paypalrestsdk.Payment({
"intent": "authorize",
"payer": {
"payment_method": "paypal"
},
"redirect_urls": {
"return_url": "http://mysite/success",
"cancel_url": "http://mysite/cancel"
},
"transactions": [ {
"amount": {
"total": price,
"currency": "USD"
},
"description": title
}]
})
And everything is ОК, except that I doesn't receive an Authorization ID. Here is what I receive as response:
{
'redirect_urls':{
'cancel_url':'http://glamfame.com:8000/cancel',
'return_url':'http://glamfame.com:8000/success'
},
'update_time':'2014-04-08T13:54:22Z',
'state':'created',
'transactions':[
{
'amount':{
'currency':'USD',
'total':'123.00',
'details':{
'subtotal':'123.00'
}
},
'description':'fawfwa',
'related_resources':[{
'authorization':{
'valid_until':'2014-05-07T13:54:22Z',
'update_time':'2014-04-08T13:54:22Z',
'parent_payment':'PAY-54Y91315F8620142DKNB77DQ',
'create_time':'2014-04-08T13:54:22Z',
'links':[{
'method':'GET',
[link removed]
'rel':'parent_payment'
}]
}
}]
}],
'payer':{
'payer_info':{
'shipping_address':{
}
},
'payment_method':'paypal'
},
'id':'PAY-54Y91315F8620142DKNB77DQ',
'intent':'authorize',
'create_time':'2014-04-08T13:54:22Z',
'links':[{ POST, GET, REDIRECT methods with links
}]
And below is what I supposed to receive according their documentation.
{
"id": "2DC87612EK520411B",
"create_time": "2013-06-25T21:39:15Z",
"update_time": "2013-06-25T21:39:17Z",
"state": "authorized",
"amount": {
"total": "7.47",
"currency": "USD",
"details": {
"subtotal": "7.47"
}
},
"parent_payment": "PAY-36246664YD343335CKHFA4AY",
"valid_until": "2013-07-24T21:39:15Z",
"links": [
{
"href": [link removed]
"rel": "self",
"method": "GET"
},
{
"href": [link removed]
"rel": "capture",
"method": "POST"
},
{
"href": [link removed]
"rel": "void",
"method": "POST"
},
{
"href": [link removed]
"rel": "parent_payment",
"method": "GET"
}]
}
As you maybe already noticed, in the paypal response doesn't contain authorization id and void, and capture link. Can you please help me to find out the reason for this. Thank you in advance.
Best Regards,
Georgi
From the REST API documentation: With PayPal payments authorizations, PayPal initially provides HATEOAS links that are specific to PayPal payments including an approval_url and execute link. First get payment approval and execute the payment as you normally would do for a PayPal payment. Once you successfully execute on the payment authorization, PayPal responds with a new set of HATEOAS links, including a capture link that you use to capture the payment.