Thingsboard Device Provisioning : How to create new devices in a specified device group via API? - provisioning

As I am going through the documentation regarding "Device Provision" & "Bulk Provision" in Thingsboard, I came to know that the devices can be provisioned via following API,
curl -v -X POST --header "Content-Type: application/json" --header "Accept: application/json" -d "{"deviceName":"*<name>*","provisionDeviceKey":"*<key>*","provisionDeviceSecret":"*<secret_key>*"}" "https://thingsboard.cloud/api/v1/provision"
The above command will create a new device under default device group ("All" device group).
How can we make this API to create a new device under specified Device Group with the help of "Device Group" entity id?
Please provide suggestions.
Thank you.

From what I gather based on the source code
https://github.com/thingsboard/thingsboard/blob/eb16527e4dc6017038c5f3dc93e04a953b19299a/dao/src/main/java/org/thingsboard/server/dao/device/DeviceServiceImpl.java#L518
It does not seem to be able to create a device within a device group.
What you can do is that you can create a device profile that has a rule chain that will automatically add to the device group on device creation.

Related

Using Slack, how do you send direct message to user based on their "Member ID?

How do you send a direct message to a user in Slack, using their unique "Member ID". Slack seems to only accept a Slack handle as an acceptable username.
I'm new to Slack and thanks in advance for the help (please let me know if this needs to be moved, etc.).
Assuming you meant user ID when you said "member ID", you can use that as channel parameter in chat.postMessage to send a direct message to that user.
Example for user with User ID U12345678:
curl -X POST "https://slack.com/api/chat.postMessage" -H "accept: application/json" -d token=TOKEN -d channel=U12345678 - d text=Hello

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.

How to get a listed of delivered emails in last three days in 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

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