Questions tagged with Amazon Pinpoint

Content language: English

Sort by most recent

Browse through the questions and answers listed below or filter and sort to narrow down your results.

create_import_job() on Lambda using Amazon Pinpoint API

I'm trying to use this code, to create a single lambda function that will Import a Segment from an **S3 bucket** and after that use the response from it, so I can pass it to the **create_campaign(**) function, and send a sample Push Campaign right away after importing ![Enter image description here](https://repost.aws/media/postImages/original/IMUMs_yxgQRhC9rvU7gZSVDQ) Since I need a segment ID from the **create_import_job_response** before running the **create_campaign** , I need to wait for it to finish first. After its is finish ,I was able to get the segment ID(checking from the function logs) right after I run the lambda function. ![Enter image description here](https://repost.aws/media/postImages/original/IMkxWvSBmyTZCTTDqYSHFcpA) But I wasn't able to use it right away when giving it to the **create_campaign()** and giving this error.![Enter image description here](https://repost.aws/media/postImages/original/IMJM7XQnMDSm6opE9dfqmcAw) I'm aware that the reason of this is that the import job status is not yet completed or in a **In progress** state so thats why its giving its error. We tried a work around and implemented a for loop that will check the import job status until we get the **COMPLETED** status, it works.We even added a **WAIT** state and set it for 5secs and it works also. But, still not yet convinced to this solution since for the pricing of Lambda it bills every milliseconds it runs the function, and for a larger scale it will be a waste if we run this loop over and over again just to get the **COMPLETED **status, and still not running what is the main function is which is to send the campaign. ![Enter image description here](https://repost.aws/media/postImages/original/IMtchp6SqgRiSf5b0FfO2kTg) Is there any way or best practice on running the create_import_job function? That will give the **COMPLETED** job status right away as long it is finish when called? I'm still currently searching for any solution but still no luck. Any sample article or code will help if anyone knows or encountered this same issue, Thank you!
0
answers
0
votes
40
views
asked 4 months ago

pinpoint.updateEndpoint Giving error "NotFoundException: Resource not found"

I am trying to create a dynamic segment in amazon pinpoint and then add endpoints. In Postman i am able to create/update the pinpoint endpoint with AWS signature but when I tried to implement the same in the NodeJS project i am getting "Resource Not Found" exception. Where i am missing something? Any solution, please! here is my code: ``` const AWS = require('aws-sdk'); accessKeyId = process.env.ACCESS_KEY_ID, secretKey = process.env.SECRET_KEY AWS.config.update({ region: 'ap-southeast-2', accessKey: accessKeyId, secretAccessKey: secretKey, }); const pinpoint = new AWS.Pinpoint({ accessKey: accessKeyId, secretAccessKey: secretKey, region: 'ap-southeast-2', signatureVersion: 'v4', }); const endpointAddress = obj.phone; console.log(">>>Endpoint Address: ", endpointAddress) //I am getting this value const endpointID = obj_id.toString(); console.log(">>>EndpointID: ", endpointID) //I am getting this value as well const params = { ApplicationId: 'a35e50bc1ec54c18a53294c6e610da5d' /* required */, EndpointId: endpointID /* required */, EndpointRequest: { /* required */ Address: endpointAddress, ChannelType: 'VOICE', EndpointStatus: 'ACTIVE', OptOut: 'NONE', Location: { Country: obj.country, }, Demographic: { Make: 'Apple', Platform: 'iOS', }, EffectiveDate: '2022-08-11', Attributes: { Interests: ['Technology', 'Music', 'Travel'], CampaignIdentifier: ['OB'], }, Metrics: { technology_interest_level: 9, music_interest_level: 6, travel_interest_level: 4, }, User: { UserAttributes: { firstName: [obj.firstname], lastName: [obj.lastname], country: [obj.country] }, UserId: "user-20" //obj_id.toString() }, }, }; pinpoint.updateEndpoint(params).promise().catch((er) => { console.log(er); }); return endpointID; //res.status(200).end(); }); ```
2
answers
-1
votes
119
views
asked 4 months ago