How to get a listed of delivered emails in last three days in SparkPost? - sparkpost

It should be with message events API but I don't see a solution.
Could someone give me a hint?
Best regards,
Nedim

The suppression list is only a list of emails that are blocked from being sent to in the future. I would not use this as a method to detect delivery. Email addresses you send to that result in a hard bounce, spam complaint, link unsubscribe, or list unsubscribe are automatically added to your suppression list so you can't send to those emails again.
You can definitely use the message events API to get what you are looking for. You can filter the events shown by the delivery event type using the events parameter. You'll also want to supply the from parameter and set it to three days ago. Here's an example call using cURL:
curl -X GET -H "Accept: application/json" -H "Authorization: <your-api-key>" "https://api.sparkpost.com/api/v1/message-events?from=2016-06-07T00:00&events=delivery"
Documentation for the message events API can be found here:
https://developers.sparkpost.com/api/message-events#message-events-message-events-get
Additionally, there are endpoints for both documentation of all the fields returned as well as sample endpoints:
https://api.sparkpost.com/api/v1/message-events/events/samples?events=delivery
https://api.sparkpost.com/api/v1/message-events/events/documentation?events=delivery

Related

How to improve email robustness? [mailgun, laravel]

I planned to improve email robustness using below way. I am using laravel and mailgun. If any bounces email is in the mailgun then i want to send that to someone related to the email(not to that previous receiver and it related with previous sender or someone) so that i plan to use Task scheduler and schedule every hour this process. After that email send successfully i want to remove that email from mailgun.
I actually want to know how to implement get bounces email from mailgun and if send successfully using Task scheduler i want to remove that email from mailgun. if any sample's to achieve this? or any different ideas?
Normally when a bounce happens, providers such as Mailgun will retry a few times depending on the bounce status/type. After failing to send to that email address, Mailgun will put that address into your Bounces list to avoid sending to that address in the future. There's really no point in trying to send emails to an address which doesn't exist, inbox is full, domain expired, etc. So perhaps you should review your bounce list before you consider doing this. Mailgun's dashboard provides the description and date it happened. If you wish to send to a particular address again, you can remove the address from the bounce list. More about bounces here.
You can use mailgun-php or simply use Guzzle to call their API to retrieve your bounces. I'm not sure what you meant my removing email, but hope this helps.
Edit:
You can use their API to get all your bounces, and also the message content (retention depends on your plan or settings) if you need the original content. You could also use their webhooks to get the failed emails, so you don't really need to schedule/cron.
Edit 2:
The bounce list only stores email addresses of previously bounced emails. Also, I just realized that, if you're checking hourly for bounced messages, looks like the suppression/bounce API won't be of much help since you can't know if a message has failed for an address already on the list. This is the only data from bounce list:
{
"address": "alice#example.com",
"code": "550",
"error": "No such mailbox",
"created_at": "Fri, 21 Oct 2011 11:02:55 GMT"
},
So looks like you've to use the events API or webhooks to get the failed messages.
I've used mailgun-php sometime ago, and I found that the it wasn't easy working with Events on that library due to protected properties of the class. So if you have trouble, maybe just use Guzzle or use webhook approach instead.

How to message a user in a slack App via API?

When creating a slack app, it creates a new "channel" in the left hand menu. I want to be able to send a message to specific users and not to all users in a workspace who have integrated with the app.
For example, if I make the following request:
curl -X POST -H 'Content-type: application/json' --data '{"text":"Hello, World!"}' https://hooks.slack.com/services/ABxxx/CDxxx/EFxxxxxx
It will send a message to all users who have integrated with my app with the text "Hello World".
But I only want to send a message to user A without User B being notified.
I don't want to message a user directly and it to appear to come from slack bot. I want the message to appear to come from my bot / app.
How can this be achieved via slack API?
I found this quite hard to explain so please let me know if you'd like me to clarify anything.
The problem of your request that you are using a hook URL which is bound to a particular channel (you pick it during Slack App installation).
To send a direct message to the user on behalf of your bot, you need to consider the following things (this is not the single way to achieve it, but works for me):
Ensure you have a bot registered for your Slack App.
Ask for bot and chat:write:bot permissions during App installation process (example for Slack Install button and here).
Store the bot access token on successful installation (see for details).
Now using the bot access token you can send Slack API requests.
To achieve what you need, use chat.postMessage API method. channel argument can be user ID (e.g. U0G9QF9C6). By setting up as_user argument to true, your message will be always sent on behalf (name and icon) of your bot (seems for bot tokens it's always like this, but it's recommend it to specify it explicitly).
Hope it helps. Feel free to ask for details.

Square API: How does the payment notifications webhook work?

I recently inherited an app that uses the Webhooks from the Connect API. I'm looking through this:
https://docs.connect.squareup.com/api/connect/v1/#webhooks-overview
I have the webhook setup with what it says in the docs:
curl -X PUT -H "Authorization: Bearer PERSONAL_ACCESS_TOKEN" -H "Content-Type:
application/json" -d "[\"PAYMENT_UPDATED\"]"
https://connect.squareup.com/v1/LOCATION_ID/webhooks
I recently had an issue where I was receiving 2 requests for each PAYMENT_UPDATED event. I eventually found out that this was because 2 separate accounts had the webhook enabled. The two accounts were
1) a developer's account
2) the client's account
However, what I don't understand is how the developer's account was receiving notifications for the orders coming from the client's account?
Is it because it hooks up any orders placed in the location (which comes from the LOCATION_ID) and the webhook URL specified for the merchant (which is identified by the PERSONAL_ACCESS_TOKEN)? This works even if the merchant is not the owner of that location?
You probably have multiple applications connected to your account with the same notification URL, so you are getting notified twice. If you go to https://squareup.com/dashboard/apps/my-apps you can see the apps that are authoirzed for a given account and remove ones that you aren't using anymore.

List of possible events for use in Webhooks method

I would like to create a webhook using callfire's api on outbound calls when the "transfer digit" is pressed by the user.
The webhooks method is found here:
https://developers.callfire.com/docs.html#createWebhook
Is shows an example in the post payload like this:
curl -u username:password -H
"Content-Type:application/json" -X POST"
localhost:8080/callfire-api-v2/v2/webhooks"
-d '{"name":"API hook", "resource":"textCampaign", "events":["start", "stop"], "callback":"http://cool.site.xyz/webhook"}'
This example shows the events "start" and "stop" for a "textCampaign" . This is the only list of events I can find in the documentation.
I was hoping to find a list of events for each resource.
I would like to use a webhook to get call results for voice calls without having to poll for them.
It might look like this assuming these events and resources existed:
-d '{"name":"API hook", "resource":"voiceCampaign", "events":["finalCallResult"], "callback":"blah"}'
Is there a way that one infers the resources and specifically, the events that are available for webhooks?
currently API v2 for webhooks is in beta and doesn't have some statuses, events and other things.
I would recommend to use subscriptions in API v1.1 https://www.callfire.com/api-documentation/rest/version/1.1#!/subscription

Assigning User to Channel without Object_id

I am currently trying to develop a script for our backend (PHP) which sends push-notifications to a custom group of users using the REST API https://api.parse.com/1/push.
So far, it is working fine sending single push messages and I could probably loop through the list of users and send the push notifications 1by1.
However, this is obviously not a great idea reporting wise since they will show up as single notifications in Parse and hence it would be more difficult to see the open rate, etc.
My Idea would be to assign a unique Channel to the users which match the filters defined and sends the push to this channel.
I know that I can do this with the object_id using this:
https://parse.com/docs/rest#installations-updating
But the problem is that I only got the installationID or deviceToken (depending on Device) which I can not use to assign a channel.
It would be great if anybody knows a solution for this using the Data I got (installationID and deviceToken)
Thanks a lot
Marco, have a look into the object as, even though their docs don't specify it there is a method to retrieve objectId from the object and pass it to your PHP API.
On Android use:
ParseInstallation.getCurrentInstallation().getObjectId()
Nevertheless, if you cannot figure it out, you can always query the installations endpoint of Parse API
curl -X GET \
-H "X-Parse-Application-Id: <app-key>" \
-H "X-Parse-REST-API-Key: <api-key>" \
-G \
--data-urlencode 'where={"installationId":"sdfddf-344-dfdf-dffd-dffff"}' \
https://api.parse.com/1/installations
To use deviceToken, just edit the where clause.
For more info check their docs query installations and object querying

Resources