diff --git a/agent/src/index.ts b/agent/src/index.ts index e93231050e..87e01cf306 100644 --- a/agent/src/index.ts +++ b/agent/src/index.ts @@ -526,7 +526,12 @@ export async function createAgent( // character.plugins are handled when clients are added plugins: [ bootstrapPlugin, - twilioPlugin, + getSecret(character, "TWILIO_ACCOUNT_SID") && + getSecret(character, "TWILIO_AUTH_TOKEN") && + getSecret(character, "TWILIO_PHONE_NUMBER") && + getSecret(character, "TWILIO_WHATSAPP_PHONE_NUMBER") + ? twilioPlugin + : null, getSecret(character, "CONFLUX_CORE_PRIVATE_KEY") ? confluxPlugin : null, diff --git a/packages/plugin-twilio/src/actions/sendSms.ts b/packages/plugin-twilio/src/actions/sendSms.ts index c3b8c6311f..cae33f1255 100644 --- a/packages/plugin-twilio/src/actions/sendSms.ts +++ b/packages/plugin-twilio/src/actions/sendSms.ts @@ -31,8 +31,6 @@ export const sendSmsAction: Action = { const accountSid = process.env.TWILIO_ACCOUNT_SID; const authToken = process.env.TWILIO_AUTH_TOKEN; - console.log("CHECK _message: ",_message.content.text); - if (!accountSid || !authToken) { console.error('TWILIO_ACCOUNT_SID or TWILIO_AUTH_TOKEN is not set'); return false; @@ -67,10 +65,6 @@ export const sendSmsAction: Action = { const twilioNumber = process.env.TWILIO_PHONE_NUMBER; // Your Twilio phone number - console.log('check target mobile number: ', mobileNumberProvidedByUser); - console.log('check messageToSendFromUser: ', messageToSendFromUser); - console.log('check twilioNumber: ', twilioNumber); - if (!twilioNumber) { console.error('Twilio phone number is missing'); @@ -140,7 +134,8 @@ export const sendSmsAction: Action = { from: twilioNumber, // Your Twilio phone number }); - console.log("message body: ", message); + // for debug purposes uncomment this + console.log("check twilio message body: ", message); const messageFromAgent = `SMS sent successfully to ${mobileNumberProvidedByUser}`; diff --git a/packages/plugin-twilio/src/actions/sendWhatsAppMessage.ts b/packages/plugin-twilio/src/actions/sendWhatsAppMessage.ts index f9ec774441..0c76fd48ca 100644 --- a/packages/plugin-twilio/src/actions/sendWhatsAppMessage.ts +++ b/packages/plugin-twilio/src/actions/sendWhatsAppMessage.ts @@ -63,15 +63,13 @@ export const sendWhatsAppMessageAction: Action = { } } - const twilioNumber = process.env.TWILIO_WHATSAPP_PHONE_NUMBER; // Your Twilio WhatsApp number - - console.log('check target mobile number: ', mobileNumberProvidedByUser); - console.log('check messageToSendFromUser: ', messageToSendFromUser); - console.log('check twilioNumber: ', twilioNumber); + // Your Twilio WhatsApp enabled phone number this is a different from twilio regular phone number + const twilioNumber = process.env.TWILIO_WHATSAPP_PHONE_NUMBER; if (!mobileNumberProvidedByUser) { console.error('Mobile number is missing'); + //TODO: this can be improve by letting the AI Agent generate his/her own reply for the specific issue _callback({ text: `Sorry there was an issue sending the WhatsApp message, please try again later`, }); @@ -81,6 +79,7 @@ export const sendWhatsAppMessageAction: Action = { if (!twilioNumber) { console.error('Twilio WhatsApp number is missing'); + //TODO: this can be improve by letting the AI Agent generate his/her own reply for the specific issue _callback({ text: `Sorry there was an issue sending the WhatsApp message, please try again later`, }); @@ -90,6 +89,7 @@ export const sendWhatsAppMessageAction: Action = { if(messageToSendFromUser==null){ console.error('messageToSendFromUser is empty or null'); + //TODO: this can be improve by letting the AI Agent generate his/her own reply for the specific issue _callback({ text: `Sorry there was an issue sending the WhatsApp message, please try again later`, }); @@ -107,8 +107,10 @@ export const sendWhatsAppMessageAction: Action = { from: `whatsapp:${twilioNumber}`, // Your Twilio WhatsApp number }); - console.log("message body: ", message); + // for debug purposes uncomment this + console.log("check twilio message body: ", message); + //TODO: this can be improve by letting the AI Agent generate his/her own reply to user const messageFromAgent = `WhatsApp message sent successfully to ${mobileNumberProvidedByUser}`; // Call the callback to notify the user