forked from wassengerhq/whatsapp-chatgpt-bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.js
207 lines (170 loc) · 9.25 KB
/
config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
const { env } = process
// Default message when the user sends an unknown message.
const unknownCommandMessage = `I'm sorry, I can only understand text. Can you please describe your query?
If you would like to chat with a human, just reply with *human*.`
// Default welcome message. Change it as you need.
const welcomeMessage = `Hey there 👋 Welcome to this ChatGPT-powered AI chatbot demo using *Wassenger API*! I can also speak many languages 😁`
// AI bot instructions to adjust its bevarior. Change it as you need.
// Use concise and clear instructions.
const botInstructions = `You are a smart virtual customer support assistant who works for Wassenger.
You can identify yourself as Molly, the Wassenger chatbot assistant.
You will be chatting with random customers who may contact you with general queries about the product.
Wassenger is a cloud solution that offers WhatsApp API and multi-user live communication services designed for businesses and developers.
Wassenger also enables customers to automate WhatsApp communication and build chatbots.
You are an expert customer support agent.
Be polite. Be gentle. Be helpful. Be emphatic. Be concise in your responses.
Politely reject any queries that are not related to customer support or Wassenger itself.
Strictly stick to your role as customer support virtual assistant for Wassenger.
If you can't help with something, ask the user to type *human* in order to talk with customer support.`
// Default help message. Change it as you need.
const defaultMessage = `Don't be shy 😁 try asking anything to the AI chatbot, using natural language!
Example queries:
1️⃣ Explain me what is Wassenger
2️⃣ Can I use Wassenger to send automatic messages?
3️⃣ Can I schedule messages using Wassenger?
4️⃣ Is there a free trial available?
Type *human* to talk with a person. The chat will be assigned to an available member of the team.
Give it a try! 😁`
// Optional. AI callable functions to be interpreted by the AI
// Using it you can instruct the AI to inform you to execute arbitrary functions
// in your code based in order to augment information for a specific user query.
// For example, you can call an external CRM in order to retrieve, save or validate
// specific information about the customer, such as email, phone number, user ID, etc.
// Learn more here: https://platform.openai.com/docs/guides/gpt/function-calling
const openaiFunctions = [
{
name: 'getPlanPrices',
description: 'Get available plans and prices information available in Wassenger',
parameters: { type: 'object', properties: {} }
}
]
// Optional. Edit as needed to cover your business use cases.
// Note the method property name for every function must be equal the openaiFunctions[].name property.
// Collection of callable function calls used to generate the response to feed the AI model
// and generate a domain-specific response to the user.
// Functions may be synchronous or asynchronous.
// Learn more here: https://platform.openai.com/docs/guides/gpt/function-calling
const functions = {
async getPlanPrices ({ response, data, device, messages }) {
const message = [
'*Gateway plans: Send only messages + API*',
'',
'- Gateway Professional: up to 10,000 outbound messages',
'- Gateway Business: up to 30,000 outbound messages',
'- Gateway Enterprise: unlimited outbound messages',
'',
'*Platform plans: Send & Receive messages + API + Webhooks + Live Team Chat + CRM + Analytics*',
'',
'- Platform Professional: up to 30,000 outbound + unlimited inbound messages',
'- Platform Business: up to 60,000 outbound + unlimited inbound messages',
'- Platform Enterprise: unlimited: unlimited outbound + inbound messages',
'',
'Each plan is limited to one WhatsApp number. You can purchase multiple plans for multiple numbers.',
'',
'*Find more information about the different plan prices and features here:*',
'https://wassenger.com/#pricing'
].join('\n')
return message
}
}
// Chatbot config
export default {
// Optional. Specify the Wassenger device ID (24 characters hexadecimal length) to be used for the chatbot
// If no device is defined, the first connected device will be used
// Obtain the device ID in the Wassenger app: https://app.wassenger.com/number
device: env.DEVICE || 'ENTER WHATSAPP DEVICE ID',
// Required. Specify the Wassenger API key to be used
// You can obtain it here: https://app.wassenger.com/apikeys
apiKey: env.API_KEY || 'ENTER API KEY HERE',
// Required. Specify the OpenAI API key to be used
// You can sign up for free here: https://platform.openai.com/signup
// Obtain your API key here: https://platform.openai.com/account/api-keys
openaiKey: env.OPENAI_API_KEY || '',
// Required. Set the OpenAI model to use.
// You can use a pre-existing model or create your fine-tuned model.
// Default model (fastest and cheapest): gpt-3.5-turbo-0125
// Newest model: gpt-4-1106-preview
// For customized fine-tuned models, see: https://platform.openai.com/docs/guides/fine-tuning
openaiModel: env.OPENAI_MODEL || 'gpt-3.5-turbo-0125',
// Optional. AI callable functions to be interpreted by the AI
// Using it you can instruct the AI to inform you to execute arbitrary functions
// in your code based in order to augment information for a specific user query.
// For example, you can call an external CRM in order to retrieve, save or validate
// specific information about the customer, such as email, phone number, user ID, etc.
// Learn more here: https://platform.openai.com/docs/guides/gpt/function-calling
openaiFunctions,
// Optional. Edit as needed to cover your business use cases.
// Note the method property name for every function must be equal the openaiFunctions[].name property.
// Collection of callable function calls used to generate the response to feed the AI model
// and generate a domain-specific response to the user.
// Functions may be synchronous or asynchronous.
// Learn more here: https://platform.openai.com/docs/guides/gpt/function-calling
functions,
// Optional. HTTP server TCP port to be used. Defaults to 8080
port: +env.PORT || 8080,
// Optional. Use NODE_ENV=production to run the chatbot in production mode
production: env.NODE_ENV === 'production',
// Optional. Specify the webhook public URL to be used for receiving webhook events
// If no webhook is specified, the chatbot will autoamtically create an Ngrok tunnel
// and register it as the webhook URL.
// IMPORTANT: in order to use Ngrok tunnels, you need to sign up for free, see the option below.
webhookUrl: env.WEBHOOK_URL,
// Ngrok tunnel authentication token.
// Required if webhook URL is not provided.
// sign up for free and get one: https://ngrok.com/signup
// Learn how to obtain the auth token: https://ngrok.com/docs/agent/#authtokens
ngrokToken: env.NGROK_TOKEN,
// Optional. Full path to the ngrok binary.
ngrokPath: env.NGROK_PATH,
// Set one or multiple labels on chatbot-managed chats
setLabelsOnBotChats: ['bot'],
// Remove labels when the chat is assigned to a person
removeLabelsAfterAssignment: true,
// Set one or multiple labels on chatbot-managed chats
setLabelsOnUserAssignment: ['from-bot'],
// Optional. Set a list of labels that will tell the chatbot to skip it
skipChatWithLabels: ['no-bot'],
// Optional. Ignore processing messages sent by one of the following numbers
// Important: the phone number must be in E164 format with no spaces or symbols
numbersBlacklist: ['1234567890'],
// Optional. Only process messages one of the the given phone numbers
// Important: the phone number must be in E164 format with no spaces or symbols
numbersWhitelist: [],
// Skip chats that were archived in WhatsApp
skipArchivedChats: true,
// If true, when the user requests to chat with a human, the bot will assign
// the chat to a random available team member.
// You can specify which members are eligible to be assigned using the `teamWhitelist`
// and which should be ignored using `teamBlacklist`
enableMemberChatAssignment: true,
// If true, chats assigned by the bot will be only assigned to team members that are
// currently available and online (not unavailable or offline)
assignOnlyToOnlineMembers: false,
// Optional. Skip specific user roles from being automatically assigned by the chat bot
// Available roles are: 'admin', 'supervisor', 'agent'
skipTeamRolesFromAssignment: ['admin'], // 'supervisor', 'agent'
// Enter the team member IDs (24 characters length) that can be eligible to be assigned
// If the array is empty, all team members except the one listed in `skipMembersForAssignment`
// will be eligible for automatic assignment
teamWhitelist: [],
// Optional. Enter the team member IDs (24 characters length) that should never be automatically assigned chats to
teamBlacklist: [],
// Optional. Set metadata entries on bot-assigned chats
setMetadataOnBotChats: [
{
key: 'bot_start',
value: () => new Date().toISOString()
}
],
// Optional. Set metadata entries when a chat is assigned to a team member
setMetadataOnAssignment: [
{
key: 'bot_stop',
value: () => new Date().toISOString()
}
],
defaultMessage,
botInstructions,
welcomeMessage,
unknownCommandMessage,
}