[Tool] add send media message images#11
Conversation
This reverts commit b2806ed.
src/whatsapp-service.ts
Outdated
| if (mediaType === 'url') { | ||
| media = await MessageMedia.fromUrl(mediaLocation); | ||
| } else { | ||
| media = await MessageMedia.fromFilePath(mediaLocation); |
There was a problem hiding this comment.
We need to add a way to restrict the access files only from allowed paths
There was a problem hiding this comment.
addressed with new commits
src/types.ts
Outdated
|
|
||
| export interface SendMediaMessageParams { | ||
| number: string; | ||
| mediaType: 'url' | 'local'; |
There was a problem hiding this comment.
What if instead of adding media type as params, we decide that by the location: if location starts with http:// or https:// its url, if it starts with file:// its local?
There was a problem hiding this comment.
good suggestion. implemented and removed the mediaType param, renamed mediaLocation to source
I'll make a follow on PR to video and voice note support
src/mcp-server.ts
Outdated
| number: z.string().describe('The phone number to send the message to'), | ||
| mediaType: z.enum(['url', 'local']).describe('Whether the media is from a URL or local file'), | ||
| mediaLocation: z.string().describe('The URL or local file path of the image'), | ||
| caption: z.string().optional().describe('Optional caption for the image'), |
There was a problem hiding this comment.
Because of limitations on OpenAI response API, that doesn't support optional fields on tools for now, we need to remove the optional() or add a configuration that disable all optional fields
There was a problem hiding this comment.
I think there is support for this. You can specify required properties. But updated to default to '' when not passed in
This change extends the existing functionality by adding the ability to send media messages (images only for now)
Changes:
tsconfig.jsonand package.jsonfiles before runningnpm install`/send_mediaendpoint to apisendMediaMessagemethod to whatsapp api client and servicewhatsapp-service.test.tsto test newly added method)