Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: tutorial for WebSockets with AsyncAPI #2245

Merged
merged 32 commits into from
Feb 7, 2024

Conversation

VaishnaviNandakumar
Copy link
Collaborator

Description
Initial draft for a WebSocket tutorial with AsyncAPI.

  • ...
  • ...
  • ...

Related issue(s)

@netlify
Copy link

netlify bot commented Oct 18, 2023

Deploy Preview for asyncapi-website ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit d305437
🔍 Latest deploy log https://app.netlify.com/sites/asyncapi-website/deploys/65c2e4e253bd3a0008ac56d9
😎 Deploy Preview https://deploy-preview-2245--asyncapi-website.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Welcome to AsyncAPI. Thanks a lot for creating your first pull request. Please check out our contributors guide useful for opening a pull request.
Keep in mind there are also other channels you can use to interact with AsyncAPI community. For more details check out this issue.

@VaishnaviNandakumar VaishnaviNandakumar changed the title Initial draft Docs: Tutorial for WebSockets with AsyncAPI Oct 25, 2023
And that brings us to what the `payload` attribute does. It specifies the name, format, and description of all expected properties, and can even set constant values that must be followed during schema validation.
For example, in `reactionPayload` schema definition, any API message received from this channel must follow the constant value for the "reaction" property which is clearly defined as “heart”.

The const value feature ensures that the data exchanged through your API complies with your specified constants, helping to maintain data integrity and accuracy.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The const value feature ensures that the data exchanged through your API complies with your specified constants, helping to maintain data integrity and accuracy.
The `const` value feature ensures that the data exchanged through your API complies with your specified constants, helping to maintain data integrity and accuracy.

## Define Operations and Channels
The `operation` property, is all about defining specific tasks your application can perform. Essentially, it's how my-slack-bot interacts with Slack.

In this example, the `helloListenerOperation` keeps an eye out for the message sent by the Slack server when a WebSocket connection is successfully established. On the other hand, the `reactionListener` is focused on the reaction_added event type.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
In this example, the `helloListenerOperation` keeps an eye out for the message sent by the Slack server when a WebSocket connection is successfully established. On the other hand, the `reactionListener` is focused on the reaction_added event type.
In this example, the `helloListenerOperation` keeps an eye out for the message sent by the Slack server when a WebSocket connection is successfully established. On the other hand, the `reactionListenerOperation ` is focused on the `reaction_added` event type.


Your Slack application is designed to be notified of events within your workspace. It does this by subscribing to a specific event type making use of Slack's Event API. So in this case the `action` property in both the operations is set to receive events.

Now, moving on to the `channels` section. The `address` specifies where the channel is tuned in to receive messages while the `messages` property defines the structure of the event it's set up to handle.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be first in this section, channels are first, operations later. This way first you can just change only channels in the yaml example, and later when you talk about operations, you show both, to make references visible

Copy link
Contributor

@Arya-Gupta Arya-Gupta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that it should be Slackbot and not SlackBot in the title.

In Slack, WebSocket is employed as part of its [Socket Mode](https://api.slack.com/apis/connections/socket) feature to facilitate real-time notifications between Slack's servers and third-party applications or bots. The [Slack Event API](https://api.slack.com/apis/connections/events-api) is a tool that lets you receive real-time notifications of specific events in a Slack workspace such as messages, reactions, and user presence changes.


## Define AsyncAPI Version, API Information, and Server
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
## Define AsyncAPI Version, API Information, and Server
## Define AsyncAPI version, API information, and server

We observe sentence capitalization for headers, let's make sure to fix them all :)

Copy link
Member

@KhudaDad414 KhudaDad414 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some comment.

Comment on lines 49 to 54
sequenceDiagram
Client -->> Server: Initiate WebSocket Connection
Server -->> Client: WebSocket Response
Server -->> Client: WebSocket Response
Server -->> Client: WebSocket Response
Server -->> Client: WebSocket Response
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not only the server but client can sends a message in any instance of time. I would remove Response keyword since there is no Request or Response in websocket.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well, there is a response, but not always, so yeah, can be must a message

servers:
production:
host: wss://wss-primary.slack.com
pathname: /link/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
pathname: /link/
pathname: /link

@derberg derberg changed the title docs: Tutorial for WebSockets with AsyncAPI docs: tutorial for WebSockets with AsyncAPI Jan 9, 2024
derberg
derberg previously approved these changes Jan 10, 2024
Copy link
Member

@derberg derberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@VaishnaviNandakumar great work 👏🏼 I made one suggestion - you do what you think is the best

@alequetzalli on to you, no need for me to have another look

pages/docs/tutorials/websocket/index.md Outdated Show resolved Hide resolved
Copy link
Member

@quetzalliwrites quetzalliwrites left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@quetzalliwrites
Copy link
Member

/rtm

@asyncapi-bot asyncapi-bot merged commit 64915b2 into asyncapi:master Feb 7, 2024
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants