---title: First steps with Chatslug: /guides/chat-first-stepssidebar_position: 0x-custom: ported_from_readme: true---Quickly implement a full-fledged chat into your web application.
### InstallationFirst, you need to obtain the [JavaScript SDK](/sdks/reference/browser-sdk/00-browser-sdk-reference.mdx) using one of these two methods. Using npm
If you are using npm, from your terminal you can run:shellnpm install @signalwire/jsThen, include the package in JavaScript as follows:jsimport * as SignalWire from @signalwire/js Using a CDN
You can import the library from a CDN into your HTML file: paste the following within the section of your page:htmlA global SignalWire variable will be available for use by JavaScript. ### Getting a tokenThe chat is organized in channels. To start receiving messages from a channel, you need an authentication token which grants you access to that channel. To get a demo token:jsconst res = await fetch(https://guides.swrooms.com/public/chat_token, { method: POST, headers: { accept: application/json, content-type: application/json, }, body: JSON.stringify({ member_id: my-unique-id, channels: { my-channel-name: { read: true, write: true } }, state: {} })});const reply = await res.json()// token is in reply.tokenMake sure to wrap the code into an async function to be able to use await.### Receiving messagesNow you can use the token to initialize a client and start receiving messages:jsconst chatClient = new SignalWire.Chat.Client({ token: reply.token});await chatClient.subscribe([my-channel-name]);chatClient.on(message, msg => { console.log(msg.member.id, says, msg.content)});### Sending messagesAfter you have initialized a client, you can use it for sending messages too. For example:jschatClient.publish({ channel: my-channel-name, content: Hello, world!});Next steps----------Congratulations! You have now created your own basic chat application.In this example, we made a POST request to an endpoint located at https://guides.swrooms.com/public/chat_token to obtain a token. While this works for demo purposes, it has some limitations:- Channels and users are shared across all applications using the same endpoint- Some APIs are limited- _swrooms.com_ is not supported for production applicationsHaving your own server will also allow you to access the following additional APIs and SDKs:- [REST APIs](pathname:///rest/): create and manage tokens- [Realtime SDK](/sdks/reference/realtime-sdk/00-realtime-sdk-reference.mdx): receive events from active chat rooms and control them server-side.To access these full capabilities, you should provide your own chat_token endpoint using your own server. Follow the guide to keep learning:[Get Started With a Simple Chat Demo ❯](/guides/get-started-with-a-simple-chat-demo)