diff --git a/public/assets/examples/contactsOnBot.png b/public/assets/examples/contactsOnBot.png
new file mode 100644
index 0000000..ec260ed
Binary files /dev/null and b/public/assets/examples/contactsOnBot.png differ
diff --git a/public/assets/examples/deleteBotMessage1.png b/public/assets/examples/deleteBotMessage1.png
new file mode 100644
index 0000000..0d7962d
Binary files /dev/null and b/public/assets/examples/deleteBotMessage1.png differ
diff --git a/public/assets/examples/deleteBotMessage2.png b/public/assets/examples/deleteBotMessage2.png
new file mode 100644
index 0000000..3be372a
Binary files /dev/null and b/public/assets/examples/deleteBotMessage2.png differ
diff --git a/public/assets/examples/imageProfile.png b/public/assets/examples/imageProfile.png
new file mode 100644
index 0000000..25237ab
Binary files /dev/null and b/public/assets/examples/imageProfile.png differ
diff --git a/public/assets/examples/status.png b/public/assets/examples/status.png
new file mode 100644
index 0000000..eb87663
Binary files /dev/null and b/public/assets/examples/status.png differ
diff --git a/src/pages/en/databases/index.mdx b/src/pages/en/databases/index.mdx
index 9cd883d..052c4cd 100755
--- a/src/pages/en/databases/index.mdx
+++ b/src/pages/en/databases/index.mdx
@@ -249,6 +249,20 @@ main()
[PostgreSQL](https://www.postgresql.org/) database, celebrated for its reliability and cutting-edge features, presents formidable data storage solutions for bot-generated responses. Seamless integration with PostgreSQL entails specifying vital parameters such as `host`, `user`, `password`, `database` name, and `port`. This database variant guarantees data integrity and scalability, rendering it optimal for applications requiring top-tier data storage and retrieval performance.
+
+### Uses Cases
+
+If you want connect your bot to cloud database like Supabase or any CloudProvider you can use it.
+
+
+
+
+
PostgreSQL's flexible architecture and endorsement of advanced data types empower developers to craft sophisticated bots endowed with extensive functionality. Leveraging PostgreSQL equips developers with potent querying capabilities, transactional support, and comprehensive data management features, fostering the creation of resilient and efficient bot systems.
diff --git a/src/pages/en/databases/postgres/uses-cases/index.mdx b/src/pages/en/databases/postgres/uses-cases/index.mdx
new file mode 100644
index 0000000..59e5b12
--- /dev/null
+++ b/src/pages/en/databases/postgres/uses-cases/index.mdx
@@ -0,0 +1,21 @@
+import { Contributors } from '@/components/Contributors'
+import { Resources } from '@/components/Resources'
+import { Guides } from '@/components/Guides'
+
+export const description =
+ 'In this guide, we will discuss what to do to connecting another database.'
+
+# Supabase Uses Cases
+
+
+
+
+Connect to your Cloud Supabase database
+
+
+
diff --git a/src/pages/en/databases/postgres/uses-cases/uses-cases-supabase.mdx b/src/pages/en/databases/postgres/uses-cases/uses-cases-supabase.mdx
new file mode 100644
index 0000000..4655cbd
--- /dev/null
+++ b/src/pages/en/databases/postgres/uses-cases/uses-cases-supabase.mdx
@@ -0,0 +1,45 @@
+import { Contributors } from '@/components/Contributors'
+import { Resources } from '@/components/Resources'
+import { Guides } from '@/components/Guides'
+
+export const description =
+ 'In this guide, we will discuss what to do to connecting another database.'
+
+# Getting Starter
+
+
+
+
+
+
+Postgres database supports other types of connections as in this case it is Supabase, let's take a quick tour on the Supabase platform to get our database credentials
+
+The first thing is to create your account if you don't have one yet [Supabase](https://supabase.com/dashboard/sign-in?returnTo=%2Fsign-in) account.
+Log in with your Github user
+
+
+
+The second thing is to create an organization which is the one that allows you to create projects, this part is intuitive, create one then the other
+The database will ask you for a strong key, copy it and save it in a safe place, you will need it later for the connection :)
+
+
+
+Once we have our database ready, the next thing is to go to the project configuration section
+
+
+
+when clicking on database we will see all our configuration, you must copy each one do not forget that the key is the same when creating the project
+
+
+
+at the end you should be able to configure your database as follows
+
+
+
+
+----
+
+
+
+
+
diff --git a/src/pages/en/methods/index.mdx b/src/pages/en/methods/index.mdx
index 1bed463..ef4eb89 100644
--- a/src/pages/en/methods/index.mdx
+++ b/src/pages/en/methods/index.mdx
@@ -261,7 +261,7 @@ flowchart LR
## State/GlobalState Options {{ not:'true' }}
-Both methods such as state and global estate contain similar options and funcinalides, which depending on the use case can be very useful.
+Both methods such as state and global state contain similar options and funcinalides, which depending on the use case can be very useful.
## Clear {{ not:'true' }}
diff --git a/src/pages/en/providers/baileys/presence-update.mdx b/src/pages/en/providers/baileys/delete-bot-message.mdx
similarity index 53%
rename from src/pages/en/providers/baileys/presence-update.mdx
rename to src/pages/en/providers/baileys/delete-bot-message.mdx
index d88671e..39a4734 100644
--- a/src/pages/en/providers/baileys/presence-update.mdx
+++ b/src/pages/en/providers/baileys/delete-bot-message.mdx
@@ -3,27 +3,19 @@ import { Resources } from '@/components/Resources'
import { Guides } from '@/components/Guides'
-# Presence Update
-
-This method lets the person/group with id know whether you're online, offline, typing etc.
-
-
-```
-(property) sendPresenceUpdate: (type: WAPresence, toJid?: string) => Promise
-```
-
-WAPresence can be one of the following:
+# Delete Bot Message
+We can use the sendMessage method to delete a message sent by the bot. This method has the following signature:
```
-type WAPresence = 'unavailable' | 'available' | 'composing' | 'recording' | 'paused'
+(property) sendMessage: (jid: string, content: AnyMessageContent, options?: MiscMessageGenerationOptions) => Promise
```
```ts {{ title: 'app.ts' }}
import { createBot, createProvider, createFlow, addKeyword, EVENTS } from '@builderbot/bot'
-import { MemoryDB as Database } from '@builderbot/bot'
import { BaileysProvider as Provider } from '@builderbot/provider-baileys'
+import { MemoryDB as Database } from '@builderbot/bot'
import { config } from 'dotenv'
config()
@@ -38,15 +30,15 @@ const waitT = (ms: number) => {
}
const welcomeFlow = addKeyword(EVENTS.WELCOME)
- .addAnswer(`💡 Example *Sending Presence Update*`)
+ .addAnswer(`💡 Example delete Message`)
.addAction(
async (ctx, { provider, flowDynamic }) => {
- await flowDynamic('This is an example of presence update')
- await provider.vendor.sendPresenceUpdate('recording', ctx.key.remoteJid)
- await waitT(5000)
- await provider.vendor.sendPresenceUpdate('composing', ctx.key.remoteJid)
+ const number = ctx.key.remoteJid
+ await provider.vendor.sendMessage(number, { text: `Next message is going to be deleted in 5 seconds.\n\n*${Date()}*` })
+ const msg = await provider.vendor.sendMessage(number, { text: `This is the message to be deleted!!! ` })
await waitT(5000)
- await flowDynamic('Great!')
+ await provider.vendor.sendMessage(number, { delete: msg.key })
+ await flowDynamic(`*${Date()}*\n\nMessage has been deleted!`)
}
)
@@ -61,15 +53,15 @@ const main = async () => {
database: adapterDB,
}
)
-
}
main()
-
```
-
+
+
+
---
diff --git a/src/pages/en/providers/baileys/delete-on-bot.mdx b/src/pages/en/providers/baileys/delete-on-bot.mdx
new file mode 100644
index 0000000..de54a2f
--- /dev/null
+++ b/src/pages/en/providers/baileys/delete-on-bot.mdx
@@ -0,0 +1,106 @@
+import { Contributors } from '@/components/Contributors'
+import { Resources } from '@/components/Resources'
+import { Guides } from '@/components/Guides'
+
+
+# Contacts on BOT
+
+From the adapterProvider, we can utilize the store property to fetch all contacts, store them in a variable, and subsequently display them to the user. This property has the following signature:
+
+```
+(property) BaileysProvider.store?: {
+ chats: KeyedDB;
+ contacts: {
+ [_: string]: Contact;
+ };
+ messages: {
+ [_: string]: {
+ array: proto.IWebMessageInfo[];
+ get: (id: string) => proto.IWebMessageInfo;
+ ... 7 more ...;
+ fromJSON: (newItems: proto.IWebMessageInfo[]) => void;
+ };
+ };
+ ... 18 more ...;
+ readFromFile: (path: string) => void;
+}
+```
+Contact structure:
+```
+Contact {
+ id: string;
+ lid?: string;
+ name?: string;
+ notify?: string;
+ verifiedName?: string;
+ imgUrl?: string | null | 'changed';
+ status?: string;
+}
+```
+
+
+
+```ts {{ title: 'app.ts' }}
+import { createBot, createProvider, createFlow, addKeyword, EVENTS } from '@builderbot/bot'
+import { BaileysProvider as Provider } from '@builderbot/provider-baileys'
+import { MemoryDB as Database } from '@builderbot/bot'
+import { config } from 'dotenv'
+config()
+
+const PHONE_NUMBER = process.env.PHONE_NUMBER
+let contacts = {}
+
+const welcomeFlow = addKeyword(EVENTS.WELCOME)
+ .addAnswer(`💡 Example *Contacts on BOT*`)
+ .addAction(
+ async (_, { flowDynamic }) => {
+ const contactsBot = Object.entries(contacts)
+ .map(([id, data]) => ({ id, name: data }))
+ await flowDynamic(`Total contacts: ${contactsBot.length}`)
+ const messages: string[] = []
+ for (const grupo of contactsBot) {
+ const message = `${grupo.name ? 'Object:' : ''} ${JSON.stringify(grupo?.name, null, 5) || ''}\n*id:* ${grupo.id}`
+ messages.push(message);
+ }
+ const concatenatedMessages = messages.join('\n\n')
+ await flowDynamic(concatenatedMessages);
+ }
+ )
+
+const main = async () => {
+ const adapterFlow = createFlow([welcomeFlow])
+
+ const adapterProvider = createProvider(Provider, { usePairingCode: true, phoneNumber: PHONE_NUMBER })
+ const adapterDB = new Database()
+
+ const { handleCtx, httpServer } = await createBot(
+ {
+ flow: adapterFlow,
+ provider: adapterProvider,
+ database: adapterDB,
+ }
+ )
+
+ try {
+ adapterProvider.on("ready", () => {
+ if (adapterProvider.store && adapterProvider.store.contacts) {
+ contacts = adapterProvider.store.contacts
+ }
+ })
+ } catch (error) {
+ console.log(error)
+ }
+}
+
+main()
+
+```
+
+
+
+
+---
+
+
+
+
diff --git a/src/pages/en/providers/baileys/number-onwhatsapp.mdx b/src/pages/en/providers/baileys/fetchStatus.mdx
similarity index 51%
rename from src/pages/en/providers/baileys/number-onwhatsapp.mdx
rename to src/pages/en/providers/baileys/fetchStatus.mdx
index cb351aa..ef2f6c5 100644
--- a/src/pages/en/providers/baileys/number-onwhatsapp.mdx
+++ b/src/pages/en/providers/baileys/fetchStatus.mdx
@@ -3,49 +3,42 @@ import { Resources } from '@/components/Resources'
import { Guides } from '@/components/Guides'
-# Number on Whatsapp
-
-To check if an entered number exists on WhatsApp, you use the 'onWhatsApp' method of the provider. This method has the following signature:
+# Fetch Status
+ This method has the following signature:
```
-onWhatsApp: (...jids: string[]) => Promise<{
- exists: boolean;
- jid: string;
-}[]>
+(property) fetchStatus: (jid: string) => Promise<{
+ status: string;
+ setAt: Date;
+}>
```
-This method accepts one or more phone numbers (JIDs) as arguments and returns a promise that resolves to an array of objects containing
-the existence status (exists) and JID (jid) for each number.
-
```ts {{ title: 'app.ts' }}
import { createBot, createProvider, createFlow, addKeyword, EVENTS } from '@builderbot/bot'
-import { MemoryDB as Database } from '@builderbot/bot'
import { BaileysProvider as Provider } from '@builderbot/provider-baileys'
+import { MemoryDB as Database } from '@builderbot/bot'
import { config } from 'dotenv'
config()
const PHONE_NUMBER = process.env.PHONE_NUMBER
const welcomeFlow = addKeyword(EVENTS.WELCOME)
- .addAnswer(`💡 Example *Number Exist on Whatsapp*`)
- .addAnswer(
- '*Enter the number to check:*',
+ .addAnswer(`💡 Example *Whatsapp Status*`)
+ .addAction(
+ async (_, { provider, flowDynamic }) => {
+ const statusInfo = await provider.vendor.fetchStatus(PHONE_NUMBER + '@s.whatsapp.net')
+ console.log(statusInfo)
+ await flowDynamic(`*Status Info for ${PHONE_NUMBER}*:\n\nStatus: *${statusInfo.status}*\nSet At: ${statusInfo.setAt}`)
+ await flowDynamic(`Enter phone number to check status:`)
+ }
+ )
+ .addAction(
{ capture: true },
async (ctx, { provider, flowDynamic }) => {
- const checkNumber = ctx.body
- try {
- const onWhats = await provider.vendor.onWhatsApp(checkNumber)
- if (onWhats[0]?.exists) {
- await flowDynamic([`*Exists:* ${onWhats[0].exists}\n*JID:* ${onWhats[0].jid}`, `*Object:* ${JSON.stringify(onWhats, null, 6)}`])
- }
- else {
- await flowDynamic(`The number *${checkNumber}* does not exists on Whatsapp.`)
- }
- } catch (error) {
- await flowDynamic(`*Error:* ${error}`);
- }
+ const statusR = await provider.vendor.fetchStatus(ctx.body + '@s.whatsapp.net')
+ await flowDynamic(`*Status for:* ${ctx.body}\n\nStatus: *${statusR.status}*\nSet At: ${statusR.setAt}`)
}
)
@@ -63,11 +56,10 @@ const main = async () => {
}
main()
-
```
+
-
---
diff --git a/src/pages/en/providers/baileys/index.mdx b/src/pages/en/providers/baileys/index.mdx
index 78ce530..c494d00 100644
--- a/src/pages/en/providers/baileys/index.mdx
+++ b/src/pages/en/providers/baileys/index.mdx
@@ -22,7 +22,7 @@ The [Baileys](https://whiskeysockets.github.io/Baileys/) library originated as a
---
-## QR Code
+### QR Code
Link device QR Code In the code below you can see the standard way to link a device by scanning the QR code with the whatsapp application.
```ts {{title:'app.ts'}}
@@ -52,7 +52,7 @@ main()
---
-## Pairing code
+### Pairing code
Link device pairing code, In the code below you can see the alternative way to link the whatsapp account through a pairing code.
```ts {{title:'app.ts'}}
@@ -79,15 +79,318 @@ const main = async () => {
}
main()
+```
+
+---
+
+## Profile Picture
+
+The method profilePictureUrl allows us to retrieve the profile picture of a given number.
+This method has the following signature:
+
+```
+(property) profilePictureUrl: (jid: string, type?: "image" | "preview", timeoutMs?: number) => Promise
+```
+
+
+
+```ts {{ title: 'app.ts' }}
+import { createBot, createProvider, createFlow, addKeyword, EVENTS } from '@builderbot/bot'
+import { BaileysProvider as Provider } from '@builderbot/provider-baileys'
+import { MemoryDB as Database } from '@builderbot/bot'
+import { config } from 'dotenv'
+config()
+
+const PHONE_NUMBER = process.env.PHONE_NUMBER
+
+const welcomeFlow = addKeyword(EVENTS.WELCOME)
+ .addAnswer(`💡 Example *profile Picture*`)
+ .addAnswer(
+ 'Enter number to check image profile: ', { capture: true },
+ async (ctx, { provider, flowDynamic, fallBack, endFlow }) => {
+ const check = ctx.body + '@s.whatsapp.net'
+ try {
+ const imageProfile = await provider.vendor.profilePictureUrl(check.replace(/\+/g, ''), 'image', 10000)
+ await flowDynamic([
+ {
+ body: '*Profile Picture:*',
+ media: imageProfile
+ }
+ ])
+ return endFlow('End.')
+ } catch (error) {
+ await flowDynamic(`Error: ${error.message}`)
+ return fallBack('Try it again.')
+ }
+
+ }
+ )
+
+const main = async () => {
+ const adapterFlow = createFlow([welcomeFlow])
+ const adapterProvider = createProvider(Provider, { usePairingCode: true, phoneNumber: PHONE_NUMBER })
+ const adapterDB = new Database()
+ const botResult = await createBot(
+ {
+ flow: adapterFlow,
+ provider: adapterProvider,
+ database: adapterDB,
+ }
+ )
+}
+
+main()
+```
+
+
+
+---
+
+## Modifying Chats
+
+The chatModify method provides various options to modify a chat, including:
+* Archive a chat
+* Mute/unmute a chat
+* Mark a chat read/unread
+* Delete a message for me
+* Delete a chat
+* Pin/unpin a chat
+* Star/unstar a message
+
+This method has the following signature:
+
+```
+(property) chatModify: (mod: ChatModification, jid: string) => Promise
+```
+
+Delete a message for me when the received message does not comply with my business logic rules. (Develop your own logic rules)
+
+
+
+```ts {{ title: 'app.ts' }}
+import { createBot, createProvider, createFlow, addKeyword, EVENTS } from '@builderbot/bot'
+import { BaileysProvider as Provider } from '@builderbot/provider-baileys'
+import { MemoryDB as Database } from '@builderbot/bot'
+import { config } from 'dotenv'
+config()
+
+const PHONE_NUMBER = process.env.PHONE_NUMBER
+
+const badWords = ['fuck', 'ass hole', 'motherfucker']
+
+const waitT = (ms: number) => {
+ return new Promise((resolve) => {
+ setTimeout(() => {
+ resolve(ms);
+ }, ms)
+ })
+}
+
+const welcomeFlow = addKeyword(EVENTS.WELCOME)
+ .addAnswer(`💡 Example *Delete User Message:*`)
+ .addAction(
+ async (ctx, { provider, flowDynamic }) => {
+ const resp = ctx.body.toLocaleLowerCase()
+ const containsBadWord = badWords.some(word => resp.includes(word))
+ const id = ctx.key.id
+ const fromMe = ctx.key.fromMe
+ const timeStamp = ctx.messageTimestamp
+ if (containsBadWord) {
+ await flowDynamic('Your message is going to be deleted as you are sending inappropriate language.')
+ await waitT(3500)
+ try {
+ await provider.vendor.chatModify(
+ { clear: { messages: [{ id: id, fromMe: fromMe, timestamp: timeStamp }] } },
+ ctx.key.remoteJid
+ )
+ await flowDynamic(`Message deleted successfully.`)
+ } catch (error) {
+ await flowDynamic(`Error: ${JSON.stringify(error, null, 3)}`)
+ }
+ }
+ await flowDynamic('Welcome!')
+ }
+ )
+
+const main = async () => {
+ const adapterFlow = createFlow([welcomeFlow])
+ const adapterProvider = createProvider(Provider, { usePairingCode: true, phoneNumber: PHONE_NUMBER })
+ const adapterDB = new Database()
+ const botResult = await createBot(
+ {
+ flow: adapterFlow,
+ provider: adapterProvider,
+ database: adapterDB,
+ }
+ )
+}
+
+main()
+```
+
+
+
+---
+
+## Send Presence Update
+
+The method sendPresenceUpdate lets the person/group with id know whether you're online, offline, typing etc.
+This method has the following signature:
```
+(property) sendPresenceUpdate: (type: WAPresence, toJid?: string) => Promise
+```
+
+WAPresence can be one of the following:
+
+```
+type WAPresence = 'unavailable' | 'available' | 'composing' | 'recording' | 'paused'
+```
+
+
+
+```ts {{ title: 'app.ts' }}
+import { createBot, createProvider, createFlow, addKeyword, EVENTS } from '@builderbot/bot'
+import { MemoryDB as Database } from '@builderbot/bot'
+import { BaileysProvider as Provider } from '@builderbot/provider-baileys'
+import { config } from 'dotenv'
+config()
+
+const PHONE_NUMBER = process.env.PHONE_NUMBER
+
+const waitT = (ms: number) => {
+ return new Promise((resolve) => {
+ setTimeout(() => {
+ resolve(ms)
+ }, ms)
+ })
+}
+
+const welcomeFlow = addKeyword(EVENTS.WELCOME)
+ .addAnswer(`💡 Example *Sending Presence Update*`)
+ .addAction(
+ async (ctx, { provider, flowDynamic }) => {
+ await flowDynamic('This is an example of presence update')
+ await provider.vendor.sendPresenceUpdate('recording', ctx.key.remoteJid)
+ await waitT(5000)
+ await provider.vendor.sendPresenceUpdate('composing', ctx.key.remoteJid)
+ await waitT(5000)
+ await flowDynamic('Great!')
+ }
+ )
+
+const main = async () => {
+ const adapterFlow = createFlow([welcomeFlow])
+ const adapterProvider = createProvider(Provider, { usePairingCode: true, phoneNumber: PHONE_NUMBER })
+ const adapterDB = new Database()
+ const botResult = await createBot(
+ {
+ flow: adapterFlow,
+ provider: adapterProvider,
+ database: adapterDB,
+ }
+ )
+
+}
+
+main()
+
+```
+
+
+
+---
+
+
+## Number Exists on WhatsApp
+
+To check if an entered number exists on WhatsApp, you use the onWhatsApp method of the provider.
+This method has the following signature:
+
+```
+onWhatsApp: (...jids: string[]) => Promise<{
+ exists: boolean;
+ jid: string;
+}[]>
+```
+
+This method accepts one or more phone numbers (JIDs) as arguments and returns a promise that resolves to an array of objects containing
+the existence status (exists) and JID (jid) for each number.
+
+
+
+```ts {{ title: 'app.ts' }}
+import { createBot, createProvider, createFlow, addKeyword, EVENTS } from '@builderbot/bot'
+import { MemoryDB as Database } from '@builderbot/bot'
+import { BaileysProvider as Provider } from '@builderbot/provider-baileys'
+import { config } from 'dotenv'
+config()
+
+const PHONE_NUMBER = process.env.PHONE_NUMBER
+
+const welcomeFlow = addKeyword(EVENTS.WELCOME)
+ .addAnswer(`💡 Example *Number Exist on Whatsapp*`)
+ .addAnswer(
+ '*Enter the number to check:*',
+ { capture: true },
+ async (ctx, { provider, flowDynamic }) => {
+ const checkNumber = ctx.body
+ try {
+ const onWhats = await provider.vendor.onWhatsApp(checkNumber)
+ if (onWhats[0]?.exists) {
+ await flowDynamic([`*Exists:* ${onWhats[0].exists}\n*JID:* ${onWhats[0].jid}`, `*Object:* ${JSON.stringify(onWhats, null, 6)}`])
+ }
+ else {
+ await flowDynamic(`The number *${checkNumber}* does not exists on Whatsapp.`)
+ }
+ } catch (error) {
+ await flowDynamic(`*Error:* ${error}`);
+ }
+ }
+ )
+
+const main = async () => {
+ const adapterFlow = createFlow([welcomeFlow])
+ const adapterProvider = createProvider(Provider, { usePairingCode: true, phoneNumber: PHONE_NUMBER })
+ const adapterDB = new Database()
+ const botResult = await createBot(
+ {
+ flow: adapterFlow,
+ provider: adapterProvider,
+ database: adapterDB,
+ }
+ )
+}
+
+main()
+
+```
+
+
+
+---
+
+
+# Below you will find several examples that you can implement in your project:
+
+
+
+
+
+
[External API Call](/providers/baileys/external-api)
+
[Blocked Users on Bot](/providers/baileys/blocked-users) - fetchBlocklist()
+
[Contacts on Bot](/providers/baileys/contacts-on-bot)