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
4558a4ff
Commit
4558a4ff
authored
Aug 30, 2021
by
Gabriel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Agrega delay entre mensajes
parent
4d68464c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
0 deletions
+19
-0
crisp.js
crisp.js
+19
-0
No files found.
crisp.js
View file @
4558a4ff
...
...
@@ -5,12 +5,14 @@ const config = require('config');
var
identifier
=
config
.
get
(
'credenciales.crisp.identifier'
);
var
key
=
config
.
get
(
'credenciales.crisp.key'
);
let
SIGUIENTE_PASO
=
'siguiente_paso'
;
const
DELAY_MS
=
1000
;
let
localData
=
{};
CrispClient
.
authenticate
(
identifier
,
key
);
async
function
sendTextMessage
(
website_id
,
session_id
,
message
)
{
await
composeMessage
(
website_id
,
session_id
,
DELAY_MS
);
await
CrispClient
.
websiteConversations
.
sendMessage
(
website_id
,
session_id
,
{
...
...
@@ -22,7 +24,24 @@ async function sendTextMessage(website_id, session_id, message) {
);
}
async
function
composeMessage
(
website_id
,
session_id
,
ms
){
await
CrispClient
.
websiteConversations
.
composeMessage
(
website_id
,
session_id
,
{
"type"
:
"start"
,
"from"
:
"operator"
}
);
await
new
Promise
(
resolve
=>
setTimeout
(
resolve
,
ms
));
await
CrispClient
.
websiteConversations
.
composeMessage
(
website_id
,
session_id
,
{
"type"
:
"stop"
,
"from"
:
"operator"
}
);
}
async
function
sendPickerMessage
(
website_id
,
session_id
,
id
,
title
,
choices
)
{
await
composeMessage
(
website_id
,
session_id
,
DELAY_MS
);
await
CrispClient
.
websiteConversations
.
sendMessage
(
website_id
,
session_id
,
{
...
...
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