Skip to content

Commit 8425ebc

Browse files
Merge pull request #156 from EvolutionAPI/revert-154-evolution-api-1.5.2-develop-francis
Revert "Start Typebot com opção de ativar chatbot ou não"
2 parents 99f3e77 + 6fc37a4 commit 8425ebc

File tree

1 file changed

+2
-42
lines changed

1 file changed

+2
-42
lines changed

src/whatsapp/services/typebot.service.ts

Lines changed: 2 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ export class TypebotService {
9999
const remoteJid = data.remoteJid;
100100
const url = data.url;
101101
const typebot = data.typebot;
102-
const enabled_typebot = data.enabled_typebot;
103102
const variables = data.variables;
104103
const findTypebot = await this.find(instance);
105104
const sessions = (findTypebot.sessions as Session[]) ?? [];
@@ -117,13 +116,8 @@ export class TypebotService {
117116
prefilledVariables[variable.name] = variable.value;
118117
});
119118

120-
if (enabled_typebot !== false ) {
121-
let enabled_typebot = true;
122-
123-
124-
const response = await this.createNewSession(instance, {
119+
const response = await this.createNewSession(instance, {
125120
url: url,
126-
enabled_typebot: enabled_typebot,
127121
typebot: typebot,
128122
remoteJid: remoteJid,
129123
expire: expire,
@@ -147,53 +141,18 @@ const response = await this.createNewSession(instance, {
147141
this.waMonitor.waInstances[instance.instanceName].sendDataWebhook(Events.TYPEBOT_START, {
148142
remoteJid: remoteJid,
149143
url: url,
150-
enabled_typebot: enabled_typebot,
151144
typebot: typebot,
152145
prefilledVariables: prefilledVariables,
153146
sessionId: `${response.sessionId}`,
154147
});
155148
} else {
156149
throw new Error("Session ID not found in response");
157150
}
158-
159-
} else {
160-
161-
const id = Math.floor(Math.random() * 10000000000).toString();
162-
163-
const reqData = {
164-
sessionId: id,
165-
startParams: {
166-
typebot: data.typebot,
167-
prefilledVariables: prefilledVariables,
168-
},
169-
};
170-
171-
const request = await axios.post(data.url + '/api/v1/sendMessage', reqData);
172-
173-
await this.sendWAMessage(
174-
instance,
175-
remoteJid,
176-
request.data.messages,
177-
request.data.input,
178-
request.data.clientSideActions,
179-
);
180-
181-
this.waMonitor.waInstances[instance.instanceName].sendDataWebhook(Events.TYPEBOT_START, {
182-
remoteJid: remoteJid,
183-
url: url,
184-
typebot: typebot,
185-
variables: variables,
186-
sessionId: id,
187-
});
188-
189-
190-
}
191151

192152
return {
193153
typebot: {
194154
...instance,
195155
typebot: {
196-
enabled_typebot: enabled_typebot,
197156
url: url,
198157
remoteJid: remoteJid,
199158
typebot: typebot,
@@ -545,6 +504,7 @@ const id = Math.floor(Math.random() * 10000000000).toString();
545504
sessions.splice(sessions.indexOf(session), 1);
546505

547506
const typebotData = {
507+
enabled: true,
548508
url: url,
549509
typebot: typebot,
550510
expire: expire,

0 commit comments

Comments
 (0)