You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Nov 13, 2024. It is now read-only.
Copy file name to clipboardExpand all lines: README.md
+90-2Lines changed: 90 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -28,12 +28,14 @@ To run this application you must obtain publish and subscribe keys from your Pub
28
28
29
29
1. Give your app a name, and select **Chat App** as the app type.
30
30
31
-
1. Select a region to store your user data (e.g. *Portland*).
32
-
33
31
1. Click **Create**.
34
32
35
33
1. Click your new app to open its settings, then click its keyset.
36
34
35
+
1. Enable the **Objects** feature. **Presence** and **PubNub Functions** should have been enabled when the keyset was created.
36
+
37
+
1. Select a region to store your user data (e.g. *US East*).
38
+
37
39
1. Locate the *Publish* and *Subscribe* keys. You'll need these keys to include in this project.
38
40
39
41
## Running the project
@@ -59,6 +61,92 @@ To run this application you must obtain publish and subscribe keys from your Pub
59
61
60
62
A web browser should automatically open [http://localhost:3000](http://localhost:3000), and you can explore your very own Team Chat app!
61
63
64
+
## Enable rich message features *(optional)*
65
+
66
+
### Gif Picker
67
+
68
+
To enable the gif picker, you need a GIPHY API key.
69
+
You can sign up for a (free) developer account and create a key from the [GIPHY developer dashboard](https://developers.giphy.com/dashboard/).
70
+
71
+
1. Create `.env` at the root of the project to hold your environment variables. This file will no be commited.
72
+
73
+
1. Copy the API key from the dashboard and add it to `.env`.
74
+
75
+
```dotenv
76
+
GIPHY_API_KEY=your-api-key
77
+
```
78
+
79
+
1. The variable needs to be exposed to the React app by adding another line.
80
+
81
+
```dotenv
82
+
REACT_APP_GIPHY_API_KEY=$GIPHY_API_KEY
83
+
```
84
+
85
+
86
+
1. Restart the dev server for the changes to take effect.
87
+
88
+
```bash
89
+
npm start
90
+
```
91
+
92
+
93
+
### Image Moderation
94
+
95
+
In addition to message moderation, AI powered moderation can be enabled to block innapropriate images.
96
+
97
+
You can sign up for a (free) account and API key from the [Sightengine dashboard](https://dashboard.sightengine.com/).
98
+
99
+
1. Add the **API User** and **API Secret** to your `.env` file.
100
+
101
+
```dotenv
102
+
FUNCTIONS_SIGHTENGINE_API_SECRET=your-api-secret
103
+
FUNCTIONS_SIGHTENGINE_API_USER=your-api-user
104
+
```
105
+
106
+
### /giphy command
107
+
108
+
The `/giphy ${message}`command shares a gif related to the message.
109
+
110
+
1. You should have created a GIPHY API key in the [Gif Picker](#gif-picker) section. Exposed it to the function by adding another variable that references it.
111
+
112
+
```dotenv
113
+
FUNCTIONS_GIPHY_API_KEY=$GIPHY_API_KEY
114
+
```
115
+
116
+
### Deploy Functions
117
+
118
+
Link previews, message moderation, and the `/giphy`command are powered by PubNub functions. To enable these features, you'll need to build and deploy the function code in `/server`.
119
+
120
+
#### Option 1: Automatic Upload
121
+
122
+
> Note: To manage functions from the CLI, you have to sign in to your PubNub account. This is currently not possible if you created your account with SSO.
123
+
124
+
1. Use the CLI to build and deploy the functions from source (in `server/src`).
125
+
126
+
```bash
127
+
npm run deploy:functions
128
+
```
129
+
130
+
1. Enter your PubNub account email and password (these will **not** be saved).
131
+
132
+
1. Select your app and keyset using the up/down arrows and return to submit.
133
+
134
+
#### Option 2: Manual Upload
135
+
136
+
1. From the PubNub dashboard, select the keyset your are using. Then, open the functions tab (on the left). Enter a module name and description, then click **Create New Module**.
137
+
138
+
1. Click **Create Function**, give it a name, set the event type to *Before Publish or Fire* and enter `*` for the channel pattern and click **Create**.
139
+
140
+
1. Use the CLI to build the functions from source (in `server/src`).
141
+
142
+
```bash
143
+
npm run build:functions
144
+
```
145
+
146
+
1. After running the build command, a minified and compiled version of the function is available is `server/build/transformPublishedMessages.js`. Copy the contents of the file into the functions editor and click **Save**.
147
+
148
+
1. Click **Start Module** from the top right to deploy your function.
149
+
62
150
## Documentation
63
151
64
152
We've included additional documentation and a detailed tutorial for building a chat app with React, Redux, and PubNub.
Team Chat comes with additional rich features like link previews, gifs, and content moderation.
8
+
These features required additional setup and free third party APIs.
9
+
10
+
## Gif Picker
11
+
12
+
To enable the gif picker, you need a GIPHY API key.
13
+
You can sign up for a (free) developer account and create a key from the [GIPHY developer dashboard](https://developers.giphy.com/dashboard/).
14
+
15
+
1. Create `.env` at the root of the project to hold your environment variables. This file will no be commited.
16
+
17
+
1. Copy the API key from the dashboard and add it to `.env`.
18
+
19
+
```dotenv
20
+
GIPHY_API_KEY=your-api-key
21
+
```
22
+
23
+
1. The variable needs to be exposed to the React app by adding another line.
24
+
25
+
```dotenv
26
+
REACT_APP_GIPHY_API_KEY=$GIPHY_API_KEY
27
+
```
28
+
29
+
30
+
1. Restart the dev server for the changes to take effect.
31
+
32
+
```bash
33
+
npm start
34
+
```
35
+
36
+
37
+
## Image Moderation
38
+
39
+
In addition to message moderation, AI powered moderation can be enabled to block innapropriate images.
40
+
41
+
You can sign up for a (free) account and API key from the [Sightengine dashboard](https://dashboard.sightengine.com/).
42
+
43
+
1. Add the **API User** and **API Secret** to your `.env` file.
44
+
45
+
```dotenv
46
+
FUNCTIONS_SIGHTENGINE_API_SECRET=your-api-secret
47
+
FUNCTIONS_SIGHTENGINE_API_USER=your-api-user
48
+
```
49
+
50
+
## /giphy command
51
+
52
+
The `/giphy ${message}` command shares a gif related to the message.
53
+
54
+
1. You should have created a GIPHY API key in the [Gif Picker](#gif-picker) section. Exposed it to the function by adding another variable that references it.
55
+
56
+
```dotenv
57
+
FUNCTIONS_GIPHY_API_KEY=$GIPHY_API_KEY
58
+
```
59
+
60
+
## Deploy Functions
61
+
62
+
Link previews, message moderation, and the `/giphy` command are powered by PubNub functions. To enable these features, you'll need to build and deploy the function code in `/server`.
63
+
64
+
### Option 1: Automatic Upload
65
+
66
+
> Note: To manage functions from the CLI, you have to sign in to your PubNub account. This is currently not possible if you created your account with SSO.
67
+
68
+
1. Use the CLI to build and deploy the functions from source (in `server/src`).
69
+
70
+
```bash
71
+
npm run deploy:functions
72
+
```
73
+
74
+
1. Enter your PubNub account email and password (these will **not** be saved).
75
+
76
+
1. Select your app and keyset using the up/down arrows and return to submit.
77
+
78
+
### Option 2: Manual Upload
79
+
80
+
1. From the PubNub dashboard, select the keyset your are using. Then, open the functions tab (on the left). Enter a module name and description, then click **Create New Module**.
81
+
82
+
1. Click **Create Function**, give it a name, set the event type to *Before Publish or Fire* and enter `*` for the channel pattern and click **Create**.
83
+
84
+
1. Use the CLI to build the functions from source (in `server/src`).
85
+
86
+
```bash
87
+
npm run build:functions
88
+
```
89
+
90
+
1. After running the build command, a minified and compiled version of the function is available is `server/build/transformPublishedMessages.js`. Copy the contents of the file into the functions editor and click **Save**.
91
+
92
+
1. Click **Start Module** from the top right to deploy your function.
0 commit comments