copyright | link | is |
---|---|---|
Copyright IBM Corp. 2017 |
listen-to-events-in-a-space |
published |
Using Outbound Webhooks, your App can provide an automated response to messages that members post in a space. For example, you could have an app that listens for a trigger word such as "weather" in the conversation and every time it records this event, it responds with a message in the conversation that displays the current weather. Basically, your app receives an HTTP POST from Watson Work Services when specific events occur in the space, such as the trigger word "weather", and then automatically responds.
To enable outbound Webhooks in your App you need to register your callback URL for IBM Watson Work Services.
A callback occurs in these two situations:
- Initially, when the callback is enabled to verify that the URL of the callback is under the control of the person who registered it. Note that during registration, the URL must be valid and resolve itself as a valid address. Additionally, the HTTPS certificate of the server that processes the URL is verified and stored. (see Preparing your App to run to learn how to code the verification function)
- And then, repeatedly for each event, for which the callback was added.
Each event must be acknowledged as being processed by returning an http status, such as 200, back to Watson Work Services
To register your callback URL follow these steps:
- Go to Your Apps in the top navigation of this site
- Select an app
- Choose Listen to Events from the App Dashboard.
- Click Add an outbound webhook.
- Add the callback URL and select one or more events.
- Click Save.
Available events are:
message-created: each time a new message is created in the space
message-deleted: each time a message is deleted from the space.
message_edited: each time a message is edited (EVENT is EXPERIMENTAL)
Please note that the triggering of message-edited events takes place due to a change in the data model via Administrator action, End User action or through an API call.
Since this is an EXPERIMENTAL
capability, complete information can be found in our GitHub repo, see Coming Next section for more info.
space-members-added: each time a member is added to the space
space-members-removed: each time a member is removed from the space
space-updated: each time the space is modified
space-deleted: on space deletion
message-annotation-added: each time an annotation is added to a message
message-annotation-edited: each time an annotation that is bound to a message is modified
message-annotation-removed: each time an annotation is removed from a message
reaction_added: each time a reaction is added to a message
reaction_removed: each time a reaction is removed from a message
Details about event notification requests are described in the Webhooks API Reference.
Note: It’s important that your App carries out the proper handshake sequence. To learn more, read Preparing your App to run.