I'm new to Discord and would like to know whether Discord provides APIs for the following purposes:
I would like to send a search keyword in the request and would like to receive in response all public servers / channels that are a match. (This is similar to the 'Explore Public Server' functionality available in the Discord web and desktop front-ends (but not on mobile devices)
The user goes through the search results and select one of the results. Now, I would like to send this server (server name or server Id) in the request and expect to get the list of public channels on this server.
The user then selects one of the public channels. Now I send the channel id in the request and expect to receive the messages along with their corresponding usernames and datetime they were posted in the channel.
I tried to refer to the API documentation but was unable to figure out. I plan to use Java API (JAX-RS) with Jersey.
Thanks,
Dicky
Related
I want to implement a connected OAuth app in Salesforce which should trigger push events in case some entities changed, for example an opportunity was closed.
Zapier implemented something similar
https://zapier.com/apps/salesforce/integrations/webhook
Could not find something I need which is a simple way to subscribe to entity changes using the OAuth client's token and passing a webhook endpoint. I read about apex callouts, streaming API and outbound messages.
Yeah, we solved this exact problem at Fusebit and I can help you understand the process as well.
Typically speaking here's what you need to do:
Create triggers on the Salesforce Objects you want to get updates for
Upload Apex class that will send an outgoing message to a pre-determined URL
Enable Remote Site Setting for the Domain you want to send the message to
Add in Secret Verification (or other auth method) to prevent spamming of your external URL
If you're leveraging javascript, then you can use the jsforce sdk & salesforce tooling API to push the code into the salesforce instance AFTER the Auth flow has occurred AND on Salesforce Instances that have API access enabled (typically - this is enterprise and above OR professional with API enabled).
This will be helpful for you to look through: https://jamesward.com/2014/06/30/create-webhooks-on-salesforce-com/
FYI - Zapier's webhooks implementation is actually polling every 15 minutes, instead of real-time incoming events.
In which programming language?
For consuming outbound messages you just need to be able to accept an XML message and send back "Ack" message to acknowledge receiving, otherwise SF will keep trying to resend it for 24h.
For consuming platform events / streaming API / Change Data Capture (CDC) you'll need to raise the event in SF (Platform Event you could raise from code, flow, process builder, CDC would happen automatically, you just tell it which objects it should track).
And then in client app you'd need to login to SF (SOAP or REST API), subscribe to channel (any library that supports cometd should be fine). Have you seen "EMP Connector", mentioned for example in https://trailhead.salesforce.com/en/content/learn/modules/change-data-capture/subscribe-to-events?trail_id=architect-solutions-with-the-right-api ?
Picking right messaging way is an art, there's free course that can help: https://trailhead.salesforce.com/en/content/learn/trails/architect-solutions-with-the-right-api
And pretty awesome PDF if you want to study for certification: https://resources.docs.salesforce.com/sfdc/pdf/integration_patterns_and_practices.pdf
I am developing a simple audio client for Watson assistant solutions and I am having problems authorizing the client.
I am following this guide https://watson-personal-assistant.github.io/developer/audio/audio_authentication/ but the Api Key I am using is not recognized.
The error message I get is the following:
"errorMessage": "Provided API key could not be found"
The Api Key I am using is the one displayed in the user's card (that appears when clicking the user's avatar in the top-right corner of the page).
In the console there is the Clients tab which states:
A client can be a device such as a smart speaker or wearable, but it could also be a mobile app or web-based chatbot. Use this page to create credentials for those clients and assign an entity to them.
I thought that an Api Key could be created here, but it is not.
The Watson Assistant Solutions Service is now using IAM API key instead of the API key for the MultiTenant Audio Gateway. This does pre-req that you have a An IBM Cloud ID account
To create your own IBM IAM API key use these directions https://console.bluemix.net/docs/iam/userid_keys.html#userapikey
You also need your tenant id you can find that in the WASol Console.
Your client will have to send the following properties
Server connection parameterss. For userID note to not include ( # # . or other special chars). There is an issue we are fixing.
host=wa-audio-gateway.mybluemix.net
userID=carlos.ferreira
IAM API Key is Used to authenticate the client device
IAMAPIKey=yourIAMAPIkey
Choosing which skill set to use (Required parameter)
skillset=industry
Your tenant ID (Required parameter)
tenantID=yourtenantID
Client language specific preferences can be passed (Optional parameter with a default value: en-US)
language=en-US
Choosing which STT and TTS engine to convert audio to text and text to audio - possible values are : watson, google , (Optional parameter with a default value : watson)
engine=google
Controls playback method. Playback using an audio URL in the response [true], playback by streaming audio from the server [false]
urltts=false
You can find a reference Java implementation for the Audio Gateway here. https://github.com/Watson-Personal-Assistant/AudioClientSampleCodeJava
Please note that you also need to use IBM APIKey for programmatic access to the WASol Core text routing service. Here is a code example I did to get Amazon Dot/Alexa skill to communicate with WASol Assistant skill set.
I created a working Google Channel AP and now I would like to send a message to all clients.
I have two servlets. The first creates the channel and tells the clients the userid and token. The second one is called by an http post and should send the message.
To send a message to a client, I use:
channelService.sendMessage(new ChannelMessage(channelUserId, "This is a server message!"));
This sends the message just to one client. How could I send this to all?
Have I to store every Id which I use to create a channel and send the message for every id? How could I pass the Ids to the second servlet?
Using Channel API it is not possible to create one channel and then having many subscribers to it. The server creates a unique channel for individual JavaScript clients, so if you have the same Client ID the messages will be received only by one.
If you want to send the same message to multiple clients, in short, you will have to keep a track of active clients and send the same message to all of them.
If that approach sounds scary and messy, consider using PubNub for your push notification messages, where you can easily create one channel and have many subscribers. To make it run on Google App Engine is not that hard, since they support almost any platform or device.
I know this is an old question, but I just finished an open source project that uses the Channel API to implement a publish/subscribe model, i.e. you can have multiple users subscribe to a single topic, and then all those subscribers will be notified when anyone publishes a message to the topic. It also has some nice features like automatic message persistence if desired, and "return receipts", where a subscriber can be notified whenever OTHER subscribers receive that message. See https://github.com/adevine/gaewebpubsub#gae-web-pubsub. Licensed under Apache 2.0 license.
In Google App Engine documentation for Channel API, it is stated that "Only one client at a time can connect to a channel using a given Client ID".
In contradiction, when I try to create a channel with the same Client ID, a new channel is consumed. In other words, when I call creat channel api for ClientID "user_one" channelService.createChannel("user_one"); for ten times, 10 different channels with 10 different token strings would be created, and when I send a message to "user_one" channelService.sendMessage(new ChannelMessage("user_one", message));, all of the ten clients on different devices, would receive the message!
How would you describe this scenario ? How one can benefit from this mechanism (one clientID with different channel, all receiving same message)? how to prevent it from creating multiple channel for single user ?
The documentation is not complete but it describes its intent pretty well. It says:
Only one client at a time can connect to a channel using a given Client ID, so an application cannot use a Client ID for fan-out. In other words, it's not possible to create a central Client ID for connections to multiple clients (For example, you can't create a Client ID for something like a "global-high-scores" channel and use it to broadcast to multiple game clients.)
It's up to you to keep track of the of the number of channels you create for each ClientID. From my experience, what you describe works, but not reliably. The newest channel created with the ClientID works, the older ones, sometimes work, sometimes don't receive messages.
Note that if you're trying this out on the dev_appserver, all the clients receive messages, but on the real server this behavior is not the same.
I created an application that has ~50 users.
I am trying to use channel API but I've run into a problem while testing with message send.
I am saving the token into the database so i can use the same token if an user opens multiple tabs with the same interface and i have a servlet that resets my token when it expires.
It works fine until I redeploy my application or change the version of my app. I stop receiving messages. If I try to open a channel with the old app version token it doesn't throw an error or anything, it opens it but I still don't receive messages on that channel.
If I reset my token it works OK again.
Does anyone know of a solution to this bug, or has anyone had it before? I deploy often while people are working so I can't ignore it.
My best guess is that ChannelServiceFactory.getChannelService() returns a different instance of ChannelService so when I call channelService.sendMessage("id","message"); it sends it to a different channel.
I can't explain why stored tokens wouldn't work on re-deploying your app (they should), but I can explain why they don't work when you change versions. Briefly, tokens are specific to an app version.
First, the reason for this: we want to ensure that applications that send different data or change message formats or whatever in different versions don't send messages across version boundaries. In the same way that you don't want your javascript bundle from v1 rendering against servlets on v2, you wouldn't want v1 your javascript message handlers receiving messages from v2 servlets (or vice versa).
So, to hopefully make it clear what's going on:
A channel is identified by a combination of your appid, your app version, and the clientid that you provide when you call createChannel or sendMessage. The implementation of the Channel API doesn't store any mapping of appid/clientid -> token. To greatly simplify, you can think of createChannel as doing something like this:
public String createChannel(clientid) {
// obviously we don't really just append strings to each other for actual implementation.
return encryptStringSomehow(clientid + globalAppInfo.version + globalAppInfo.appid);
}
and sendMessage is like this:
public void sendMessage(clientid, message) {
// identify the JID used for this channel.
JID xmppJid = new JID(mutateString(clientid + globalAppInfo.version + globalAppInfo.appid),
CHANNEL_XMPP_DOMAIN); // some domain used for channel messages
// send the <message> stanza to that jid with the application message as the body
xmppService.sendMessage(xmppJid, encodeSomehow(message));
}
and on the client side, the servlet responsible for the channel decrypts the token and binds to the endpoint identified by a JID created by the same method as the sendMessage function.
The upshot is that tokens are only valid for messages sent from the same version of the app that created them.