11# CCAI Node.js Client
22
3- A TypeScript client for the Cloud Contact AI API that allows you to easily send SMS messages.
3+ A TypeScript client for the Cloud Contact AI API that allows you to easily send SMS and MMS messages.
44
55## Requirements
66
@@ -20,6 +20,8 @@ npm run build
2020
2121## Usage
2222
23+ ### SMS
24+
2325``` typescript
2426import { CCAI } from ' ccai-node' ;
2527
@@ -58,6 +60,62 @@ ccai.sms.sendSingle(
5860 .catch (error => console .error (' Error:' , error ));
5961```
6062
63+ ### MMS
64+
65+ ``` typescript
66+ import { CCAI , Account , SMSOptions } from ' ccai-node' ;
67+
68+ // Initialize the client
69+ const ccai = new CCAI ({
70+ clientId: ' YOUR-CLIENT-ID' ,
71+ apiKey: ' API-KEY-TOKEN'
72+ });
73+
74+ // Define a progress callback
75+ const trackProgress = (status : string ) => {
76+ console .log (` Progress: ${status } ` );
77+ };
78+
79+ // Create options with progress tracking
80+ const options: SMSOptions = {
81+ timeout: 60000 ,
82+ onProgress: trackProgress
83+ };
84+
85+ // Complete MMS workflow (get URL, upload image, send MMS)
86+ async function sendMmsWithImage() {
87+ try {
88+ // Path to your image file
89+ const imagePath = ' path/to/your/image.jpg' ;
90+ const contentType = ' image/jpeg' ;
91+
92+ // Define recipient
93+ const account: Account = {
94+ firstName: ' John' ,
95+ lastName: ' Doe' ,
96+ phone: ' +15551234567'
97+ };
98+
99+ // Send MMS with image in one step
100+ const response = await ccai .mms .sendWithImage (
101+ imagePath ,
102+ contentType ,
103+ [account ],
104+ " Hello ${firstName}, check out this image!" ,
105+ " MMS Campaign Example" ,
106+ options
107+ );
108+
109+ console .log (` MMS sent! Campaign ID: ${response .campaignId } ` );
110+ } catch (error ) {
111+ console .error (' Error sending MMS:' , error );
112+ }
113+ }
114+
115+ // Call the function
116+ sendMmsWithImage ();
117+ ```
118+
61119### Using Async/Await
62120
63121``` typescript
@@ -96,6 +154,7 @@ async function sendMessages() {
96154 - ` ccai.ts ` - Main CCAI client class
97155 - ` sms/ ` - SMS-related functionality
98156 - ` sms.ts ` - SMS service class
157+ - ` mms.ts ` - MMS service class
99158 - ` index.ts ` - Main exports
100159 - ` examples/ ` - Example usage
101160 - ` __tests__/ ` - Test files
@@ -192,7 +251,9 @@ This project includes a `.gitignore` file that excludes:
192251
193252- TypeScript support with full type definitions
194253- Promise-based API with async/await support
195- - Support for sending to multiple recipients
254+ - Support for sending SMS to multiple recipients
255+ - Support for sending MMS with images
256+ - Upload images to S3 with signed URLs
196257- Support for template variables (firstName, lastName)
197258- Progress tracking via callbacks
198259- Comprehensive error handling
0 commit comments