Commit 4558a4ff authored by Gabriel's avatar Gabriel

Agrega delay entre mensajes

parent 4d68464c
......@@ -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, {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment