-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'fix/charity' of http://github.com/ai16z/eliza into develop
- Loading branch information
Showing
7 changed files
with
184 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"name": "@ai16z/client-whatsapp", | ||
"version": "0.0.1", | ||
"description": "WhatsApp client for Eliza", | ||
"main": "dist/index.js", | ||
"types": "dist/index.d.ts", | ||
"scripts": { | ||
"build": "tsc", | ||
"clean": "rimraf dist", | ||
"test": "jest", | ||
"lint": "eslint src --ext .ts" | ||
}, | ||
"dependencies": { | ||
"@ai16z/eliza": "workspace:*" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "^20.0.0", | ||
"typescript": "^5.0.0", | ||
"rimraf": "^5.0.0", | ||
"jest": "^29.0.0", | ||
"@types/jest": "^29.0.0" | ||
} | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { IAgentRuntime } from "@ai16z/eliza"; | ||
|
||
export async function validateWhatsAppConfig( | ||
runtime: IAgentRuntime | ||
): Promise<void> { | ||
const requiredSettings = [ | ||
"WHATSAPP_API_TOKEN", | ||
"WHATSAPP_PHONE_NUMBER_ID", | ||
"WHATSAPP_APP_ID", | ||
"WHATSAPP_APP_SECRET", | ||
"WHATSAPP_WEBHOOK_VERIFY_TOKEN" | ||
]; | ||
|
||
for (const setting of requiredSettings) { | ||
if (!runtime.getSetting(setting)) { | ||
throw new Error( | ||
`Missing required WhatsApp configuration: ${setting}` | ||
); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { elizaLogger } from "@ai16z/eliza"; | ||
import { Client, IAgentRuntime } from "@ai16z/eliza"; | ||
import { WhatsAppClient } from "./whatsappClient"; | ||
import { validateWhatsAppConfig } from "../../../eliza/packages/client-whatsapp/src/environment"; | ||
|
||
export const WhatsAppClientInterface: Client = { | ||
start: async (runtime: IAgentRuntime) => { | ||
await validateWhatsAppConfig(runtime); | ||
|
||
const client = new WhatsAppClient( | ||
runtime, | ||
runtime.getSetting("WHATSAPP_API_TOKEN"), | ||
runtime.getSetting("WHATSAPP_PHONE_NUMBER_ID") | ||
); | ||
|
||
await client.start(); | ||
|
||
elizaLogger.success( | ||
`✅ WhatsApp client successfully started for character ${runtime.character.name}` | ||
); | ||
return client; | ||
}, | ||
stop: async (runtime: IAgentRuntime) => { | ||
elizaLogger.warn("WhatsApp client stopping..."); | ||
}, | ||
}; | ||
|
||
export default WhatsAppClientInterface; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.