Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
node_crisp
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
web
node_crisp
Commits
8d10330c
Commit
8d10330c
authored
Nov 24, 2021
by
Gabriel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Actualiza Crisp a V5.0.1
parent
4a1e1763
Changes
5
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
81 additions
and
128 deletions
+81
-128
crisp.js
crisp.js
+12
-12
is.js
endpoints/is.js
+1
-1
index.js
index.js
+6
-6
package-lock.json
package-lock.json
+61
-108
package.json
package.json
+1
-1
No files found.
crisp.js
View file @
8d10330c
var
Crisp
=
require
(
"node-
crisp-api"
);
var
CrispClient
=
new
Crisp
();
const
Crisp
=
require
(
"
crisp-api"
);
const
CrispClient
=
new
Crisp
();
const
config
=
require
(
'config'
);
var
identifier
=
config
.
get
(
'credenciales.crisp.identifier'
);
var
key
=
config
.
get
(
'credenciales.crisp.key'
);
le
t
SIGUIENTE_PASO
=
'siguiente_paso'
;
const
identifier
=
config
.
get
(
'credenciales.crisp.identifier'
);
const
key
=
config
.
get
(
'credenciales.crisp.key'
);
cons
t
SIGUIENTE_PASO
=
'siguiente_paso'
;
const
DELAY_MS
=
1000
;
let
localData
=
{};
CrispClient
.
authenticate
(
identifier
,
key
);
CrispClient
.
authenticate
Tier
(
"plugin"
,
identifier
,
key
);
async
function
sendTextMessage
(
website_id
,
session_id
,
message
)
{
await
composeMessage
(
website_id
,
session_id
,
DELAY_MS
);
await
CrispClient
.
website
Conversations
.
sendMessage
(
await
CrispClient
.
website
.
sendMessageInConversation
(
website_id
,
session_id
,
{
type
:
"text"
,
...
...
@@ -25,14 +25,14 @@ async function sendTextMessage(website_id, session_id, message) {
}
async
function
composeMessage
(
website_id
,
session_id
,
ms
){
await
CrispClient
.
website
Conversations
.
composeMessage
(
await
CrispClient
.
website
.
composeMessageInConversation
(
website_id
,
session_id
,
{
"type"
:
"start"
,
"from"
:
"operator"
}
);
await
new
Promise
(
resolve
=>
setTimeout
(
resolve
,
ms
));
await
CrispClient
.
website
Conversations
.
composeMessage
(
await
CrispClient
.
website
.
composeMessageInConversation
(
website_id
,
session_id
,
{
"type"
:
"stop"
,
...
...
@@ -46,7 +46,7 @@ async function showWritingIcon(website_id, session_id){
async
function
sendPickerMessage
(
website_id
,
session_id
,
id
,
title
,
choices
)
{
await
composeMessage
(
website_id
,
session_id
,
DELAY_MS
);
await
CrispClient
.
website
Conversations
.
sendMessage
(
await
CrispClient
.
website
.
sendMessageInConversation
(
website_id
,
session_id
,
{
type
:
"picker"
,
...
...
@@ -84,7 +84,7 @@ async function getUserData(website_id, session_id) {
}
async
function
updateCrispData
(
website_id
,
session_id
,
correo
,
tipo_documento
,
numero_documento
,
fecha_nacimiento
,
sexo
)
{
await
CrispClient
.
website
Conversations
.
updateMeta
(
website_id
,
session_id
,
{
await
CrispClient
.
website
.
updateConversationMetas
(
website_id
,
session_id
,
{
email
:
correo
,
data
:
{
tipo_documento
:
tipo_documento
,
...
...
@@ -96,7 +96,7 @@ async function updateCrispData(website_id, session_id, correo, tipo_documento, n
}
async
function
getCrispData
(
website_id
,
session_id
)
{
return
await
CrispClient
.
website
Conversations
.
getMeta
(
website_id
,
session_id
);
return
await
CrispClient
.
website
.
getConversationMetas
(
website_id
,
session_id
);
}
async
function
updateUserData
(
website_id
,
session_id
,
data
)
{
...
...
endpoints/is.js
View file @
8d10330c
...
...
@@ -2,7 +2,7 @@ const config = require('config');
const
axios
=
require
(
'axios'
);
let
_
=
require
(
'lodash'
);
var
AUTH_TOKEN
=
config
.
get
(
'credenciales.isApiToken'
);
const
AUTH_TOKEN
=
config
.
get
(
'credenciales.isApiToken'
);
let
isClient
=
axios
.
create
({
baseURL
:
config
.
get
(
'isBaseUrl'
),
...
...
index.js
View file @
8d10330c
const
axios
=
require
(
'axios'
);
const
config
=
require
(
'config'
);
const
handlerTurnosProgramados
=
require
(
'./handlers/is_turnos_programados.js'
);
const
handlerTurnosBajoDemanda
=
require
(
'./handlers/ips_turnos_bajo_demanda'
);
const
crisp
=
require
(
'./crisp.js'
);
const
utils
=
require
(
'./utils.js'
);
const
pasosTurnosProgramados
=
require
(
'./handlers/pasos_is_turnos_programados.js'
);
const
pasosIpsTurnosBajoDemanda
=
require
(
'./handlers/pasos_ips_turnos_bajo_demanda'
);
const
is
=
require
(
'./endpoints/is.js'
);
const
sendinblue
=
require
(
'./endpoints/sendinblue.js'
);
const
WEBSITE_ID_IPS_TURNOS_BAJO_DEMANDA
=
config
.
get
(
'crispWebsiteIdIpsTurnosBajoDemanda'
);
const
WEBSITE_ID_TURNOS_PROGRAMADOS
=
config
.
get
(
'crispWebsiteIdIsTurnosProgramados'
);
crisp
.
CrispClient
.
userProfile
.
get
().
then
(
function
(
myProfile
)
{
console
.
log
(
`El chatbot esta escuchando eventos (profile name:
${
myProfile
.
first_name
}
)`
);
});
crisp
.
CrispClient
.
plugin
.
getConnectAccount
()
.
then
(
account
=>
{
console
.
log
(
'El chatbot esta escuchando eventos'
);
console
.
log
(
"Plugin ID:"
,
account
.
plugin_id
);
})
.
catch
(
error
=>
console
.
error
(
"Error al inicializar el chatbot: "
,
error
));
crisp
.
CrispClient
.
on
(
"message:updated"
,
async
function
(
message
)
{
darSiguientePaso
(
message
,
message
.
website_id
,
message
.
session_id
);
...
...
package-lock.json
View file @
8d10330c
This diff is collapsed.
Click to expand it.
package.json
View file @
8d10330c
...
...
@@ -14,7 +14,7 @@
"
axios
"
:
"
^0.21.1
"
,
"
config
"
:
"
^3.3.6
"
,
"
lodash
"
:
"
^4.17.21
"
,
"
node-crisp-api
"
:
"
^1.12.2
"
"
crisp-api
"
:
"
5.0.1
"
},
"devDependencies"
:
{
"
nodemon
"
:
"
^2.0.7
"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment